From 42c5c5581b83a00e2c1de42e4fe687a30b9efa5a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 21 Nov 2022 12:30:18 +0100 Subject: [PATCH] windows ports: enable PortAudio via pkg-config in CMake build --- port/windows-h4-da14585/CMakeLists.txt | 14 ++++++++++++++ port/windows-h4-da14585/main.c | 6 ++++++ port/windows-h4-zephyr/CMakeLists.txt | 14 ++++++++++++++ port/windows-h4-zephyr/main.c | 6 ++++++ port/windows-h4/CMakeLists.txt | 14 ++++++++++++++ port/windows-h4/main.c | 6 ++++++ port/windows-winusb-intel/CMakeLists.txt | 14 ++++++++++++++ port/windows-winusb-intel/main.c | 6 ++++++ port/windows-winusb/CMakeLists.txt | 17 ++++++++++++++++- port/windows-winusb/main.c | 6 ++++++ 10 files changed, 102 insertions(+), 1 deletion(-) diff --git a/port/windows-h4-da14585/CMakeLists.txt b/port/windows-h4-da14585/CMakeLists.txt index 5a0eff09e..7e1513adc 100644 --- a/port/windows-h4-da14585/CMakeLists.txt +++ b/port/windows-h4-da14585/CMakeLists.txt @@ -17,6 +17,20 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ endif() +# pkgconfig +find_package(PkgConfig REQUIRED) + +# portaudio +pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +if(PORTAUDIO_FOUND) + message("HAVE_PORTAUDIO") + include_directories(${PORTAUDIO_INCLUDE_DIRS}) + link_directories(${PORTAUDIO_LIBRARY_DIRS}) + link_libraries(${PORTAUDIO_LIBRARIES}) + # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) + SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") +endif() + # to generate .h from .gatt files find_package (Python REQUIRED COMPONENTS Interpreter) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/port/windows-h4-da14585/main.c b/port/windows-h4-da14585/main.c index 0e3e69112..331583e98 100644 --- a/port/windows-h4-da14585/main.c +++ b/port/windows-h4-da14585/main.c @@ -51,6 +51,7 @@ #include "btstack_config.h" #include "ble/le_device_db_tlv.h" +#include "btstack_audio.h" #include "btstack_chipset_da145xx.h" #include "btstack_debug.h" #include "btstack_event.h" @@ -156,6 +157,11 @@ static void phase2(int status){ const hci_transport_t * transport = hci_transport_h4_instance(uart_driver); hci_init(transport, (void*) &transport_config); +#ifdef HAVE_PORTAUDIO + btstack_audio_sink_set_instance(btstack_audio_portaudio_sink_get_instance()); + btstack_audio_source_set_instance(btstack_audio_portaudio_source_get_instance()); +#endif + // inform about BTstack state hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); diff --git a/port/windows-h4-zephyr/CMakeLists.txt b/port/windows-h4-zephyr/CMakeLists.txt index 42852d4eb..14566ac2d 100644 --- a/port/windows-h4-zephyr/CMakeLists.txt +++ b/port/windows-h4-zephyr/CMakeLists.txt @@ -17,6 +17,20 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ endif() +# pkgconfig +find_package(PkgConfig REQUIRED) + +# portaudio +pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +if(PORTAUDIO_FOUND) + message("HAVE_PORTAUDIO") + include_directories(${PORTAUDIO_INCLUDE_DIRS}) + link_directories(${PORTAUDIO_LIBRARY_DIRS}) + link_libraries(${PORTAUDIO_LIBRARIES}) + # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) + SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") +endif() + # to generate .h from .gatt files find_package (Python REQUIRED COMPONENTS Interpreter) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/port/windows-h4-zephyr/main.c b/port/windows-h4-zephyr/main.c index 602677c02..c29073c0c 100644 --- a/port/windows-h4-zephyr/main.c +++ b/port/windows-h4-zephyr/main.c @@ -52,6 +52,7 @@ #include "ble/le_device_db_tlv.h" #include "bluetooth_company_id.h" +#include "btstack_audio.h" #include "btstack_chipset_zephyr.h" #include "btstack_debug.h" #include "btstack_event.h" @@ -172,6 +173,11 @@ int main(int argc, const char * argv[]){ hci_init(transport, (void*) &config); hci_set_chipset(btstack_chipset_zephyr_instance()); +#ifdef HAVE_PORTAUDIO + btstack_audio_sink_set_instance(btstack_audio_portaudio_sink_get_instance()); + btstack_audio_source_set_instance(btstack_audio_portaudio_source_get_instance()); +#endif + // inform about BTstack state hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); diff --git a/port/windows-h4/CMakeLists.txt b/port/windows-h4/CMakeLists.txt index dfa901363..c226f239a 100644 --- a/port/windows-h4/CMakeLists.txt +++ b/port/windows-h4/CMakeLists.txt @@ -17,6 +17,20 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ endif() +# pkgconfig +find_package(PkgConfig REQUIRED) + +# portaudio +pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +if(PORTAUDIO_FOUND) + message("HAVE_PORTAUDIO") + include_directories(${PORTAUDIO_INCLUDE_DIRS}) + link_directories(${PORTAUDIO_LIBRARY_DIRS}) + link_libraries(${PORTAUDIO_LIBRARIES}) + # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) + SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") +endif() + # to generate .h from .gatt files find_package (Python REQUIRED COMPONENTS Interpreter) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/port/windows-h4/main.c b/port/windows-h4/main.c index ac1dddab2..70196954b 100644 --- a/port/windows-h4/main.c +++ b/port/windows-h4/main.c @@ -46,6 +46,7 @@ #include "ble/le_device_db_tlv.h" #include "bluetooth_company_id.h" +#include "btstack_audio.h" #include "btstack_chipset_bcm.h" #include "btstack_chipset_cc256x.h" #include "btstack_chipset_csr.h" @@ -253,6 +254,11 @@ int main(int argc, const char * argv[]){ const hci_transport_t * transport = hci_transport_h4_instance(uart_driver); hci_init(transport, (void*) &config); +#ifdef HAVE_PORTAUDIO + btstack_audio_sink_set_instance(btstack_audio_portaudio_sink_get_instance()); + btstack_audio_source_set_instance(btstack_audio_portaudio_source_get_instance()); +#endif + // inform about BTstack state hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); diff --git a/port/windows-winusb-intel/CMakeLists.txt b/port/windows-winusb-intel/CMakeLists.txt index 1032c066b..c2f1d56ae 100644 --- a/port/windows-winusb-intel/CMakeLists.txt +++ b/port/windows-winusb-intel/CMakeLists.txt @@ -17,6 +17,20 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ endif() +# pkgconfig +find_package(PkgConfig REQUIRED) + +# portaudio +pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +if(PORTAUDIO_FOUND) + message("HAVE_PORTAUDIO") + include_directories(${PORTAUDIO_INCLUDE_DIRS}) + link_directories(${PORTAUDIO_LIBRARY_DIRS}) + link_libraries(${PORTAUDIO_LIBRARIES}) + # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) + SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") +endif() + # Generate .h from .gatt files find_package (Python COMPONENTS Interpreter) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/port/windows-winusb-intel/main.c b/port/windows-winusb-intel/main.c index 334bc6f0b..50d8ff3be 100644 --- a/port/windows-winusb-intel/main.c +++ b/port/windows-winusb-intel/main.c @@ -51,6 +51,7 @@ #include "btstack_config.h" #include "ble/le_device_db_tlv.h" +#include "btstack_audio.h" #include "btstack_chipset_intel_firmware.h" #include "btstack_debug.h" #include "btstack_event.h" @@ -140,6 +141,11 @@ static void intel_firmware_done(int result){ // init HCI hci_init(transport, NULL); +#ifdef HAVE_PORTAUDIO + btstack_audio_sink_set_instance(btstack_audio_portaudio_sink_get_instance()); + btstack_audio_source_set_instance(btstack_audio_portaudio_source_get_instance()); +#endif + // inform about BTstack state hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration); diff --git a/port/windows-winusb/CMakeLists.txt b/port/windows-winusb/CMakeLists.txt index 008b9b7fa..fe60cd555 100644 --- a/port/windows-winusb/CMakeLists.txt +++ b/port/windows-winusb/CMakeLists.txt @@ -17,6 +17,20 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ endif() +# pkgconfig +find_package(PkgConfig REQUIRED) + +# portaudio +pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0) +if(PORTAUDIO_FOUND) + message("HAVE_PORTAUDIO") + include_directories(${PORTAUDIO_INCLUDE_DIRS}) + link_directories(${PORTAUDIO_LIBRARY_DIRS}) + link_libraries(${PORTAUDIO_LIBRARIES}) + # CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO) + SET(CMAKE_C_FLAGS "-DHAVE_PORTAUDIO") +endif() + # to generate .h from .gatt files find_package (Python REQUIRED COMPONENTS Interpreter) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -51,13 +65,14 @@ file(GLOB SOURCES_RIJNDAEL "../../3rd-party/rijndael/rijndael.c") file(GLOB SOURCES_WINDOWS "../../platform/windows/*.c") file(GLOB SOURCES_ZEPHYR "../../chipset/zephyr/*.c") file(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c") -file(GLOB SOURCES_PORT "*.c") +file(GLOB SOURCES_PORT "main.c" "../../platform/posix/btstack_audio_portaudio.c") file(GLOB SOURCES_YXML "../../3rd-party/yxml/yxml.c") file(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c") list(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF}) + set(SOURCES ${SOURCES_BLE} ${SOURCES_BLUEDROID} diff --git a/port/windows-winusb/main.c b/port/windows-winusb/main.c index a88992d2b..a7edf38a0 100644 --- a/port/windows-winusb/main.c +++ b/port/windows-winusb/main.c @@ -52,6 +52,7 @@ #include "btstack_config.h" #include "ble/le_device_db_tlv.h" +#include "btstack_audio.h" #include "btstack_debug.h" #include "btstack_event.h" #include "btstack_memory.h" @@ -147,6 +148,11 @@ int main(int argc, const char * argv[]){ // init HCI hci_init(hci_transport_usb_instance(), NULL); +#ifdef HAVE_PORTAUDIO + btstack_audio_sink_set_instance(btstack_audio_portaudio_sink_get_instance()); + btstack_audio_source_set_instance(btstack_audio_portaudio_source_get_instance()); +#endif + // inform about BTstack state hci_event_callback_registration.callback = &packet_handler; hci_add_event_handler(&hci_event_callback_registration);