From 110ded6fc60823f2bc25ef2a61a1d12a36307ded Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 21 Jul 2025 16:11:31 +1000 Subject: [PATCH] Include the SDL2 and PipeWire backends in the deviceio test. --- CMakeLists.txt | 4 ++++ tests/deviceio/deviceio.c | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9bea30f..4c34faf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -603,6 +603,10 @@ if(MINIAUDIO_BUILD_TESTS) function(add_miniaudio_test name source) add_executable(${name} ${TESTS_DIR}/${source}) target_link_libraries(${name} PRIVATE miniaudio_common_options) + if(TARGET miniaudio_pipewire) + target_link_libraries(${name} PRIVATE miniaudio_pipewire) + target_compile_definitions(${name} PRIVATE MA_TESTS_INCLUDE_PIPEWIRE) + endif() endfunction() # The debugging test is only used for debugging miniaudio itself. Don't do add_test() for this, and do not include it in in any automated testing. diff --git a/tests/deviceio/deviceio.c b/tests/deviceio/deviceio.c index 8780b0e0..22101ad1 100644 --- a/tests/deviceio/deviceio.c +++ b/tests/deviceio/deviceio.c @@ -1,5 +1,5 @@ /* -USAGE: ma_test_deviceio [input/output file] [mode] [backend] [waveform] [noise] [--auto] +USAGE: deviceio [input/output file] [mode] [backend] [waveform] [noise] [--auto] In playback mode the input file is optional, in which case a waveform or noise source will be used instead. For capture and loopback modes it must specify an output parameter, and must be specified. In duplex mode it is optional, but if specified will be an output file that @@ -26,6 +26,8 @@ will receive the captured audio. opensl webaudio null + sdl2 + pipewire "waveform" can be one of the following: sine @@ -42,6 +44,11 @@ If multiple backends are specified, the priority will be based on the order in w are specified the last one on the command line will have priority. */ #include "../common/common.c" +#include "../../extras/backends/sdl/backend_sdl.c" + +#if defined(MA_TESTS_INCLUDE_PIPEWIRE) +#include "../../extras/backends/pipewire/miniaudio_pipewire.h" +#endif #ifndef AUTO_CLOSE_TIME_IN_MILLISECONDS #define AUTO_CLOSE_TIME_IN_MILLISECONDS 5000 @@ -181,6 +188,18 @@ ma_bool32 try_parse_backend(const char* arg, ma_device_backend_config* pBackends pBackends[backendCount++] = ma_device_backend_config_init(ma_device_backend_null, NULL); goto done; } + if (strcmp(arg, "sdl2") == 0) { + pBackends[backendCount++] = ma_device_backend_config_init(ma_device_backend_sdl, NULL); + goto done; + } + if (strcmp(arg, "pipewire") == 0) { + #if defined(MA_TESTS_INCLUDE_PIPEWIRE) + pBackends[backendCount++] = ma_device_backend_config_init(ma_device_backend_pipewire, NULL); + #else + printf("ERROR: Attempting to use PipeWire, but it was not compiled in. Compile with MA_TESTS_INCLUDE_PIPEWIRE."); + #endif + goto done; + } done: if (*pBackendCount < backendCount) { @@ -509,7 +528,7 @@ int main(int argc, char** argv) deviceConfig.notificationCallback = on_notification; result = ma_device_init(&g_State.context, &deviceConfig, &g_State.device); if (result != MA_SUCCESS) { - printf("Failed to initialize device.\n"); + printf("Failed to initialize device: %s.\n", ma_result_description(result)); ma_context_uninit(&g_State.context); return -1; }