gst-libs/gst/audio/gstbaseaudiosink.c

Original commit message from CVS:
2007-01-12  Andy Wingo  <wingo@pobox.com>

* gst-libs/gst/audio/gstbaseaudiosink.c
(gst_base_audio_sink_fixate): Implement, stolen from baseaudiosrc.
(gst_base_audio_sink_activate_pull): Remove the handwavey nego
stuff, as the base class handles this now. Actually tell the ring
buffer to start.
(gst_base_audio_sink_callback): Cast the ring buffer correctly.
How did this work before? Maybe I'm not as awesome a programmer as
I think.

* gst-libs/gst/audio/gstbaseaudiosrc.c
(gst_base_audio_src_fixate): Rework as a basesrc vmethod instead
of a pad function.
This commit is contained in:
Andy Wingo 2007-01-12 21:19:35 +00:00
parent b93a9176db
commit d853b23819
3 changed files with 49 additions and 29 deletions

View file

@ -1,3 +1,18 @@
2007-01-12 Andy Wingo <wingo@pobox.com>
* gst-libs/gst/audio/gstbaseaudiosink.c
(gst_base_audio_sink_fixate): Implement, stolen from baseaudiosrc.
(gst_base_audio_sink_activate_pull): Remove the handwavey nego
stuff, as the base class handles this now. Actually tell the ring
buffer to start.
(gst_base_audio_sink_callback): Cast the ring buffer correctly.
How did this work before? Maybe I'm not as awesome a programmer as
I think.
* gst-libs/gst/audio/gstbaseaudiosrc.c
(gst_base_audio_src_fixate): Rework as a basesrc vmethod instead
of a pad function.
2007-01-12 Tim-Philipp Müller <tim at centricular dot net>
* gst-libs/gst/utils/missing-plugins.c: (copy_and_clean_caps):

View file

@ -104,6 +104,7 @@ static void gst_base_audio_sink_get_times (GstBaseSink * bsink,
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_base_audio_sink_setcaps (GstBaseSink * bsink,
GstCaps * caps);
static void gst_base_audio_sink_fixate (GstBaseSink * bsink, GstCaps * caps);
/* static guint gst_base_audio_sink_signals[LAST_SIGNAL] = { 0 }; */
@ -155,6 +156,7 @@ gst_base_audio_sink_class_init (GstBaseAudioSinkClass * klass)
gstbasesink_class->get_times =
GST_DEBUG_FUNCPTR (gst_base_audio_sink_get_times);
gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_base_audio_sink_setcaps);
gstbasesink_class->fixate = GST_DEBUG_FUNCPTR (gst_base_audio_sink_fixate);
gstbasesink_class->async_play =
GST_DEBUG_FUNCPTR (gst_base_audio_sink_async_play);
gstbasesink_class->activate_pull =
@ -375,6 +377,32 @@ acquire_error:
}
}
static void
gst_base_audio_sink_fixate (GstBaseSink * bsink, GstCaps * caps)
{
GstStructure *s;
gint width, depth;
s = gst_caps_get_structure (caps, 0);
/* fields for all formats */
gst_structure_fixate_field_nearest_int (s, "rate", 44100);
gst_structure_fixate_field_nearest_int (s, "channels", 2);
gst_structure_fixate_field_nearest_int (s, "width", 16);
/* fields for int */
if (gst_structure_has_field (s, "depth")) {
gst_structure_get_int (s, "width", &width);
/* round width to nearest multiple of 8 for the depth */
depth = GST_ROUND_UP_8 (width);
gst_structure_fixate_field_nearest_int (s, "depth", depth);
}
if (gst_structure_has_field (s, "signed"))
gst_structure_fixate_field_boolean (s, "signed", TRUE);
if (gst_structure_has_field (s, "endianness"))
gst_structure_fixate_field_nearest_int (s, "endianness", G_BYTE_ORDER);
}
static void
gst_base_audio_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
GstClockTime * start, GstClockTime * end)
@ -824,29 +852,9 @@ gst_base_audio_sink_activate_pull (GstBaseSink * basesink, gboolean active)
GstBaseAudioSink *sink = GST_BASE_AUDIO_SINK (basesink);
if (active) {
GstCaps *sinkcaps, *peercaps, *caps;
gst_ring_buffer_set_callback (sink->ringbuffer,
gst_base_audio_sink_callback, sink);
/* need to spawn a thread to start pulling. that's the ring buffer thread,
which is started in ring_buffer_acquire(), which is called due to a sink
setcaps(). So we need to setcaps, which is tough because we don't know
exactly what caps we'll be getting. We can guess, though, and that's as
good as we're going to get without the user telling us explicitly e.g.
via a capsfilter before the sink. */
sinkcaps = gst_pad_get_caps (basesink->sinkpad);
peercaps = gst_pad_peer_get_caps (basesink->sinkpad);
caps = gst_caps_intersect (sinkcaps, peercaps);
gst_caps_unref (sinkcaps);
gst_caps_unref (peercaps);
gst_caps_truncate (caps);
gst_pad_fixate_caps (basesink->sinkpad, caps);
GST_DEBUG_OBJECT (sink, "initializing pull-mode ringbuffer with caps %"
GST_PTR_FORMAT, caps);
ret = gst_pad_set_caps (basesink->sinkpad, caps);
gst_caps_unref (caps);
ret = gst_ring_buffer_start (sink->ringbuffer);
} else {
gst_ring_buffer_set_callback (sink->ringbuffer, NULL, NULL);
/* stop thread */
@ -865,8 +873,8 @@ gst_base_audio_sink_callback (GstRingBuffer * rbuf, guint8 * data, guint len,
GstBuffer *buf;
GstFlowReturn ret;
basesink = GST_BASE_SINK (data);
sink = GST_BASE_AUDIO_SINK (data);
basesink = GST_BASE_SINK (user_data);
sink = GST_BASE_AUDIO_SINK (user_data);
/* would be nice to arrange for pad_alloc_buffer to return data -- as it is we
will copy twice, once into data, once into DMA */

View file

@ -67,8 +67,6 @@ static void gst_base_audio_src_set_property (GObject * object, guint prop_id,
static void gst_base_audio_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_base_audio_src_fixate (GstPad * pad, GstCaps * caps);
static GstStateChangeReturn gst_base_audio_src_change_state (GstElement *
element, GstStateChange transition);
@ -86,6 +84,7 @@ static gboolean gst_base_audio_src_event (GstBaseSrc * bsrc, GstEvent * event);
static void gst_base_audio_src_get_times (GstBaseSrc * bsrc,
GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
static gboolean gst_base_audio_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps);
static void gst_base_audio_src_fixate (GstBaseSrc * bsrc, GstCaps * caps);
/* static guint gst_base_audio_src_signals[LAST_SIGNAL] = { 0 }; */
@ -136,6 +135,7 @@ gst_base_audio_src_class_init (GstBaseAudioSrcClass * klass)
gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_base_audio_src_create);
gstbasesrc_class->check_get_range =
GST_DEBUG_FUNCPTR (gst_base_audio_src_check_get_range);
gstbasesrc_class->fixate = GST_DEBUG_FUNCPTR (gst_base_audio_src_fixate);
}
static void
@ -151,9 +151,6 @@ gst_base_audio_src_init (GstBaseAudioSrc * baseaudiosrc,
baseaudiosrc->clock = gst_audio_clock_new ("clock",
(GstAudioClockGetTimeFunc) gst_base_audio_src_get_time, baseaudiosrc);
gst_pad_set_fixatecaps_function (GST_BASE_SRC_PAD (baseaudiosrc),
gst_base_audio_src_fixate);
/* we are always a live source */
gst_base_src_set_live (GST_BASE_SRC (baseaudiosrc), TRUE);
/* we operate in time */
@ -292,7 +289,7 @@ gst_base_audio_src_get_property (GObject * object, guint prop_id,
}
static void
gst_base_audio_src_fixate (GstPad * pad, GstCaps * caps)
gst_base_audio_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
{
GstStructure *s;
gint width, depth;