Skip to content

Commit

Permalink
lazy setup glib main loop
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongyihui committed May 24, 2018
1 parent daf114b commit eef6c7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions avs/player/gstreamer_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit eef6c7e

Please sign in to comment.