summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2022-04-22 23:24:10 +0200
committerjaseg <git@jaseg.de>2022-04-22 23:24:10 +0200
commit3cb1196621e5817761a08b88272135ac6b783039 (patch)
tree81d49f7ea6fb35bee054bd4ec984c102456db397
parent85ad2a6aa6ef526db7b47c9e062f3460610e163d (diff)
downloadpython-mpv-3cb1196621e5817761a08b88272135ac6b783039.tar.gz
python-mpv-3cb1196621e5817761a08b88272135ac6b783039.tar.bz2
python-mpv-3cb1196621e5817761a08b88272135ac6b783039.zip
Finish event infrastructure rework.
-rw-r--r--mpv.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/mpv.py b/mpv.py
index 714c293..6469ebb 100644
--- a/mpv.py
+++ b/mpv.py
@@ -459,13 +459,12 @@ class MpvEventClientMessage(Structure):
class MpvEventCommand(Structure):
_fields_ = [('_result', MpvNode)]
- @property
- def result_raw(self):
- return self._result.node_value()
+ def unpack(self, decoder=identity_decoder):
+ return self._result.node_value(decoder=decoder)
@property
def result(self):
- return self._result.node_value(decoder=lazy_decoder)
+ return self.unpack()
class MpvEventHook(Structure):
_fields_ = [('_name', c_char_p),
@@ -918,7 +917,7 @@ class MPV(object):
key = event.reply_userdata
callback = self._command_reply_callbacks.pop(key, None)
if callback:
- callback(ErrorCode.exception_for_ec(event.error), event.data.result)
+ callback(ErrorCode.exception_for_ec(event.error), event.data)
if eid == MpvEventID.SHUTDOWN:
_mpv_destroy(self._event_handle)
@@ -1111,7 +1110,7 @@ class MPV(object):
args = _create_null_term_cmd_arg_array(name, args)
_mpv_command(self.handle, args)
- def command_async(self, name, *args, callback=None, **kwargs):
+ def command_async(self, name, *args, callback=None, decoder=lazy_decoder, **kwargs):
"""Same as mpv_command, but run the command asynchronously. If you provide a callback, that callback will be
called after completion or on error. This method returns a future that evaluates to the result of the callback
(if given), and the result of the libmpv call otherwise.
@@ -1136,6 +1135,7 @@ class MPV(object):
def wrapper(error, result):
try:
+ result = result.unpack(decoder)
future.set_result(callback(error, result))
except Exception as e:
future.set_exception(e)