apply mpv fix

c0d9544812
This commit is contained in:
Damien Elmes 2020-05-27 09:19:20 +10:00
parent 97618564f4
commit c37390ae14

View file

@ -433,6 +433,9 @@ class MPV(MPVBase):
"""
def __init__(self, *args, **kwargs):
self._callbacks_queue = Queue()
self._callbacks_initialized = False
super().__init__(*args, **kwargs)
self._callbacks = {}
@ -455,6 +458,14 @@ class MPV(MPVBase):
name = name.replace("_", "-")
self.register_callback(name, method)
self._callbacks_initialized = True
while True:
try:
message = self._callbacks_queue.get_nowait()
except Empty:
break
self._handle_event(message)
# Simulate an init event when the process and all callbacks have been
# completely set up.
if hasattr(self, "on_init"):
@ -495,6 +506,10 @@ class MPV(MPVBase):
def _handle_event(self, message):
"""Lookup and call the callbacks for a particular event message.
"""
if not self._callbacks_initialized:
self._callbacks_queue.put(message)
return
if message["event"] == "property-change":
name = "property-" + message["name"]
else: