From 4581ab8af9f96ee0f871051b77bf5a7ab9cbb14a Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Mon, 15 Sep 2025 20:50:14 -0400 Subject: [PATCH] torture --- libs/audio/audio.def | 48 +++++++++++++++++++++++++++++ libs/audio/test_wrapper.py | 62 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 libs/audio/audio.def create mode 100644 libs/audio/test_wrapper.py diff --git a/libs/audio/audio.def b/libs/audio/audio.def new file mode 100644 index 0000000..c8781f6 --- /dev/null +++ b/libs/audio/audio.def @@ -0,0 +1,48 @@ +EXPORTS +list_host_apis +init_audio_device +close_audio_device +is_audio_device_ready +set_master_volume +get_master_volume +load_wave +is_wave_valid +unload_wave +load_sound_from_wave +load_sound +is_sound_valid +unload_sound +play_sound +pause_sound +resume_sound +stop_sound +is_sound_playing +set_sound_volume +set_sound_pitch +set_sound_pan +load_audio_stream +unload_audio_stream +play_audio_stream +pause_audio_stream +resume_audio_stream +is_audio_stream_playing +stop_audio_stream +set_audio_stream_volume +set_audio_stream_pitch +set_audio_stream_pan +update_audio_stream +load_music_stream +is_music_valid +unload_music_stream +play_music_stream +pause_music_stream +resume_music_stream +stop_music_stream +seek_music_stream +update_music_stream +is_music_stream_playing +set_music_volume +set_music_pitch +set_music_pan +get_music_time_length +get_music_time_played diff --git a/libs/audio/test_wrapper.py b/libs/audio/test_wrapper.py new file mode 100644 index 0000000..fc553fa --- /dev/null +++ b/libs/audio/test_wrapper.py @@ -0,0 +1,62 @@ +import cffi +import os +import sys +from pathlib import Path + +def test_dll_loading(): + """Test DLL loading with detailed error reporting""" + + ffi = cffi.FFI() + + # Define minimal interface first + ffi.cdef(""" + void list_host_apis(void); + bool is_audio_device_ready(void); + """) + + dll_path = "./libaudio.dll" + + print(f"Testing DLL: {dll_path}") + print(f"DLL exists: {os.path.exists(dll_path)}") + + if os.path.exists(dll_path): + print(f"DLL size: {os.path.getsize(dll_path)} bytes") + + try: + # Try to load the DLL + print("Attempting to load DLL...") + lib = ffi.dlopen(dll_path) + print("✓ DLL loaded successfully!") + + # Try to call a simple function + print("Testing function call...") + ready = lib.is_audio_device_ready() + print(f"✓ Function call successful: {ready}") + + # Try calling list_host_apis (this initializes PortAudio) + print("Testing list_host_apis...") + lib.list_host_apis() + print("✓ list_host_apis completed") + + return True + + except Exception as e: + print(f"✗ Error: {e}") + print(f"Error type: {type(e).__name__}") + + # Additional debugging + if "GetLastError" in str(e): + import ctypes + error_code = ctypes.windll.kernel32.GetLastError() + print(f"Windows error code: 0x{error_code:x} ({error_code})") + + return False + +if __name__ == "__main__": + success = test_dll_loading() + if not success: + print("\nDebugging steps:") + print("1. Check DLL dependencies with: python check_deps.py") + print("2. Ensure all required DLLs are in PATH or same directory") + print("3. Verify DLL architecture matches Python (64-bit)") + print("4. Try the minimal test_dll.dll first")