- Add patch to set the PA stream volume from Totem, instead of having a

separate one
This commit is contained in:
Bastien Nocera 2009-02-12 15:57:59 +00:00
parent 95ee26a956
commit 402f2df7cf
2 changed files with 141 additions and 0 deletions

View File

@ -0,0 +1,134 @@
Index: src/backend/bacon-video-widget-gst-0.10.c
===================================================================
--- src/backend/bacon-video-widget-gst-0.10.c (revision 5970)
+++ src/backend/bacon-video-widget-gst-0.10.c (working copy)
@@ -166,7 +166,8 @@
gboolean cursor_shown;
gboolean fullscreen_mode;
gboolean auto_resize;
- gboolean uses_fakesink;
+ gboolean uses_audio_fakesink;
+ GstElement *pulse_audio_sink;
gint video_width; /* Movie width */
gint video_height; /* Movie height */
@@ -1892,6 +1893,11 @@
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;
@@ -3145,7 +3151,7 @@
if (bvw->priv->speakersetup == BVW_AUDIO_SOUND_AC3PASSTHRU)
return FALSE;
- return !bvw->priv->uses_fakesink;
+ return !bvw->priv->uses_audio_fakesink;
}
void
@@ -3157,8 +3163,13 @@
if (bacon_video_widget_can_set_volume (bvw) != FALSE)
{
volume = CLAMP (volume, 0.0, 1.0);
- g_object_set (bvw->priv->play, "volume",
- (gdouble) volume, NULL);
+ if (bvw->priv->pulse_audio_sink) {
+ g_object_set (bvw->priv->pulse_audio_sink, "volume",
+ (gdouble) volume, NULL);
+ } else {
+ g_object_set (bvw->priv->play, "volume",
+ (gdouble) volume, NULL);
+ }
g_object_notify (G_OBJECT (bvw), "volume");
}
}
@@ -3171,7 +3182,11 @@
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), 0.0);
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), 0.0);
- g_object_get (G_OBJECT (bvw->priv->play), "volume", &vol, NULL);
+ if (bvw->priv->pulse_audio_sink) {
+ g_object_get (G_OBJECT (bvw->priv->pulse_audio_sink), "volume", &vol, NULL);
+ } else {
+ g_object_get (G_OBJECT (bvw->priv->play), "volume", &vol, NULL);
+ }
return vol;
}
@@ -4947,6 +4962,21 @@
g_mutex_unlock (bvw->priv->lock);
}
+static gboolean
+notify_volume_idle_cb (BaconVideoWidget *bvw)
+{
+ g_object_notify (G_OBJECT (bvw), "volume");
+ return FALSE;
+}
+
+static void
+notify_volume_cb (GObject *object,
+ GParamSpec *pspec,
+ BaconVideoWidget *bvw)
+{
+ g_idle_add (notify_volume_idle_cb, bvw);
+}
+
GtkWidget *
bacon_video_widget_new (int width, int height,
BvwUseType type, GError ** err)
@@ -5014,15 +5044,18 @@
cb_gconf, bvw, NULL, NULL);
if (type == BVW_USE_TYPE_VIDEO || type == BVW_USE_TYPE_AUDIO) {
- audio_sink = gst_element_factory_make ("gconfaudiosink", "audio-sink");
+ audio_sink = gst_element_factory_make ("pulsesink", "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);
+ 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);
+ }
}
} else {
audio_sink = gst_element_factory_make ("fakesink", "audio-fake-sink");
@@ -5171,9 +5204,19 @@
/* make fakesink sync to the clock like a real sink */
g_object_set (audio_sink, "sync", TRUE, NULL);
GST_DEBUG ("audio sink doesn't work, using fakesink instead");
- bvw->priv->uses_fakesink = TRUE;
+ 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_object_set (bvw->priv->play, "volume",
+ (gdouble) 1.0, NULL);
+ g_signal_connect (G_OBJECT (bvw->priv->pulse_audio_sink), "notify::volume",
+ G_CALLBACK (notify_volume_cb), bvw);
+ }
} else {
g_set_error_literal (err, BVW_ERROR, BVW_ERROR_AUDIO_PLUGIN,
_("Could not find the audio output. "

View File

@ -15,6 +15,8 @@ Group: Applications/Multimedia
URL: http://projects.gnome.org/totem/
Source0: http://download.gnome.org/sources/totem/2.24/totem-%{version}.tar.bz2
Source1: totem-bin-backend-ondemand.sh
# Will be removed when we switch to playbin2
Patch0: totem-use-pulsesink-volume.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires(pre): GConf2 >= 2.14
@ -204,6 +206,7 @@ audio and video files in the properties dialog.
%prep
%setup -q -c
%patch0 -p0 -b .pulsesink-vol
# Whatever needs to be changed in both copies do here
## remember to update me when changing %doc
for i in AUTHORS COPYING NEWS README TODO;do
@ -476,6 +479,10 @@ fi
%endif
%changelog
* Thu Feb 12 2009 - Bastien Nocera <bnocera@redhat.com> - 2.25.90-3
- Add patch to set the PA stream volume from Totem, instead
of having a separate one
* Wed Feb 04 2009 - Peter Robinson <pbrobinson@gmail.com> - 2.25.90-2
- Fix logic in spec file for xine disable