mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-15 16:40:46 +00:00
check for error code -9 in clear_dirty()
re-raise error if not AttributeError otherwise clear pdirty only add -5,-6 response to ok in get_midi_message().
This commit is contained in:
parent
bafaa58507
commit
6de78a4037
@ -116,8 +116,12 @@ class Remote(CBindings):
|
|||||||
return self.call(self.vm_mdirty, ok=(0, 1)) == 1
|
return self.call(self.vm_mdirty, ok=(0, 1)) == 1
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||||
|
ERR_MSG = (
|
||||||
|
"no bind for VBVMR_MacroButton_IsDirty.",
|
||||||
|
"are you using an old version of the API?",
|
||||||
|
)
|
||||||
raise CAPIError(
|
raise CAPIError(
|
||||||
"no bind for VBVMR_MacroButton_IsDirty. are you using an old version of the API?"
|
"VBVMR_MacroButton_IsDirty", -9, msg=" ".join(ERR_MSG)
|
||||||
) from e
|
) from e
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -133,8 +137,10 @@ class Remote(CBindings):
|
|||||||
try:
|
try:
|
||||||
while self.pdirty or self.mdirty:
|
while self.pdirty or self.mdirty:
|
||||||
pass
|
pass
|
||||||
except CAPIError:
|
except CAPIError as e:
|
||||||
self.logger.error("no bind for mdirty, clearing pdirty only")
|
if e.fn_name == "VBVMR_MacroButton_IsDirty" and e.code != -9:
|
||||||
|
raise
|
||||||
|
self.logger.error(f"{e} clearing pdirty only.")
|
||||||
while self.pdirty:
|
while self.pdirty:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -174,8 +180,12 @@ class Remote(CBindings):
|
|||||||
)
|
)
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||||
|
ERR_MSG = (
|
||||||
|
"no bind for VBVMR_MacroButton_GetStatus.",
|
||||||
|
"are you using an old version of the API?",
|
||||||
|
)
|
||||||
raise CAPIError(
|
raise CAPIError(
|
||||||
"no bind for VBVMR_MacroButton_GetStatus. are you using an old version of the API?"
|
"VBVMR_MacroButton_GetStatus", -9, msg=" ".join(ERR_MSG)
|
||||||
) from e
|
) from e
|
||||||
return int(state.value)
|
return int(state.value)
|
||||||
|
|
||||||
@ -186,8 +196,12 @@ class Remote(CBindings):
|
|||||||
self.call(self.vm_set_buttonstatus, ct.c_long(id), c_state, ct.c_long(mode))
|
self.call(self.vm_set_buttonstatus, ct.c_long(id), c_state, ct.c_long(mode))
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||||
|
ERR_MSG = (
|
||||||
|
"no bind for VBVMR_MacroButton_SetStatus.",
|
||||||
|
"are you using an old version of the API?",
|
||||||
|
)
|
||||||
raise CAPIError(
|
raise CAPIError(
|
||||||
"no bind for VBVMR_MacroButton_SetStatus. are you using an old version of the API?"
|
"VBVMR_MacroButton_SetStatus", -9, msg=" ".join(ERR_MSG)
|
||||||
) from e
|
) from e
|
||||||
self.cache[f"mb_{id}_{mode}"] = int(c_state.value)
|
self.cache[f"mb_{id}_{mode}"] = int(c_state.value)
|
||||||
|
|
||||||
@ -240,7 +254,13 @@ class Remote(CBindings):
|
|||||||
def get_midi_message(self):
|
def get_midi_message(self):
|
||||||
n = ct.c_long(1024)
|
n = ct.c_long(1024)
|
||||||
buf = ct.create_string_buffer(1024)
|
buf = ct.create_string_buffer(1024)
|
||||||
res = self.vm_get_midi_message(ct.byref(buf), n, ok_exp=lambda r: r >= 0)
|
res = self.call(
|
||||||
|
self.vm_get_midi_message,
|
||||||
|
ct.byref(buf),
|
||||||
|
n,
|
||||||
|
ok=(-5, -6), # no data received from midi device
|
||||||
|
ok_exp=lambda r: r >= 0,
|
||||||
|
)
|
||||||
if res > 0:
|
if res > 0:
|
||||||
vals = tuple(
|
vals = tuple(
|
||||||
grouper(3, (int.from_bytes(buf[i], "little") for i in range(res)))
|
grouper(3, (int.from_bytes(buf[i], "little") for i in range(res)))
|
||||||
|
Loading…
Reference in New Issue
Block a user