From: Wim Taymans Date: Thu, 29 May 2003 13:02:16 +0000 (+0000) Subject: - small cleanups X-Git-Tag: BRANCH-ERROR-ROOT~145 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3faa5fd3df922be7e01ac4780f018b36875aac0d;p=platform%2Fupstream%2Fgst-plugins-base.git - small cleanups Original commit message from CVS: - small cleanups - fix offset - added blocksize property --- diff --git a/ext/vorbis/vorbisfile.c b/ext/vorbis/vorbisfile.c index 085911058..a694460fa 100644 --- a/ext/vorbis/vorbisfile.c +++ b/ext/vorbis/vorbisfile.c @@ -38,28 +38,30 @@ typedef struct _VorbisFile VorbisFile; typedef struct _VorbisFileClass VorbisFileClass; struct _VorbisFile { - GstElement element; + GstElement element; - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, + *srcpad; GstByteStream *bs; OggVorbis_File vf; - gint current_link; - - gboolean restart; - gboolean need_discont; - gboolean eos; - gboolean seek_pending; - gint64 seek_value; - GstFormat seek_format; - gboolean seek_accurate; - - gboolean may_eos; - guint64 total_bytes; - guint64 offset; - - GstCaps *metadata; - GstCaps *streaminfo; + gint current_link; + + gboolean restart; + gboolean need_discont; + gboolean eos; + gboolean seek_pending; + gint64 seek_value; + GstFormat seek_format; + gboolean seek_accurate; + + gboolean may_eos; + guint64 total_bytes; + guint64 offset; + gulong blocksize; + + GstCaps *metadata; + GstCaps *streaminfo; }; struct _VorbisFileClass { @@ -90,9 +92,12 @@ enum LAST_SIGNAL }; +#define DEFAULT_BLOCKSIZE 4096 + enum { ARG_0, + ARG_BLOCKSIZE, ARG_METADATA, ARG_STREAMINFO }; @@ -175,6 +180,9 @@ gst_vorbisfile_class_init (VorbisFileClass * klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, + g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer", + 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_METADATA, g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata", GST_TYPE_CAPS, G_PARAM_READABLE)); @@ -217,6 +225,7 @@ gst_vorbisfile_init (VorbisFile * vorbisfile) vorbisfile->metadata = NULL; vorbisfile->streaminfo = NULL; vorbisfile->current_link = -1; + vorbisfile->blocksize = DEFAULT_BLOCKSIZE; } /* the next four functions are the ov callbacks we provide to vorbisfile @@ -564,9 +573,7 @@ gst_vorbisfile_loop (GstElement *element) return; } - outbuf = gst_buffer_new (); - GST_BUFFER_DATA (outbuf) = g_malloc (4096); - GST_BUFFER_SIZE (outbuf) = 4096; + outbuf = gst_buffer_new_and_alloc (vorbisfile->blocksize); /* get current time for discont and buffer timestamp */ time = (GstClockTime) (ov_time_tell (&vorbisfile->vf) * GST_SECOND); @@ -615,6 +622,7 @@ gst_vorbisfile_loop (GstElement *element) GST_BUFFER_SIZE (outbuf) = ret; GST_BUFFER_TIMESTAMP (outbuf) = time; + GST_BUFFER_OFFSET (outbuf) = ov_pcm_tell (&vorbisfile->vf); vorbisfile->may_eos = TRUE; @@ -1039,6 +1047,9 @@ gst_vorbisfile_set_property (GObject *object, guint prop_id, vorbisfile = GST_VORBISFILE (object); switch (prop_id) { + case ARG_BLOCKSIZE: + vorbisfile->blocksize = g_value_get_ulong (value); + break; default: g_warning ("Unknown property id\n"); } @@ -1055,6 +1066,9 @@ gst_vorbisfile_get_property (GObject *object, guint prop_id, vorbisfile = GST_VORBISFILE (object); switch (prop_id) { + case ARG_BLOCKSIZE: + g_value_set_ulong (value, vorbisfile->blocksize); + break; case ARG_METADATA: g_value_set_boxed (value, vorbisfile->metadata); break;