mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Include the SDL2 and PipeWire backends in the deviceio test.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user