From 94fdac04a12348ca1efa1427d6a18414008b8f24 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 10 Sep 2012 00:31:03 +0200 Subject: [PATCH] Cleanup after GStreamer actor Unregister callbacks and release pipeline resources when GStreamer actor shuts down. Fixes #185. --- mopidy/gstreamer.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mopidy/gstreamer.py b/mopidy/gstreamer.py index d9157a02..c25dde47 100644 --- a/mopidy/gstreamer.py +++ b/mopidy/gstreamer.py @@ -47,6 +47,10 @@ class GStreamer(ThreadingActor): self._setup_mixer() self._setup_message_processor() + def on_stop(self): + self._teardown_message_processor() + self._teardown_pipeline() + def _setup_pipeline(self): # TODO: replace with and input bin so we simply have an input bin we # connect to an output bin with a mixer on the side. set_uri on bin? @@ -65,6 +69,9 @@ class GStreamer(ThreadingActor): self._uridecodebin.connect('pad-added', self._on_new_pad, self._pipeline.get_by_name('queue').get_pad('sink')) + def _teardown_pipeline(self): + self._pipeline.set_state(gst.STATE_NULL) + def _setup_output(self): # This will raise a gobject.GError if the description is bad. self._output = gst.parse_bin_from_description( @@ -118,6 +125,10 @@ class GStreamer(ThreadingActor): bus.add_signal_watch() bus.connect('message', self._on_message) + def _teardown_message_processor(self): + bus = self._pipeline.get_bus() + bus.remove_signal_watch() + def _on_new_source(self, element, pad): self._source = element.get_property('source') try: