From bd637e2462697e32098efdaa314489631e215f20 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Wed, 18 May 2022 10:32:03 +0000 Subject: [PATCH] Specify required argument types for FFI functions On arm64 macOS, variadic arguments have special calling convention rules. Therefore, we must specify the required argument types for ctypes to pass the arguments correctly. Apple documentation: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Update-Code-that-Passes-Arguments-to-Variadic-Functions Fix issue #8046 --- discord/opus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/opus.py b/discord/opus.py index 9eda3f0b3..b9cf2124f 100644 --- a/discord/opus.py +++ b/discord/opus.py @@ -142,7 +142,7 @@ def _err_ne(result: T, func: Callable, args: List) -> T: # The fourth is the error handler. exported_functions: List[Tuple[Any, ...]] = [ # Generic - ('opus_get_version_string', None, ctypes.c_char_p, None), + ('opus_get_version_string', [], ctypes.c_char_p, None), ('opus_strerror', [ctypes.c_int], ctypes.c_char_p, None), # Encoder functions ('opus_encoder_get_size', [ctypes.c_int], ctypes.c_int, None), @@ -154,7 +154,7 @@ exported_functions: List[Tuple[Any, ...]] = [ ctypes.c_int32, _err_lt, ), - ('opus_encoder_ctl', None, ctypes.c_int32, _err_lt), + ('opus_encoder_ctl', [EncoderStructPtr, ctypes.c_int], ctypes.c_int32, _err_lt), ('opus_encoder_destroy', [EncoderStructPtr], None, None), # Decoder functions ('opus_decoder_get_size', [ctypes.c_int], ctypes.c_int, None), @@ -171,7 +171,7 @@ exported_functions: List[Tuple[Any, ...]] = [ ctypes.c_int, _err_lt, ), - ('opus_decoder_ctl', None, ctypes.c_int32, _err_lt), + ('opus_decoder_ctl', [DecoderStructPtr, ctypes.c_int], ctypes.c_int32, _err_lt), ('opus_decoder_destroy', [DecoderStructPtr], None, None), ('opus_decoder_get_nb_samples', [DecoderStructPtr, ctypes.c_char_p, ctypes.c_int32], ctypes.c_int, _err_lt), # Packet functions