[totem] Don't special-case pulseaudio and clean up the volume handling



commit 0c11f1ba21a48bd154988ce2620f03b89fa4d2f9
Author: Sebastian Dröge <sebastian droege collabora co uk>
Date:   Fri Oct 30 09:48:04 2009 +0100

    Don't special-case pulseaudio and clean up the volume handling
    
    totem now won't use pulsesink by default if it's available but will
    simply use gconfaudiosink, like it did in 2.28.0 and earlier.
    Fixes bug #596164.
    
    For this to work properly, the following GStreamer changesets are necessary
    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=de1db5ccbdc10a835a2dfdd5984892f3b0c9bcf4
    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=d85dadc122d40608ee304516702b479fb79c8ed7
    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=598c9376342b4f67012d1d418c090f432fc26d27
    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=e72c3029c0e4674e3ce6d9770dc9de665e7a3793
    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=e4d6a2aa2c6b8b3d9137a38e10d28434eb31a580
    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=3f541452c4916b31a222043b172b3398647b8091
    
    To give the best user experience with pulseaudio, pulseaudio >= 0.9.20
    is required because of this changeset:
    http://git.0pointer.de/?p=pulseaudio.git;a=commit;h=f27a50691c8fe45bac7dd6b21fac91a359def3a1

 configure.in                              |    2 +-
 src/backend/bacon-video-widget-gst-0.10.c |   75 +++++++----------------------
 2 files changed, 18 insertions(+), 59 deletions(-)
---
diff --git a/configure.in b/configure.in
index 623f7fa..f44645a 100644
--- a/configure.in
+++ b/configure.in
@@ -60,7 +60,7 @@ dnl the two versions here implicate the gstreamer core and gst-plugins
 dnl release versions.
 GST_MAJORMINOR=0.10
 GST_REQS=0.10.24
-GSTPLUG_REQS=0.10.25
+GSTPLUG_REQS=0.10.25.1
 
 HAVE_GSTREAMER=no
 
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 21c7b0b..4e11c9f 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -199,7 +199,6 @@ struct BaconVideoWidgetPrivate
   gboolean                     fullscreen_mode;
   gboolean                     auto_resize;
   gboolean                     uses_audio_fakesink;
-  GstElement                  *pulse_audio_sink;
   gdouble                      volume;
   gboolean                     is_menu;
   
@@ -2312,11 +2311,6 @@ bacon_video_widget_finalize (GObject * object)
   g_free (bvw->priv->vis_element_name);
   bvw->priv->vis_element_name = NULL;
 
-  if (bvw->priv->pulse_audio_sink) {
-    g_object_unref (bvw->priv->pulse_audio_sink);
-    bvw->priv->pulse_audio_sink = NULL;
-  }
-
   if (bvw->priv->vis_plugins_list) {
     g_list_free (bvw->priv->vis_plugins_list);
     bvw->priv->vis_plugins_list = NULL;
@@ -4039,33 +4033,11 @@ bacon_video_widget_set_volume (BaconVideoWidget * bvw, double volume)
   g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
   g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
 
-  if (bvw->priv->volume < 0.0 && bvw->priv->pulse_audio_sink != NULL) {
-    bvw->priv->volume = volume;
-    return;
-  }
-
-  if (bacon_video_widget_can_set_volume (bvw) != FALSE)
-  {
+  if (bacon_video_widget_can_set_volume (bvw) != FALSE) {
     volume = CLAMP (volume, 0.0, 1.0);
-    if (bvw->priv->pulse_audio_sink) {
-      GstState cur_state;
-
-      gst_element_get_state (bvw->priv->pulse_audio_sink, &cur_state, NULL, 0);
-      if (cur_state == GST_STATE_READY || cur_state == GST_STATE_PLAYING)
-      {
-	if (gst_element_implements_interface (bvw->priv->pulse_audio_sink,
-					      GST_TYPE_STREAM_VOLUME)) {
-	  gst_stream_volume_set_volume (GST_STREAM_VOLUME (bvw->priv->pulse_audio_sink),
-					GST_STREAM_VOLUME_FORMAT_CUBIC,
-					volume);
-	} else {
-	  g_object_set (bvw->priv->pulse_audio_sink, "volume", volume, NULL);
-	}
-      }
-    } else {
-      g_object_set (bvw->priv->play, "volume",
-		    (gdouble) volume, NULL);
-    }
+    gst_stream_volume_set_volume (GST_STREAM_VOLUME (bvw->priv->play),
+                                  GST_STREAM_VOLUME_FORMAT_CUBIC,
+                                  volume);
 
     bvw->priv->volume = volume;
     g_object_notify (G_OBJECT (bvw), "volume");
@@ -4791,13 +4763,9 @@ notify_volume_idle_cb (BaconVideoWidget *bvw)
 {
   gdouble vol;
 
-  if (gst_element_implements_interface (bvw->priv->pulse_audio_sink,
-					GST_TYPE_STREAM_VOLUME)) {
-    vol = gst_stream_volume_get_volume (GST_STREAM_VOLUME (bvw->priv->pulse_audio_sink),
-					GST_STREAM_VOLUME_FORMAT_CUBIC);
-  } else {
-    g_object_get (G_OBJECT (bvw->priv->pulse_audio_sink), "volume", &vol, NULL);
-  }
+  vol = gst_stream_volume_get_volume (GST_STREAM_VOLUME (bvw->priv->play),
+                                      GST_STREAM_VOLUME_FORMAT_CUBIC);
+
   bvw->priv->volume = vol;
 
   g_object_notify (G_OBJECT (bvw), "volume");
@@ -6368,18 +6336,15 @@ bacon_video_widget_new (int width, int height,
       cb_gconf, bvw, NULL, NULL);
 
   if (type == BVW_USE_TYPE_VIDEO || type == BVW_USE_TYPE_AUDIO) {
-    audio_sink = gst_element_factory_make ("pulsesink", "audio-sink");
+    audio_sink = gst_element_factory_make ("gconfaudiosink", "audio-sink");
     if (audio_sink == NULL) {
-      audio_sink = gst_element_factory_make ("gconfaudiosink", "audio-sink");
-      if (audio_sink == NULL) {
-	g_warning ("Could not create element 'gconfaudiosink'");
-	/* Try to fallback on autoaudiosink */
-	audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink");
-      } else {
-	/* set the profile property on the gconfaudiosink to "music and movies" */
-	if (g_object_class_find_property (G_OBJECT_GET_CLASS (audio_sink), "profile"))
-	  g_object_set (G_OBJECT (audio_sink), "profile", 1, NULL);
-      }
+      g_warning ("Could not create element 'gconfaudiosink'");
+      /* Try to fallback on autoaudiosink */
+      audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink");
+    } else {
+      /* set the profile property on the gconfaudiosink to "music and movies" */
+      if (g_object_class_find_property (G_OBJECT_GET_CLASS (audio_sink), "profile"))
+        g_object_set (G_OBJECT (audio_sink), "profile", 1, NULL);
     }
   } else {
     audio_sink = gst_element_factory_make ("fakesink", "audio-fake-sink");
@@ -6529,14 +6494,6 @@ bacon_video_widget_new (int width, int height,
       bvw->priv->uses_audio_fakesink = TRUE;
     }
     gst_object_unref (bus);
-
-    /* If we're using a sink that has a volume property, then that's what
-     * we need to modify, not playbin's one */
-    if (g_object_class_find_property (G_OBJECT_GET_CLASS (audio_sink), "volume")) {
-      bvw->priv->pulse_audio_sink = g_object_ref (audio_sink);
-      g_signal_connect (G_OBJECT (bvw->priv->pulse_audio_sink), "notify::volume",
-			G_CALLBACK (notify_volume_cb), bvw);
-    }
   } else {
     g_set_error_literal (error, BVW_ERROR, BVW_ERROR_AUDIO_PLUGIN,
                  _("Could not find the audio output. "
@@ -6575,6 +6532,8 @@ bacon_video_widget_new (int width, int height,
 
   bvw->priv->vis_plugins_list = NULL;
 
+  g_signal_connect (G_OBJECT (bvw->priv->play), "notify::volume",
+      G_CALLBACK (notify_volume_cb), bvw);
   g_signal_connect (bvw->priv->play, "notify::source",
       G_CALLBACK (playbin_source_notify_cb), bvw);
   g_signal_connect (bvw->priv->play, "video-changed",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]