From aa0b2b7ea7865674b9302e3fdedd8a28c880d4fb Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 9 Nov 2011 17:38:03 +0100 Subject: [PATCH] updates for new acceptcaps query --- ext/pulse/pulseaudiosink.c | 40 ++++++++++++++++++++++++++++++++++------ ext/pulse/pulsesink.c | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/ext/pulse/pulseaudiosink.c b/ext/pulse/pulseaudiosink.c index b1db63c..2f6dd76 100644 --- a/ext/pulse/pulseaudiosink.c +++ b/ext/pulse/pulseaudiosink.c @@ -114,8 +114,10 @@ static void gst_pulse_audio_sink_dispose (GObject * object); static gboolean gst_pulse_audio_sink_src_event (GstPad * pad, GstEvent * event); static gboolean gst_pulse_audio_sink_sink_event (GstPad * pad, GstEvent * event); -static gboolean gst_pulse_audio_sink_sink_acceptcaps (GstPad * pad, - GstCaps * caps); +static gboolean gst_pulse_audio_sink_sink_query (GstPad * pad, + GstQuery * query); +static gboolean gst_pulse_audio_sink_sink_acceptcaps (GstPulseAudioSink * pbin, + GstPad * pad, GstCaps * caps); static GstStateChangeReturn gst_pulse_audio_sink_change_state (GstElement * element, GstStateChange transition); @@ -371,8 +373,8 @@ gst_pulse_audio_sink_init (GstPulseAudioSink * pbin) pbin->sinkpad_old_eventfunc = GST_PAD_EVENTFUNC (pbin->sinkpad); gst_pad_set_event_function (pbin->sinkpad, GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_event)); - gst_pad_set_acceptcaps_function (pbin->sinkpad, - GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_acceptcaps)); + gst_pad_set_query_function (pbin->sinkpad, + GST_DEBUG_FUNCPTR (gst_pulse_audio_sink_sink_query)); gst_element_add_pad (GST_ELEMENT (pbin), pbin->sinkpad); @@ -799,9 +801,9 @@ gst_pulse_audio_sink_sink_event (GstPad * pad, GstEvent * event) * means that upstream will have to have everything possibly upto a parser * plugged and we plugin a decoder whenever required. */ static gboolean -gst_pulse_audio_sink_sink_acceptcaps (GstPad * pad, GstCaps * caps) +gst_pulse_audio_sink_sink_acceptcaps (GstPulseAudioSink * pbin, GstPad * pad, + GstCaps * caps) { - GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (gst_pad_get_parent (pad)); GstRingBufferSpec spec = { 0 }; const GstStructure *st; GstCaps *pad_caps = NULL; @@ -839,9 +841,35 @@ out: if (pad_caps) gst_caps_unref (pad_caps); + return ret; +} + +static gboolean +gst_pulse_audio_sink_sink_query (GstPad * pad, GstQuery * query) +{ + GstPulseAudioSink *pbin = GST_PULSE_AUDIO_SINK (gst_pad_get_parent (pad)); + gboolean ret = FALSE; + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_ACCEPT_CAPS: + { + GstCaps *caps; + + gst_query_parse_accept_caps (query, &caps); + ret = gst_pulse_audio_sink_sink_acceptcaps (pbin, pad, caps); + gst_query_set_accept_caps_result (query, ret); + ret = TRUE; + break; + } + default: + ret = gst_pad_query_default (pad, query); + break; + } + gst_object_unref (pbin); return ret; + } static gboolean diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 8b964f7..150308f 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -1736,6 +1736,7 @@ static void gst_pulsesink_get_property (GObject * object, guint prop_id, static void gst_pulsesink_finalize (GObject * object); static gboolean gst_pulsesink_event (GstBaseSink * sink, GstEvent * event); +static gboolean gst_pulsesink_query (GstBaseSink * sink, GstQuery * query); static GstStateChangeReturn gst_pulsesink_change_state (GstElement * element, GstStateChange transition); @@ -1825,6 +1826,7 @@ gst_pulsesink_class_init (GstPulseSinkClass * klass) gobject_class->get_property = gst_pulsesink_get_property; gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_pulsesink_event); + gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_pulsesink_query); /* restore the original basesink pull methods */ bc = g_type_class_peek (GST_TYPE_BASE_SINK); @@ -2004,11 +2006,11 @@ done: /* NOTE: If you're making changes here, see if pulseaudiosink acceptcaps also * needs to be changed accordingly. */ static gboolean -gst_pulsesink_pad_acceptcaps (GstPad * pad, GstCaps * caps) +gst_pulsesink_query_acceptcaps (GstPulseSink * psink, GstCaps * caps) { - GstPulseSink *psink = GST_PULSESINK (gst_pad_get_parent_element (pad)); GstPulseRingBuffer *pbuf = GST_PULSERING_BUFFER_CAST (GST_BASE_AUDIO_SINK (psink)->ringbuffer); + GstPad *pad = GST_BASE_SINK_PAD (psink); GstCaps *pad_caps; GstStructure *st; gboolean ret = FALSE; @@ -2122,7 +2124,6 @@ out: pa_threaded_mainloop_unlock (mainloop); done: - gst_object_unref (psink); return ret; info_failed: @@ -2172,11 +2173,6 @@ gst_pulsesink_init (GstPulseSink * pulsesink) gst_audio_clock_new ("GstPulseSinkClock", (GstAudioClockGetTimeFunc) gst_pulsesink_get_time, pulsesink); -#ifdef HAVE_PULSE_1_0 - gst_pad_set_acceptcaps_function (GST_BASE_SINK (pulsesink)->sinkpad, - GST_DEBUG_FUNCPTR (gst_pulsesink_pad_acceptcaps)); -#endif - /* TRUE for sinks, FALSE for sources */ pulsesink->probe = gst_pulseprobe_new (G_OBJECT (pulsesink), G_OBJECT_GET_CLASS (pulsesink), PROP_DEVICE, pulsesink->device, @@ -2870,6 +2866,30 @@ gst_pulsesink_event (GstBaseSink * sink, GstEvent * event) return GST_BASE_SINK_CLASS (parent_class)->event (sink, event); } +static gboolean +gst_pulsesink_query (GstBaseSink * sink, GstQuery * query) +{ + GstPulseSink *pulsesink = GST_PULSESINK_CAST (sink); + gboolean ret; + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_ACCEPT_CAPS: + { + GstCaps *caps; + + gst_query_parse_accept_caps (query, &caps); + ret = gst_pulsesink_query_acceptcaps (pulsesink, caps); + gst_query_set_accept_caps_result (query, ret); + ret = TRUE; + break; + } + default: + ret = GST_BASE_SINK_CLASS (parent_class)->query (sink, query); + break; + } + return ret; +} + static void gst_pulsesink_release_mainloop (GstPulseSink * psink) { -- 2.7.4