GNOME Bugzilla – Bug 614288
Setting playbin volume has no effect the second time around
Last modified: 2010-04-09 06:25:21 UTC
If the playbin is used to play many media files then the volume can only be adjusted when the first file is playing, for any subsequent files (that use the same playbin) it has no effect. Here is a quick example in python, replace references to '/home/tom/test.oga' with a media file on your system. #!/usr/bin/python import pygtk, gtk, gobject import pygst, gst def change_uri(): print "attempting to play again, but louder" pipeline.set_state(gst.STATE_NULL) pipeline.set_property("uri", "file:///home/tom/test.oga") pipeline.set_state(gst.STATE_PLAYING) pipeline.set_property("volume", 1.0) pipeline = gst.parse_launch('playbin uri=file:///home/tom/test.oga') pipeline.set_state(gst.STATE_PLAYING) pipeline.set_property("volume", 0.1) gobject.timeout_add(6000, change_uri) gtk.main() It should playback at a low volume (10%) and after 6 seconds the callback restarts playback and increases the volume (100%), but instead playback restarts with the lower volume. It is interesting to note that playbin2 works fine in the same example! I hope someone else can reproduce this problem, as far as I can tell I have all the latest core/plugin releases installed.
It's unlikely that anybody will fix this for playbin because using playbin2 is now recommended and it works there... as such I'll close this bug as WONTFIX unless you (or anybody else) wants to work on this for old playbin. Is there any reason why you don't want to use playbin2?
The main reason I still rely on old playbin in some cases is down to the lack of working DVB playback with playbin2, so it seemed like a good idea to still support playback with both. Anyway, I'll see if I can find where the regression was introduced and maybe I can understand what's going wrong.
A git bisect points at the following commit: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=e9d1819fe390e6c6d2d664387922e28003da470e It looks like unref'ing the volume element in remove_sinks is the cause of the behaviour I am seeing. This is because subsequent calls to gen_audio_element (e.g. for the next media file) don't re-create the volume element. gen_audio_element checks the cache for a "abin" (and returns it) and never gets as far as creating the volume element again.
Created attachment 158241 [details] [review] don't unref volume element in remove_sinks This simple patch only unref's the volume element when the playbin is disposed of or a new audio_sink is set on the playbin, after which gen_audio_element should re-create it.
commit 57b64c001a0a5c4e2008f61afb607c147e05a773 Author: Thomas Green <thomasgr33n@googlemail.com> Date: Fri Apr 9 08:23:33 2010 +0200 playbin: Only unref the volume element on dispose and when a new audio sink is set Unreffing it whenever the sinks are removed will make the volume element unavailable after a playbin reuse because it is only recreated if the audio sink has changed. Fixes bug #614288.