[sugar] [PATCH] Fix startup sound playback.
Thu Nov 1 21:15:17 EDT 2007
The sugar startup sound playback broke sound in Joyride, because a
callback for closing the playback pipeline was not registered, and as a
result gstreamer kept the pipeline (and audio device) open for as long
as the process (sugar-shell) stayed running. I fixed this in two ways
that make sense to me, and one that doesn't:
* We now supply a callback for the "message::eos" signal, and change
the player state to NULL instead of PLAYING in it.
* I tried doing this with a lambda, but exposed another problem with the
current function -- Python pulls down variables as a function is
exited, and our playback function exited before the sound finished (or
started) playing. I stuck the player object into main as a property
so that it sticks around until it can close the pipeline.
* That still didn't fix it; any activities launched retained an open
pcm device. I tried calling _shell_started() directly, instead
of as a gobject_idle_add() callback, and this fixed it. I don't
understand why. The playback happens in roughly the same part
of the startup sequence as it originally did.
All three changes are necessary to get sound working again.
Please review and apply.
bin/sugar-shell | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/bin/sugar-shell b/bin/sugar-shell
index 8f78289..c439085 100755
@@ -82,20 +82,29 @@ def check_cm(bus_name):
+def _eos_cb(bus, message):
+def _error_cb(bus, message):
+ error = message.parse_error()
+ print error
# Unfreeze the display
hw_manager = hardwaremanager.get_manager()
startup_sound = os.path.join(env.get_data_path('startup.flac'))
- player = gst.element_factory_make("playbin", "player")
- player.set_property("uri", "file://" + startup_sound)
+ main.player = gst.element_factory_make("playbin", "player")
+ main.player.set_property("uri", "file://" + startup_sound)
+ bus = main.player.get_bus()
+ bus.connect("message::eos", _eos_cb)
+ bus.connect("message::error", _error_cb)
@@ -145,6 +154,7 @@ def main():
model = ShellModel()
shell = Shell(model)
service = ShellService(shell)
if __name__ == '__main__':
# running the gtk.main outside of the main() function allows us to
Chris Ball <cjb at laptop.org>
More information about the Sugar-devel