pulse: Remove unused GstPulseProbe
authorOlivier Crête <olivier.crete@collabora.com>
Tue, 13 Aug 2013 21:32:17 +0000 (17:32 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 19 Aug 2013 16:56:27 +0000 (12:56 -0400)
ext/pulse/Makefile.am
ext/pulse/pulseprobe.c [deleted file]
ext/pulse/pulseprobe.h [deleted file]
ext/pulse/pulsesink.c
ext/pulse/pulsesink.h
ext/pulse/pulsesrc.c
ext/pulse/pulsesrc.h

index 04de951..a7dc7a3 100644 (file)
@@ -2,7 +2,6 @@ plugin_LTLIBRARIES = libgstpulse.la
 
 libgstpulse_la_SOURCES = \
        plugin.c \
-       pulseprobe.c \
        pulsesink.c \
        pulsesrc.c \
        pulseutil.c
@@ -15,7 +14,6 @@ libgstpulse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstpulse_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
 
 noinst_HEADERS = \
-       pulseprobe.h \
        pulsesink.h \
        pulsesrc.h \
        pulseutil.h
diff --git a/ext/pulse/pulseprobe.c b/ext/pulse/pulseprobe.c
deleted file mode 100644 (file)
index 3496394..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 2 -*-*/
-
-/*
- *  GStreamer pulseaudio plugin
- *
- *  Copyright (c) 2004-2008 Lennart Poettering
- *
- *  gst-pulse is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Lesser General Public License as
- *  published by the Free Software Foundation; either version 2.1 of the
- *  License, or (at your option) any later version.
- *
- *  gst-pulse is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with gst-pulse; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
- *  USA.
- */
-
-/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
- * with newer GLib versions (>= 2.31.0) */
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gst/audio/audio.h>
-
-#include "pulseprobe.h"
-#include "pulseutil.h"
-
-GST_DEBUG_CATEGORY_EXTERN (pulse_debug);
-#define GST_CAT_DEFAULT pulse_debug
-
-static void
-gst_pulseprobe_context_state_cb (pa_context * context, void *userdata)
-{
-  GstPulseProbe *c = (GstPulseProbe *) userdata;
-
-  /* Called from the background thread! */
-
-  switch (pa_context_get_state (context)) {
-    case PA_CONTEXT_READY:
-    case PA_CONTEXT_TERMINATED:
-    case PA_CONTEXT_FAILED:
-      pa_threaded_mainloop_signal (c->mainloop, 0);
-      break;
-
-    case PA_CONTEXT_UNCONNECTED:
-    case PA_CONTEXT_CONNECTING:
-    case PA_CONTEXT_AUTHORIZING:
-    case PA_CONTEXT_SETTING_NAME:
-      break;
-  }
-}
-
-static void
-gst_pulseprobe_sink_info_cb (pa_context * context, const pa_sink_info * i,
-    int eol, void *userdata)
-{
-  GstPulseProbe *c = (GstPulseProbe *) userdata;
-
-  /* Called from the background thread! */
-
-  if (eol || !i) {
-    c->operation_success = eol > 0;
-    pa_threaded_mainloop_signal (c->mainloop, 0);
-  }
-
-  if (i)
-    c->devices = g_list_append (c->devices, g_strdup (i->name));
-
-}
-
-static void
-gst_pulseprobe_source_info_cb (pa_context * context, const pa_source_info * i,
-    int eol, void *userdata)
-{
-  GstPulseProbe *c = (GstPulseProbe *) userdata;
-
-  /* Called from the background thread! */
-
-  if (eol || !i) {
-    c->operation_success = eol > 0;
-    pa_threaded_mainloop_signal (c->mainloop, 0);
-  }
-
-  if (i)
-    c->devices = g_list_append (c->devices, g_strdup (i->name));
-}
-
-static void
-gst_pulseprobe_invalidate (GstPulseProbe * c)
-{
-  g_list_foreach (c->devices, (GFunc) g_free, NULL);
-  g_list_free (c->devices);
-  c->devices = NULL;
-  c->devices_valid = FALSE;
-}
-
-static gboolean
-gst_pulseprobe_open (GstPulseProbe * c)
-{
-  int e;
-  gchar *name;
-
-  g_assert (c);
-
-  GST_DEBUG_OBJECT (c->object, "probe open");
-
-  c->mainloop = pa_threaded_mainloop_new ();
-  if (!c->mainloop)
-    return FALSE;
-
-  e = pa_threaded_mainloop_start (c->mainloop);
-  if (e < 0)
-    return FALSE;
-
-  name = gst_pulse_client_name ();
-
-  pa_threaded_mainloop_lock (c->mainloop);
-
-  if (!(c->context =
-          pa_context_new (pa_threaded_mainloop_get_api (c->mainloop), name))) {
-    GST_WARNING_OBJECT (c->object, "Failed to create context");
-    goto unlock_and_fail;
-  }
-
-  pa_context_set_state_callback (c->context, gst_pulseprobe_context_state_cb,
-      c);
-
-  if (pa_context_connect (c->context, c->server, 0, NULL) < 0) {
-    GST_WARNING_OBJECT (c->object, "Failed to connect context: %s",
-        pa_strerror (pa_context_errno (c->context)));
-    goto unlock_and_fail;
-  }
-
-  for (;;) {
-    pa_context_state_t state;
-
-    state = pa_context_get_state (c->context);
-
-    if (!PA_CONTEXT_IS_GOOD (state)) {
-      GST_WARNING_OBJECT (c->object, "Failed to connect context: %s",
-          pa_strerror (pa_context_errno (c->context)));
-      goto unlock_and_fail;
-    }
-
-    if (state == PA_CONTEXT_READY)
-      break;
-
-    /* Wait until the context is ready */
-    pa_threaded_mainloop_wait (c->mainloop);
-  }
-
-  pa_threaded_mainloop_unlock (c->mainloop);
-  g_free (name);
-
-  gst_pulseprobe_invalidate (c);
-
-  return TRUE;
-
-unlock_and_fail:
-
-  if (c->mainloop)
-    pa_threaded_mainloop_unlock (c->mainloop);
-
-  g_free (name);
-
-  return FALSE;
-}
-
-static gboolean
-gst_pulseprobe_is_dead (GstPulseProbe * pulseprobe)
-{
-
-  if (!pulseprobe->context ||
-      !PA_CONTEXT_IS_GOOD (pa_context_get_state (pulseprobe->context))) {
-    const gchar *err_str =
-        pulseprobe->context ?
-        pa_strerror (pa_context_errno (pulseprobe->context)) : NULL;
-
-    GST_ELEMENT_ERROR ((pulseprobe), RESOURCE, FAILED,
-        ("Disconnected: %s", err_str), (NULL));
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
-static gboolean
-gst_pulseprobe_enumerate (GstPulseProbe * c)
-{
-  pa_operation *o = NULL;
-
-  GST_DEBUG_OBJECT (c->object, "probe enumerate");
-
-  pa_threaded_mainloop_lock (c->mainloop);
-
-  if (c->enumerate_sinks) {
-    /* Get sink info */
-
-    if (!(o =
-            pa_context_get_sink_info_list (c->context,
-                gst_pulseprobe_sink_info_cb, c))) {
-      GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s",
-          pa_strerror (pa_context_errno (c->context)));
-      goto unlock_and_fail;
-    }
-
-    c->operation_success = FALSE;
-
-    while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
-
-      if (gst_pulseprobe_is_dead (c))
-        goto unlock_and_fail;
-
-      pa_threaded_mainloop_wait (c->mainloop);
-    }
-
-    if (!c->operation_success) {
-      GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s",
-          pa_strerror (pa_context_errno (c->context)));
-      goto unlock_and_fail;
-    }
-
-    pa_operation_unref (o);
-    o = NULL;
-  }
-
-  if (c->enumerate_sources) {
-    /* Get source info */
-
-    if (!(o =
-            pa_context_get_source_info_list (c->context,
-                gst_pulseprobe_source_info_cb, c))) {
-      GST_WARNING_OBJECT (c->object, "Failed to get source info: %s",
-          pa_strerror (pa_context_errno (c->context)));
-      goto unlock_and_fail;
-    }
-
-    c->operation_success = FALSE;
-    while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
-
-      if (gst_pulseprobe_is_dead (c))
-        goto unlock_and_fail;
-
-      pa_threaded_mainloop_wait (c->mainloop);
-    }
-
-    if (!c->operation_success) {
-      GST_WARNING_OBJECT (c->object, "Failed to get sink info: %s",
-          pa_strerror (pa_context_errno (c->context)));
-      goto unlock_and_fail;
-    }
-
-    pa_operation_unref (o);
-    o = NULL;
-  }
-
-  c->devices_valid = TRUE;
-
-  pa_threaded_mainloop_unlock (c->mainloop);
-
-  return TRUE;
-
-unlock_and_fail:
-
-  if (o)
-    pa_operation_unref (o);
-
-  pa_threaded_mainloop_unlock (c->mainloop);
-
-  return FALSE;
-}
-
-static void
-gst_pulseprobe_close (GstPulseProbe * c)
-{
-  g_assert (c);
-
-  GST_DEBUG_OBJECT (c->object, "probe close");
-
-  if (c->mainloop)
-    pa_threaded_mainloop_stop (c->mainloop);
-
-  if (c->context) {
-    pa_context_disconnect (c->context);
-    pa_context_set_state_callback (c->context, NULL, NULL);
-    pa_context_unref (c->context);
-    c->context = NULL;
-  }
-
-  if (c->mainloop) {
-    pa_threaded_mainloop_free (c->mainloop);
-    c->mainloop = NULL;
-  }
-}
-
-GstPulseProbe *
-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 = object;           /* We don't inc the ref counter here to avoid a ref loop */
-  c->server = g_strdup (server);
-  c->enumerate_sinks = sinks;
-  c->enumerate_sources = sources;
-
-  c->mainloop = NULL;
-  c->context = NULL;
-
-  c->prop_id = prop_id;
-  c->properties =
-      g_list_append (NULL, g_object_class_find_property (klass, "device"));
-
-  c->devices = NULL;
-  c->devices_valid = FALSE;
-
-  c->operation_success = FALSE;
-
-  return c;
-}
-
-void
-gst_pulseprobe_free (GstPulseProbe * c)
-{
-  g_assert (c);
-
-  gst_pulseprobe_close (c);
-
-  g_list_free (c->properties);
-  g_free (c->server);
-
-  g_list_foreach (c->devices, (GFunc) g_free, NULL);
-  g_list_free (c->devices);
-
-  g_free (c);
-}
-
-const GList *
-gst_pulseprobe_get_properties (GstPulseProbe * c)
-{
-  return c->properties;
-}
-
-gboolean
-gst_pulseprobe_needs_probe (GstPulseProbe * c, guint prop_id,
-    const GParamSpec * pspec)
-{
-
-  if (prop_id == c->prop_id)
-    return !c->devices_valid;
-
-  G_OBJECT_WARN_INVALID_PROPERTY_ID (c->object, prop_id, pspec);
-  return FALSE;
-}
-
-void
-gst_pulseprobe_probe_property (GstPulseProbe * c, guint prop_id,
-    const GParamSpec * pspec)
-{
-
-  if (prop_id != c->prop_id) {
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (c->object, prop_id, pspec);
-    return;
-  }
-
-  if (gst_pulseprobe_open (c)) {
-    gst_pulseprobe_enumerate (c);
-    gst_pulseprobe_close (c);
-  }
-}
-
-#if 0
-GValueArray *
-gst_pulseprobe_get_values (GstPulseProbe * c, guint prop_id,
-    const GParamSpec * pspec)
-{
-  GValueArray *array;
-  GValue value = {
-    0
-  };
-  GList *item;
-
-  if (prop_id != c->prop_id) {
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (c->object, prop_id, pspec);
-    return NULL;
-  }
-
-  if (!c->devices_valid)
-    return NULL;
-
-  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_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);
-  }
-  g_value_unset (&value);
-
-  return array;
-}
-#endif
-
-void
-gst_pulseprobe_set_server (GstPulseProbe * c, const gchar * server)
-{
-  g_assert (c);
-
-  gst_pulseprobe_invalidate (c);
-
-  g_free (c->server);
-  c->server = g_strdup (server);
-}
diff --git a/ext/pulse/pulseprobe.h b/ext/pulse/pulseprobe.h
deleted file mode 100644 (file)
index 6e9b236..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 2 -*-*/
-
-/*
- *  GStreamer pulseaudio plugin
- *
- *  Copyright (c) 2004-2008 Lennart Poettering
- *
- *  gst-pulse is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU Lesser General Public License as
- *  published by the Free Software Foundation; either version 2.1 of the
- *  License, or (at your option) any later version.
- *
- *  gst-pulse is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with gst-pulse; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
- *  USA.
- */
-
-#ifndef __GST_PULSEPROBE_H__
-#define __GST_PULSEPROBE_H__
-
-#include <gst/gst.h>
-
-G_BEGIN_DECLS
-
-#include <pulse/pulseaudio.h>
-#include <pulse/thread-mainloop.h>
-
-typedef struct _GstPulseProbe GstPulseProbe;
-
-struct _GstPulseProbe
-{
-  GObject *object;
-  gchar *server;
-
-  GList *devices;
-  gboolean devices_valid:1;
-
-  gboolean operation_success:1;
-
-  gboolean enumerate_sinks:1;
-  gboolean enumerate_sources:1;
-
-  pa_threaded_mainloop *mainloop;
-  pa_context *context;
-
-  GList *properties;
-  guint prop_id;
-};
-
-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);
-
-gboolean gst_pulseprobe_needs_probe (GstPulseProbe * probe, guint prop_id,
-    const GParamSpec * pspec);
-void gst_pulseprobe_probe_property (GstPulseProbe * probe, guint prop_id,
-    const GParamSpec * pspec);
-#if 0
-GValueArray *gst_pulseprobe_get_values (GstPulseProbe * probe, guint prop_id,
-    const GParamSpec * pspec);
-#endif
-
-void gst_pulseprobe_set_server (GstPulseProbe * c, const gchar * server);
-
-#define GST_IMPLEMENT_PULSEPROBE_METHODS(Type, interface_as_function)           \
-static const GList*                                                             \
-interface_as_function ## _get_properties(GstPropertyProbe * probe)              \
-{                                                                               \
-  Type *this = (Type*) probe;                                                   \
-                                                                                \
-  g_return_val_if_fail(this != NULL, NULL);                                     \
-  g_return_val_if_fail(this->probe != NULL, NULL);                              \
-                                                                                \
-  return gst_pulseprobe_get_properties(this->probe);                            \
-}                                                                               \
-static gboolean                                                                 \
-interface_as_function ## _needs_probe(GstPropertyProbe *probe, guint prop_id,   \
-    const GParamSpec *pspec)                                                    \
-{                                                                               \
-  Type *this = (Type*) probe;                                                   \
-                                                                                \
-  g_return_val_if_fail(this != NULL, FALSE);                                    \
-  g_return_val_if_fail(this->probe != NULL, FALSE);                             \
-                                                                                \
-  return gst_pulseprobe_needs_probe(this->probe, prop_id, pspec);               \
-}                                                                               \
-static void                                                                     \
-interface_as_function ## _probe_property(GstPropertyProbe *probe,               \
-    guint prop_id, const GParamSpec *pspec)                                     \
-{                                                                               \
-  Type *this = (Type*) probe;                                                   \
-                                                                                \
-  g_return_if_fail(this != NULL);                                               \
-  g_return_if_fail(this->probe != NULL);                                        \
-                                                                                \
-  gst_pulseprobe_probe_property(this->probe, prop_id, pspec);                   \
-}                                                                               \
-static GValueArray*                                                             \
-interface_as_function ## _get_values(GstPropertyProbe *probe, guint prop_id,    \
-    const GParamSpec *pspec)                                                    \
-{                                                                               \
-  Type *this = (Type*) probe;                                                   \
-                                                                                \
-  g_return_val_if_fail(this != NULL, NULL);                                     \
-  g_return_val_if_fail(this->probe != NULL, NULL);                              \
-                                                                                \
-  return gst_pulseprobe_get_values(this->probe, prop_id, pspec);                \
-}                                                                               \
-static void                                                                     \
-interface_as_function ## _property_probe_interface_init(GstPropertyProbeInterface *iface)\
-{                                                                               \
-  iface->get_properties = interface_as_function ## _get_properties;             \
-  iface->needs_probe = interface_as_function ## _needs_probe;                   \
-  iface->probe_property = interface_as_function ## _probe_property;             \
-  iface->get_values = interface_as_function ## _get_values;                     \
-}
-
-G_END_DECLS
-
-#endif
index cd257d6..330697a 100644 (file)
@@ -2435,11 +2435,6 @@ gst_pulsesink_init (GstPulseSink * pulsesink)
   GST_AUDIO_BASE_SINK (pulsesink)->provided_clock =
       gst_audio_clock_new ("GstPulseSinkClock",
       (GstAudioClockGetTimeFunc) gst_pulsesink_get_time, pulsesink, NULL);
-
-  /* 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);
 }
 
 static void
@@ -2458,11 +2453,6 @@ gst_pulsesink_finalize (GObject * object)
   if (pulsesink->proplist)
     pa_proplist_free (pulsesink->proplist);
 
-  if (pulsesink->probe) {
-    gst_pulseprobe_free (pulsesink->probe);
-    pulsesink->probe = NULL;
-  }
-
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -2835,8 +2825,6 @@ gst_pulsesink_set_property (GObject * object,
     case PROP_SERVER:
       g_free (pulsesink->server);
       pulsesink->server = g_value_dup_string (value);
-      if (pulsesink->probe)
-        gst_pulseprobe_set_server (pulsesink->probe, pulsesink->server);
       break;
     case PROP_DEVICE:
       g_free (pulsesink->device);
index 26e9997..85f5f7f 100644 (file)
@@ -35,7 +35,7 @@
 #include <pulse/pulseaudio.h>
 #include <pulse/thread-mainloop.h>
 
-#include "pulseprobe.h"
+#include "pulseutil.h"
 
 G_BEGIN_DECLS
 
@@ -67,8 +67,6 @@ struct _GstPulseSink
   gchar *server, *device, *stream_name, *client_name;
   GstPulseDeviceInfo device_info;
 
-  GstPulseProbe *probe;
-
   gdouble volume;
   gboolean volume_set:1;
   gboolean mute:1;
index 02f6488..495f0c0 100644 (file)
@@ -290,8 +290,6 @@ gst_pulsesrc_init (GstPulseSrc * pulsesrc)
   pulsesrc->properties = NULL;
   pulsesrc->proplist = NULL;
 
-  pulsesrc->probe = gst_pulseprobe_new (G_OBJECT (pulsesrc), G_OBJECT_GET_CLASS (pulsesrc), PROP_DEVICE, pulsesrc->server, FALSE, TRUE);        /* FALSE for sinks, TRUE for sources */
-
   /* this should be the default but it isn't yet */
   gst_audio_base_src_set_slave_method (GST_AUDIO_BASE_SRC (pulsesrc),
       GST_AUDIO_BASE_SRC_SLAVE_SKEW);
@@ -354,11 +352,6 @@ gst_pulsesrc_finalize (GObject * object)
   if (pulsesrc->proplist)
     pa_proplist_free (pulsesrc->proplist);
 
-  if (pulsesrc->probe) {
-    gst_pulseprobe_free (pulsesrc->probe);
-    pulsesrc->probe = NULL;
-  }
-
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -714,8 +707,6 @@ gst_pulsesrc_set_property (GObject * object,
     case PROP_SERVER:
       g_free (pulsesrc->server);
       pulsesrc->server = g_value_dup_string (value);
-      if (pulsesrc->probe)
-        gst_pulseprobe_set_server (pulsesrc->probe, pulsesrc->server);
       break;
     case PROP_DEVICE:
       g_free (pulsesrc->device);
index dcae8b1..967fc41 100644 (file)
@@ -30,8 +30,6 @@
 #include <pulse/pulseaudio.h>
 #include <pulse/thread-mainloop.h>
 
-#include "pulseprobe.h"
-
 G_BEGIN_DECLS
 
 #define GST_TYPE_PULSESRC \
@@ -68,7 +66,6 @@ struct _GstPulseSrc
   size_t read_buffer_length;
 
   gchar *device_description;
-  GstPulseProbe *probe;
 
   gdouble volume;
   gboolean volume_set:1;