From 9c1c858d248d1cefdda0ee0e32f87a0d235cdaaf Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 4 Feb 2005 15:40:38 +0000 Subject: [PATCH] gst/audioconvert/bufferframesconvert.c Original commit message from CVS: 2005-02-04 Andy Wingo * gst/audioconvert/bufferframesconvert.c (buffer_frames_convert_fixate): New function, fixates to 256 frames per buffer by default. (Much better than 1.) (buffer_frames_convert_init): Set the fixate function for both src and sink pad. (buffer_frames_convert_link): After success setting nonfixed caps, get the negotiated caps so we can know how many buffer-frames it will be. No idea how this worked at all before. --- ChangeLog | 11 +++++++++++ gst/audioconvert/bufferframesconvert.c | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1c0fbbd07..3d55fb1ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-02-04 Andy Wingo + + * gst/audioconvert/bufferframesconvert.c + (buffer_frames_convert_fixate): New function, fixates to 256 + frames per buffer by default. (Much better than 1.) + (buffer_frames_convert_init): Set the fixate function for both src + and sink pad. + (buffer_frames_convert_link): After success setting nonfixed caps, + get the negotiated caps so we can know how many buffer-frames it + will be. No idea how this worked at all before. + 2005-02-05 Jan Schmidt * ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_init), diff --git a/gst/audioconvert/bufferframesconvert.c b/gst/audioconvert/bufferframesconvert.c index 402f3e7c9..b1c316892 100644 --- a/gst/audioconvert/bufferframesconvert.c +++ b/gst/audioconvert/bufferframesconvert.c @@ -93,6 +93,8 @@ static GstElementStateReturn buffer_frames_convert_change_state (GstElement * static GstCaps *buffer_frames_convert_getcaps (GstPad * pad); static GstPadLinkReturn buffer_frames_convert_link (GstPad * pad, const GstCaps * caps); +static GstCaps *buffer_frames_convert_fixate (GstPad * pad, + const GstCaps * caps); static void buffer_frames_convert_chain (GstPad * sinkpad, GstData * _data); @@ -154,12 +156,14 @@ buffer_frames_convert_init (BufferFramesConvert * this) gst_pad_set_link_function (this->sinkpad, buffer_frames_convert_link); gst_pad_set_getcaps_function (this->sinkpad, buffer_frames_convert_getcaps); gst_pad_set_chain_function (this->sinkpad, buffer_frames_convert_chain); + gst_pad_set_fixate_function (this->sinkpad, buffer_frames_convert_fixate); this->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&src_static_template), "src"); gst_element_add_pad (GST_ELEMENT (this), this->srcpad); gst_pad_set_link_function (this->srcpad, buffer_frames_convert_link); gst_pad_set_getcaps_function (this->srcpad, buffer_frames_convert_getcaps); + gst_pad_set_fixate_function (this->sinkpad, buffer_frames_convert_fixate); this->in_buffer_samples = -1; this->out_buffer_samples = -1; @@ -216,6 +220,26 @@ buffer_frames_convert_getcaps (GstPad * pad) return ret; } +static GstCaps * +buffer_frames_convert_fixate (GstPad * pad, const GstCaps * caps) +{ + GstCaps *newcaps; + GstStructure *structure; + + newcaps = gst_caps_new_full (gst_structure_copy (gst_caps_get_structure + (caps, 0)), NULL); + structure = gst_caps_get_structure (newcaps, 0); + + if (gst_caps_structure_fixate_field_nearest_int (structure, + "buffer-frames", 256)) { + return newcaps; + } + + gst_caps_free (newcaps); + + return NULL; +} + static GstPadLinkReturn buffer_frames_convert_link (GstPad * pad, const GstCaps * caps) { @@ -244,6 +268,8 @@ buffer_frames_convert_link (GstPad * pad, const GstCaps * caps) ret = gst_pad_try_set_caps_nonfixed (otherpad, othercaps); if (GST_PAD_LINK_FAILED (ret)) return ret; + gst_caps_free (othercaps); + othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad)); /* it's ok, let's record our data */ sinkstructure = -- 2.34.1