From 9e572ebf0065421567134e942d24ae26f0cee55d Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Wed, 13 Aug 2008 12:34:13 +0000 Subject: ext/pulse/: Improve debugging a bit by including the parent object in pulsemixerctrl and pulseprobe objects and using... Original commit message from CVS: * ext/pulse/pulsemixer.c: (gst_pulsemixer_change_state): * ext/pulse/pulsemixerctrl.c: (gst_pulsemixer_ctrl_subscribe_cb), (gst_pulsemixer_ctrl_open), (gst_pulsemixer_ctrl_new), (gst_pulsemixer_ctrl_free), (gst_pulsemixer_ctrl_timeout_event): * ext/pulse/pulsemixerctrl.h: * ext/pulse/pulseprobe.c: (gst_pulseprobe_open), (gst_pulseprobe_enumerate), (gst_pulseprobe_new), (gst_pulseprobe_free), (gst_pulseprobe_needs_probe), (gst_pulseprobe_probe_property), (gst_pulseprobe_get_values): * ext/pulse/pulseprobe.h: * ext/pulse/pulsesink.c: (gst_pulsesink_init): * ext/pulse/pulsesrc.c: (gst_pulsesrc_init), (gst_pulsesrc_delay), (gst_pulsesrc_change_state): Improve debugging a bit by including the parent object in pulsemixerctrl and pulseprobe objects and using GST_WARNING_OBJECT instead of GST_WARNING. Use the parent GObject subclass instead of a random struct as GObject parameter for G_OBJECT_WARN_INVALID_PROPERTY_ID. This fixes a crash when probing for another property than "device". --- ext/pulse/pulsemixer.c | 4 ++-- ext/pulse/pulsemixerctrl.c | 32 +++++++++++++++++--------------- ext/pulse/pulsemixerctrl.h | 4 +++- ext/pulse/pulseprobe.c | 32 ++++++++++++++++++-------------- ext/pulse/pulseprobe.h | 5 +++-- ext/pulse/pulsesink.c | 12 +++++++----- ext/pulse/pulsesrc.c | 13 +++++++------ 7 files changed, 57 insertions(+), 45 deletions(-) (limited to 'ext/pulse') diff --git a/ext/pulse/pulsemixer.c b/ext/pulse/pulsemixer.c index ad724df1..434a606c 100644 --- a/ext/pulse/pulsemixer.c +++ b/ext/pulse/pulsemixer.c @@ -271,8 +271,8 @@ gst_pulsemixer_change_state (GstElement * element, GstStateChange transition) if (!this->mixer) this->mixer = - gst_pulsemixer_ctrl_new (this->server, this->device, - GST_PULSEMIXER_UNKNOWN); + gst_pulsemixer_ctrl_new (G_OBJECT (this), this->server, + this->device, GST_PULSEMIXER_UNKNOWN); break; diff --git a/ext/pulse/pulsemixerctrl.c b/ext/pulse/pulsemixerctrl.c index f2fb3c5d..0b605cb4 100644 --- a/ext/pulse/pulsemixerctrl.c +++ b/ext/pulse/pulsemixerctrl.c @@ -176,7 +176,7 @@ gst_pulsemixer_ctrl_subscribe_cb (pa_context * context, gst_pulsemixer_ctrl_source_info_cb, c); if (!o) { - GST_WARNING ("Failed to get sink info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s", pa_strerror (pa_context_errno (c->context))); return; } @@ -198,7 +198,7 @@ gst_pulsemixer_ctrl_success_cb (pa_context * context, int success, #define CHECK_DEAD_GOTO(c, label) do { \ if (!(c)->context || pa_context_get_state((c)->context) != PA_CONTEXT_READY) { \ - GST_WARNING("Not connected: %s", (c)->context ? pa_strerror(pa_context_errno((c)->context)) : "NULL"); \ + GST_WARNING_OBJECT (c->object, "Not connected: %s", (c)->context ? pa_strerror(pa_context_errno((c)->context)) : "NULL"); \ goto label; \ } \ } while(0); @@ -224,7 +224,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) if (!(c->context = pa_context_new (pa_threaded_mainloop_get_api (c->mainloop), name))) { - GST_WARNING ("Failed to create context"); + GST_WARNING_OBJECT (c->object, "Failed to create context"); goto unlock_and_fail; } @@ -234,7 +234,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) gst_pulsemixer_ctrl_subscribe_cb, c); if (pa_context_connect (c->context, c->server, 0, NULL) < 0) { - GST_WARNING ("Failed to connect context: %s", + GST_WARNING_OBJECT (c->object, "Failed to connect context: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -243,7 +243,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) pa_threaded_mainloop_wait (c->mainloop); if (pa_context_get_state (c->context) != PA_CONTEXT_READY) { - GST_WARNING ("Failed to connect context: %s", + GST_WARNING_OBJECT (c->object, "Failed to connect context: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -254,7 +254,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) pa_context_subscribe (c->context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, gst_pulsemixer_ctrl_success_cb, c))) { - GST_WARNING ("Failed to subscribe to events: %s", + GST_WARNING_OBJECT (c->object, "Failed to subscribe to events: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -266,7 +266,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) } if (!c->operation_success) { - GST_WARNING ("Failed to subscribe to events: %s", + GST_WARNING_OBJECT (c->object, "Failed to subscribe to events: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -277,7 +277,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) if (!(o = pa_context_get_sink_info_by_name (c->context, c->device, gst_pulsemixer_ctrl_sink_info_cb, c))) { - GST_WARNING ("Failed to get sink info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -293,7 +293,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) if (!c->operation_success && (c->type == GST_PULSEMIXER_SINK || pa_context_errno (c->context) != PA_ERR_NOENTITY)) { - GST_WARNING ("Failed to get sink info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -303,7 +303,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) if (!(o = pa_context_get_source_info_by_name (c->context, c->device, gst_pulsemixer_ctrl_source_info_cb, c))) { - GST_WARNING ("Failed to get source info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get source info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -318,7 +318,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) o = NULL; if (!c->operation_success) { - GST_WARNING ("Failed to get source info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get source info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -380,12 +380,13 @@ gst_pulsemixer_ctrl_close (GstPulseMixerCtrl * c) } GstPulseMixerCtrl * -gst_pulsemixer_ctrl_new (const gchar * server, const gchar * device, - GstPulseMixerType type) +gst_pulsemixer_ctrl_new (GObject * object, const gchar * server, + const gchar * device, GstPulseMixerType type) { GstPulseMixerCtrl *c = NULL; c = g_new (GstPulseMixerCtrl, 1); + c->object = g_object_ref (object); c->tracklist = NULL; c->server = g_strdup (server); c->device = g_strdup (device); @@ -424,6 +425,7 @@ gst_pulsemixer_ctrl_free (GstPulseMixerCtrl * c) g_free (c->device); g_free (c->name); g_free (c->description); + g_object_unref (c->object); g_free (c); } @@ -452,7 +454,7 @@ gst_pulsemixer_ctrl_timeout_event (pa_mainloop_api * a, pa_time_event * e, &c->volume, NULL, NULL); if (!o) - GST_WARNING ("Failed to set device volume: %s", + GST_WARNING_OBJECT (c->object, "Failed to set device volume: %s", pa_strerror (pa_context_errno (c->context))); else pa_operation_unref (o); @@ -469,7 +471,7 @@ gst_pulsemixer_ctrl_timeout_event (pa_mainloop_api * a, pa_time_event * e, NULL, NULL); if (!o) - GST_WARNING ("Failed to set device mute: %s", + GST_WARNING_OBJECT (c->object, "Failed to set device mute: %s", pa_strerror (pa_context_errno (c->context))); else pa_operation_unref (o); diff --git a/ext/pulse/pulsemixerctrl.h b/ext/pulse/pulsemixerctrl.h index 360711a5..0dbc1391 100644 --- a/ext/pulse/pulsemixerctrl.h +++ b/ext/pulse/pulsemixerctrl.h @@ -42,6 +42,8 @@ typedef enum struct _GstPulseMixerCtrl { + GObject *object; + GList *tracklist; gchar *server, *device; @@ -67,7 +69,7 @@ struct _GstPulseMixerCtrl gboolean update_volume, update_mute; }; -GstPulseMixerCtrl *gst_pulsemixer_ctrl_new (const gchar * server, +GstPulseMixerCtrl *gst_pulsemixer_ctrl_new (GObject *object, const gchar * server, const gchar * device, GstPulseMixerType type); void gst_pulsemixer_ctrl_free (GstPulseMixerCtrl * mixer); diff --git a/ext/pulse/pulseprobe.c b/ext/pulse/pulseprobe.c index 97f3c7c7..5d2e0b7e 100644 --- a/ext/pulse/pulseprobe.c +++ b/ext/pulse/pulseprobe.c @@ -114,7 +114,7 @@ gst_pulseprobe_open (GstPulseProbe * c) if (!(c->context = pa_context_new (pa_threaded_mainloop_get_api (c->mainloop), name))) { - GST_WARNING ("Failed to create context"); + GST_WARNING_OBJECT (c->object, "Failed to create context"); goto unlock_and_fail; } @@ -122,7 +122,7 @@ gst_pulseprobe_open (GstPulseProbe * c) c); if (pa_context_connect (c->context, c->server, 0, NULL) < 0) { - GST_WARNING ("Failed to connect context: %s", + GST_WARNING_OBJECT (c->object, "Failed to connect context: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -131,7 +131,7 @@ gst_pulseprobe_open (GstPulseProbe * c) pa_threaded_mainloop_wait (c->mainloop); if (pa_context_get_state (c->context) != PA_CONTEXT_READY) { - GST_WARNING ("Failed to connect context: %s", + GST_WARNING_OBJECT (c->object, "Failed to connect context: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -155,7 +155,7 @@ unlock_and_fail: #define CHECK_DEAD_GOTO(c, label) do { \ if (!(c)->context || pa_context_get_state((c)->context) != PA_CONTEXT_READY) { \ - GST_WARNING("Not connected: %s", (c)->context ? pa_strerror(pa_context_errno((c)->context)) : "NULL"); \ + GST_WARNING_OBJECT((c)->object, "Not connected: %s", (c)->context ? pa_strerror(pa_context_errno((c)->context)) : "NULL"); \ goto label; \ } \ } while(0); @@ -173,7 +173,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c) if (!(o = pa_context_get_sink_info_list (c->context, gst_pulseprobe_sink_info_cb, c))) { - GST_WARNING ("Failed to get sink info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -185,7 +185,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c) } if (!c->operation_success) { - GST_WARNING ("Failed to get sink info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -200,7 +200,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c) if (!(o = pa_context_get_source_info_list (c->context, gst_pulseprobe_source_info_cb, c))) { - GST_WARNING ("Failed to get source info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get source info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -212,7 +212,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c) } if (!c->operation_success) { - GST_WARNING ("Failed to get sink info: %s", + GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s", pa_strerror (pa_context_errno (c->context))); goto unlock_and_fail; } @@ -258,12 +258,13 @@ gst_pulseprobe_close (GstPulseProbe * c) } GstPulseProbe * -gst_pulseprobe_new (GObjectClass * klass, guint prop_id, const gchar * server, - gboolean sinks, gboolean sources) +gst_pulseprobe_new (GObject * object, GObjectClass * klass, guint prop_id, + const gchar * server, gboolean sinks, gboolean sources) { GstPulseProbe *c = NULL; c = g_new (GstPulseProbe, 1); + c->object = g_object_ref (object); c->server = g_strdup (server); c->enumerate_sinks = sinks; c->enumerate_sources = sources; @@ -293,6 +294,8 @@ gst_pulseprobe_free (GstPulseProbe * c) g_list_foreach (c->devices, (GFunc) g_free, NULL); g_list_free (c->devices); + g_object_unref (c->object); + g_free (c); } @@ -310,7 +313,7 @@ gst_pulseprobe_needs_probe (GstPulseProbe * c, guint prop_id, if (prop_id == c->prop_id) return !c->devices_valid; - G_OBJECT_WARN_INVALID_PROPERTY_ID (c, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (c->object, prop_id, pspec); return FALSE; } @@ -320,7 +323,7 @@ gst_pulseprobe_probe_property (GstPulseProbe * c, guint prop_id, { if (prop_id != c->prop_id) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (c, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (c->object, prop_id, pspec); return; } @@ -339,7 +342,7 @@ gst_pulseprobe_get_values (GstPulseProbe * c, guint prop_id, GList *item; if (prop_id != c->prop_id) { - G_OBJECT_WARN_INVALID_PROPERTY_ID (c, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID (c->object, prop_id, pspec); return NULL; } @@ -349,7 +352,8 @@ gst_pulseprobe_get_values (GstPulseProbe * c, guint prop_id, array = g_value_array_new (g_list_length (c->devices)); g_value_init (&value, G_TYPE_STRING); for (item = c->devices; item != NULL; item = item->next) { - GST_WARNING ("device found: %s", (const gchar *) item->data); + GST_WARNING_OBJECT (c->object, "device found: %s", + (const gchar *) item->data); g_value_set_string (&value, (const gchar *) item->data); g_value_array_append (array, &value); } diff --git a/ext/pulse/pulseprobe.h b/ext/pulse/pulseprobe.h index d27c44d9..3baf6db6 100644 --- a/ext/pulse/pulseprobe.h +++ b/ext/pulse/pulseprobe.h @@ -34,6 +34,7 @@ typedef struct _GstPulseProbe GstPulseProbe; struct _GstPulseProbe { + GObject *object; gchar *server; GList *devices; int devices_valid; @@ -48,8 +49,8 @@ struct _GstPulseProbe int operation_success; }; -GstPulseProbe *gst_pulseprobe_new (GObjectClass * klass, guint prop_id, - const gchar * server, gboolean sinks, gboolean sources); +GstPulseProbe *gst_pulseprobe_new (GObject *object, GObjectClass * klass, + guint prop_id, const gchar * server, gboolean sinks, gboolean sources); void gst_pulseprobe_free (GstPulseProbe * probe); const GList *gst_pulseprobe_get_properties (GstPulseProbe * probe); diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index b22f52d2..2408dda9 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -249,7 +249,7 @@ gst_pulsesink_init (GTypeInstance * instance, gpointer g_class) e = pa_threaded_mainloop_start (pulsesink->mainloop); g_assert (e == 0); - pulsesink->probe = gst_pulseprobe_new (G_OBJECT_GET_CLASS (pulsesink), PROP_DEVICE, pulsesink->device, TRUE, FALSE); /* TRUE for sinks, FALSE for sources */ + pulsesink->probe = gst_pulseprobe_new (G_OBJECT (pulsesink), G_OBJECT_GET_CLASS (pulsesink), PROP_DEVICE, pulsesink->device, TRUE, FALSE); /* TRUE for sinks, FALSE for sources */ } static void @@ -489,14 +489,16 @@ gst_pulsesink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec) if (!pulsesink->context || pa_context_get_state (pulsesink->context) != PA_CONTEXT_READY) { GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED, ("Bad context state: %s", - pulsesink->context ? pa_strerror (pa_context_errno (pulsesink-> - context)) : NULL), (NULL)); + pulsesink-> + context ? pa_strerror (pa_context_errno (pulsesink->context)) : + NULL), (NULL)); goto unlock_and_fail; } if (!(pulsesink->stream = pa_stream_new (pulsesink->context, - pulsesink->stream_name ? pulsesink-> - stream_name : "Playback Stream", &pulsesink->sample_spec, + pulsesink-> + stream_name ? pulsesink->stream_name : "Playback Stream", + &pulsesink->sample_spec, gst_pulse_gst_to_channel_map (&channel_map, spec)))) { GST_ELEMENT_ERROR (pulsesink, RESOURCE, FAILED, ("Failed to create stream: %s", diff --git a/ext/pulse/pulsesrc.c b/ext/pulse/pulsesrc.c index e270c430..23597481 100644 --- a/ext/pulse/pulsesrc.c +++ b/ext/pulse/pulsesrc.c @@ -259,7 +259,7 @@ gst_pulsesrc_init (GTypeInstance * instance, gpointer g_class) pulsesrc->mixer = NULL; - pulsesrc->probe = gst_pulseprobe_new (G_OBJECT_GET_CLASS (pulsesrc), PROP_DEVICE, pulsesrc->device, FALSE, TRUE); /* FALSE for sinks, TRUE for sources */ + pulsesrc->probe = gst_pulseprobe_new (G_OBJECT (pulsesrc), G_OBJECT_GET_CLASS (pulsesrc), PROP_DEVICE, pulsesrc->device, FALSE, TRUE); /* FALSE for sinks, TRUE for sources */ } static void @@ -493,8 +493,9 @@ gst_pulsesrc_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec) if (!pulsesrc->context || pa_context_get_state (pulsesrc->context) != PA_CONTEXT_READY) { GST_ELEMENT_ERROR (pulsesrc, RESOURCE, FAILED, ("Bad context state: %s", - pulsesrc->context ? pa_strerror (pa_context_errno (pulsesrc-> - context)) : NULL), (NULL)); + pulsesrc-> + context ? pa_strerror (pa_context_errno (pulsesrc->context)) : + NULL), (NULL)); goto unlock_and_fail; } @@ -666,7 +667,7 @@ gst_pulsesrc_delay (GstAudioSrc * asrc) goto unlock_and_fail; } - GST_WARNING ("Not data while querying latency"); + GST_WARNING_OBJECT (pulsesrc, "Not data while querying latency"); t = 0; } else if (negative) t = 0; @@ -691,8 +692,8 @@ gst_pulsesrc_change_state (GstElement * element, GstStateChange transition) if (!this->mixer) this->mixer = - gst_pulsemixer_ctrl_new (this->server, this->device, - GST_PULSEMIXER_SOURCE); + gst_pulsemixer_ctrl_new (G_OBJECT (this), this->server, + this->device, GST_PULSEMIXER_SOURCE); break; -- cgit