On 05/04/2012 11:34 PM, godi...@sugarlabs.org wrote:
From: Gonzalo Odiard<godi...@gmail.com>

In xo with alsa, if we keep opened the audio device after
doing tts, other activities can't use it.
We need close the device after the eof message is received,
because the message came a little before the sound has finished.

That sounds suspicious to me. I looked at the documentation [1][2] and they seem to wait for the 'gst.MESSAGE_EOS' message in order to release the device 'set_state(gst.STATE_NULL)'.

I did do a quick test and changed our code to behave the same and it seems to work:

diff --git a/src/jarabe/model/speech.py b/src/jarabe/model/speech.py
index ffc108c..5b5518e 100644
--- a/src/jarabe/model/speech.py
+++ b/src/jarabe/model/speech.py
@@ -169,11 +169,14 @@ class _GstSpeechPlayer(gobject.GObject):

         bus = self._pipeline.get_bus()
         bus.add_signal_watch()
-        bus.connect('message::element', self.__pipe_message_cb)
+        bus.connect('message', self.__pipe_message_cb)

     def __pipe_message_cb(self, bus, message):
-        if message.structure.get_name() == 'espeak-mark' and \
-                message.structure['mark'] == 'end':
+        if message.type == gst.MESSAGE_EOS:
+            self._pipeline.set_state(gst.STATE_NULL)
+            self.emit('stop')
+        elif message.type == gst.MESSAGE_ERROR:
+            self._pipeline.set_state(gst.STATE_NULL)
             self.emit('stop')

Regards,
   Simon

[1] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-helloworld.html#section-helloworld
[2] http://pygstdocs.berlios.de/pygst-tutorial/playbin.html
_______________________________________________
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel

Reply via email to