diff --git a/libs/audio/Makefile b/libs/audio/Makefile index 9b0369a..ab776ae 100644 --- a/libs/audio/Makefile +++ b/libs/audio/Makefile @@ -65,6 +65,12 @@ ifneq (,$(findstring MINGW,$(UNAME_S))) CORE_LIBS += -lsamplerate endif + ifneq (,$(wildcard /mingw64/lib/libwinpthread.a)) + SYSTEM_LIBS += /mingw64/lib/libwinpthread.a + else + SYSTEM_LIBS += -lwinpthread + endif + # Windows system libraries (these provide the missing symbols) SYSTEM_LIBS = -lwinmm -lole32 -luuid -lksuser -lsetupapi -lws2_32 -ladvapi32 -luser32 -lgdi32 -lkernel32 diff --git a/libs/audio/audio.def b/libs/audio/audio.def deleted file mode 100644 index c8781f6..0000000 --- a/libs/audio/audio.def +++ /dev/null @@ -1,48 +0,0 @@ -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/build.sh b/libs/audio/build.sh deleted file mode 100755 index 4e10150..0000000 --- a/libs/audio/build.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -set -e - -echo "Cross-compiling audio library for Windows..." - -# Configuration -MINGW_PREFIX="x86_64-w64-mingw32" -CC="${MINGW_PREFIX}-gcc" -WIN_DEPS="win-libs" - -# Check if cross-compiler is available -if ! command -v $CC &> /dev/null; then - echo "Error: MinGW-w64 cross-compiler not found!" - echo "Install it with: sudo apt-get install mingw-w64" - exit 1 -fi - -# Check if Windows dependencies exist -if [ ! -d "$WIN_DEPS" ]; then - echo "Warning: Windows dependencies not found in $WIN_DEPS" - echo "You may need to build or download Windows versions of:" - echo " - PortAudio" - echo " - libsndfile" - echo " - libsamplerate" -fi - -# Build command -CFLAGS="-O2 -Wall -Wextra" -LDFLAGS="-shared -Wl,--out-implib,libaudio.lib -static-libgcc -static-libstdc++" -LIBS="-lportaudio -lsndfile -lsamplerate -lwinmm -lole32 -luuid -lksuser -lsetupapi" - -if [ -d "$WIN_DEPS" ]; then - CFLAGS="$CFLAGS -I${WIN_DEPS}/include" - LDFLAGS="$LDFLAGS -L${WIN_DEPS}/lib" -fi - -echo "Compiling with: $CC" -$CC $CFLAGS $LDFLAGS audio.c -o libaudio.dll $LIBS - -if [ $? -eq 0 ]; then - echo "Successfully built libaudio.dll" - echo "Import library: libaudio.lib" - - # Check if we can get file info - if command -v file &> /dev/null; then - file libaudio.dll - fi - - # List exported functions - if command -v ${MINGW_PREFIX}-objdump &> /dev/null; then - echo "Exported functions:" - ${MINGW_PREFIX}-objdump -p libaudio.dll | grep "\\[.*\\]" | head -20 - fi -else - echo "Build failed!" - exit 1 -fi diff --git a/libs/audio/check_deps.py b/libs/audio/check_deps.py deleted file mode 100644 index 79424c0..0000000 --- a/libs/audio/check_deps.py +++ /dev/null @@ -1,168 +0,0 @@ -import ctypes -import ctypes.wintypes -import os -import sys -from pathlib import Path -import struct - -# Windows API constants -LOAD_LIBRARY_AS_DATAFILE = 0x00000002 -DONT_RESOLVE_DLL_REFERENCES = 0x00000001 - -def check_dll_architecture(dll_path): - """Check if DLL is 32-bit or 64-bit""" - try: - with open(dll_path, 'rb') as f: - # Read DOS header - dos_header = f.read(64) - if dos_header[:2] != b'MZ': - return "Not a valid PE file" - - # Get PE header offset - pe_offset = struct.unpack(' 1: - dll_path = sys.argv[1] - - print(f"Python Architecture: {check_python_architecture()}") - print() - - check_dll_dependencies_windows(dll_path) - test_cffi_loading(dll_path) diff --git a/libs/audio/test_wrapper.py b/libs/audio/test_wrapper.py deleted file mode 100644 index fc553fa..0000000 --- a/libs/audio/test_wrapper.py +++ /dev/null @@ -1,62 +0,0 @@ -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")