]> git.0d.be Git - empathy.git/blobdiff - src/empathy-audio-sink.c
Use a flat namespace for internal includes
[empathy.git] / src / empathy-audio-sink.c
index 5ab14b541a636a8d7c0619fe08d6f64d3446f38c..0147b870679d56645be19566e0391440724cd399 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include "config.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <gst/audio/audio.h>
+#ifdef HAVE_GST1
+#include <gst/audio/streamvolume.h>
+#else
 #include <gst/interfaces/streamvolume.h>
+#endif
 
-#include <telepathy-glib/telepathy-glib.h>
-
-#include <libempathy-gtk/empathy-call-utils.h>
-
+#include "empathy-audio-utils.h"
 #include "empathy-audio-sink.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_VOIP
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
 
 G_DEFINE_TYPE(EmpathyGstAudioSink, empathy_audio_sink, GST_TYPE_BIN)
 
@@ -50,8 +48,12 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE(
     "sink%d",
     GST_PAD_SINK,
     GST_PAD_REQUEST,
+#ifdef HAVE_GST1
+    GST_STATIC_CAPS ( "audio/x-raw" )
+#else
     GST_STATIC_CAPS ( GST_AUDIO_INT_PAD_TEMPLATE_CAPS " ; "
         GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS)
+#endif
 );
 
 enum {
@@ -64,7 +66,7 @@ struct _EmpathyGstAudioSinkPrivate
   gboolean echo_cancel;
   gdouble volume;
   gint volume_idle_id;
-  GStaticMutex volume_mutex;
+  GMutex volume_mutex;
 };
 
 #define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \
@@ -76,12 +78,19 @@ empathy_audio_sink_init (EmpathyGstAudioSink *self)
 {
   self->priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self);
   self->priv->echo_cancel = TRUE;
-  g_static_mutex_init (&self->priv->volume_mutex);
+  g_mutex_init (&self->priv->volume_mutex);
 }
 
+#ifdef HAVE_GST1
+static GstPad * empathy_audio_sink_request_new_pad (GstElement *self,
+  GstPadTemplate *templ,
+  const gchar* name,
+  const GstCaps *caps);
+#else
 static GstPad * empathy_audio_sink_request_new_pad (GstElement *self,
   GstPadTemplate *templ,
   const gchar* name);
+#endif
 
 static void empathy_audio_sink_release_pad (GstElement *self,
   GstPad *pad);
@@ -94,9 +103,9 @@ empathy_audio_sink_set_property (GObject *object,
   switch (property_id)
     {
       case PROP_VOLUME:
-        g_static_mutex_lock (&self->priv->volume_mutex);
+        g_mutex_lock (&self->priv->volume_mutex);
         self->priv->volume = g_value_get_double (value);
-        g_static_mutex_unlock (&self->priv->volume_mutex);
+        g_mutex_unlock (&self->priv->volume_mutex);
         break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -128,7 +137,7 @@ empathy_audio_sink_dispose (GObject *object)
     g_source_remove (priv->volume_idle_id);
   priv->volume_idle_id = 0;
 
-  g_static_mutex_free (&self->priv->volume_mutex);
+  g_mutex_clear (&self->priv->volume_mutex);
 
   /* release any references held by the object here */
   if (G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose)
@@ -218,11 +227,14 @@ create_sink (EmpathyGstAudioSink *self)
   if (sink == NULL)
     return NULL;
 
-  empathy_call_set_stream_properties (sink, self->priv->echo_cancel);
+  empathy_audio_set_stream_properties (sink, self->priv->echo_cancel);
 
   /* Set latency (buffering on the PulseAudio side) of 40ms and transfer data
    * in 10ms chunks */
-  g_object_set (sink, "buffer-time", 40000, "latency-time", 10000, NULL);
+  g_object_set (sink,
+      "buffer-time", (gint64) 40000,
+      "latency-time", (gint64) 10000,
+      NULL);
 
   return sink;
 }
@@ -232,9 +244,9 @@ empathy_audio_sink_volume_idle_updated (gpointer user_data)
 {
   EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (user_data);
 
-  g_static_mutex_lock (&self->priv->volume_mutex);
+  g_mutex_lock (&self->priv->volume_mutex);
   self->priv->volume_idle_id = 0;
-  g_static_mutex_unlock (&self->priv->volume_mutex);
+  g_mutex_unlock (&self->priv->volume_mutex);
 
   g_object_notify (G_OBJECT (self), "volume");
 
@@ -249,7 +261,7 @@ empathy_audio_sink_volume_updated (GObject *object,
   EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (user_data);
   gdouble volume;
 
-  g_static_mutex_lock (&self->priv->volume_mutex);
+  g_mutex_lock (&self->priv->volume_mutex);
 
   g_object_get (object, "volume", &volume, NULL);
   if (self->priv->volume == volume)
@@ -261,7 +273,7 @@ empathy_audio_sink_volume_updated (GObject *object,
       empathy_audio_sink_volume_idle_updated, self);
 
 out:
-  g_static_mutex_unlock (&self->priv->volume_mutex);
+  g_mutex_unlock (&self->priv->volume_mutex);
 }
 
 static gboolean
@@ -270,9 +282,9 @@ empathy_audio_sink_volume_idle_setup (gpointer user_data)
   EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (user_data);
   gdouble volume;
 
-  g_static_mutex_lock (&self->priv->volume_mutex);
+  g_mutex_lock (&self->priv->volume_mutex);
   self->priv->volume_idle_id = 0;
-  g_static_mutex_unlock (&self->priv->volume_mutex);
+  g_mutex_unlock (&self->priv->volume_mutex);
 
   /* We can't do a bidirection bind as the ::notify comes from another
    * thread, for other bits of empathy it's most simpler if it comes from
@@ -289,10 +301,18 @@ empathy_audio_sink_volume_idle_setup (gpointer user_data)
   return FALSE;
 }
 
+#ifdef HAVE_GST1
+static GstPad *
+empathy_audio_sink_request_new_pad (GstElement *element,
+  GstPadTemplate *templ,
+  const gchar* name,
+  const GstCaps *caps)
+#else
 static GstPad *
 empathy_audio_sink_request_new_pad (GstElement *element,
   GstPadTemplate *templ,
   const gchar* name)
+#endif
 {
   EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (element);
   GstElement *bin, *resample, *audioconvert0, *audioconvert1;
@@ -325,11 +345,11 @@ empathy_audio_sink_request_new_pad (GstElement *element,
 
   if (GST_IS_STREAM_VOLUME (self->priv->sink))
     {
-      g_static_mutex_lock (&self->priv->volume_mutex);
+      g_mutex_lock (&self->priv->volume_mutex);
       if (self->priv->volume_idle_id == 0)
         self->priv->volume_idle_id = g_idle_add (
           empathy_audio_sink_volume_idle_setup, self);
-      g_static_mutex_unlock (&self->priv->volume_mutex);
+      g_mutex_unlock (&self->priv->volume_mutex);
     }
   else
     {
@@ -351,6 +371,8 @@ empathy_audio_sink_request_new_pad (GstElement *element,
     goto error;
 
   subpad = gst_ghost_pad_new ("sink", filterpad);
+  gst_object_unref (filterpad);
+
   if (!gst_element_add_pad (GST_ELEMENT (bin), subpad))
     goto error;
 
@@ -396,6 +418,6 @@ empathy_audio_sink_set_echo_cancel (EmpathyGstAudioSink *sink,
   DEBUG ("Sink echo cancellation setting: %s", echo_cancel ? "on" : "off");
   sink->priv->echo_cancel = echo_cancel;
   if (sink->priv->sink != NULL)
-    empathy_call_set_stream_properties (sink->priv->sink,
+    empathy_audio_set_stream_properties (sink->priv->sink,
       sink->priv->echo_cancel);
 }