diff --git a/avs/player/gstreamer_player.py b/avs/player/gstreamer_player.py index 7efabe7..0fde5af 100644 --- a/avs/player/gstreamer_player.py +++ b/avs/player/gstreamer_player.py @@ -10,7 +10,7 @@ from gi.repository import Gst, GLib, GObject -def setup(): +def setup_message_handler(): GObject.threads_init() Gst.init(None) loop = GLib.MainLoop() @@ -19,15 +19,18 @@ def setup(): t.daemon = True t.start() -setup() + return t class Player(object): + message_handler = None + def __init__(self): - self.callbacks = {} + if Player.message_handler is None: + Player.message_handler = setup_message_handler() + self.callbacks = {} self.player = Gst.ElementFactory.make("playbin", "player") - bus = self.player.get_bus() bus.add_signal_watch() bus.connect('message', self.on_message)