mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-29 19:54:05 +02:00
Enable libvorbis and libopus decoding in the deviceio test.
This commit is contained in:
@@ -907,6 +907,18 @@ if(MINIAUDIO_BUILD_TESTS)
|
|||||||
target_link_libraries(miniaudio_deviceio PRIVATE PkgConfig::SDL2)
|
target_link_libraries(miniaudio_deviceio PRIVATE PkgConfig::SDL2)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
if (TARGET libvorbis_interface)
|
||||||
|
target_link_libraries(miniaudio_deviceio PRIVATE libvorbis_interface)
|
||||||
|
target_compile_definitions(miniaudio_deviceio PRIVATE ENABLE_LIBVORBIS)
|
||||||
|
else()
|
||||||
|
message(STATUS "miniaudio_libvorbis is disabled. Vorbis support is disabled in miniaudio_deviceio.")
|
||||||
|
endif()
|
||||||
|
if (TARGET libopus_interface)
|
||||||
|
target_link_libraries(miniaudio_deviceio PRIVATE libopus_interface)
|
||||||
|
target_compile_definitions(miniaudio_deviceio PRIVATE ENABLE_LIBOPUS)
|
||||||
|
else()
|
||||||
|
message(STATUS "miniaudio_libopus is disabled. Opus support is disabled in miniaudio_deviceio.")
|
||||||
|
endif()
|
||||||
if(MINIAUDIO_NO_THREADING)
|
if(MINIAUDIO_NO_THREADING)
|
||||||
target_compile_definitions(miniaudio_deviceio PRIVATE MA_NO_THREADING) # We want to be able to test device I/O without threading.
|
target_compile_definitions(miniaudio_deviceio PRIVATE MA_NO_THREADING) # We want to be able to test device I/O without threading.
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ are specified the last one on the command line will have priority.
|
|||||||
#include "../common/common.c"
|
#include "../common/common.c"
|
||||||
#include "../../extras/backends/sdl2/miniaudio_sdl2.c"
|
#include "../../extras/backends/sdl2/miniaudio_sdl2.c"
|
||||||
|
|
||||||
|
#ifdef ENABLE_LIBVORBIS
|
||||||
|
#include "../../extras/decoders/libvorbis/miniaudio_libvorbis.c"
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_LIBOPUS
|
||||||
|
#include "../../extras/decoders/libopus/miniaudio_libopus.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef AUTO_CLOSE_TIME_IN_MILLISECONDS
|
#ifndef AUTO_CLOSE_TIME_IN_MILLISECONDS
|
||||||
#define AUTO_CLOSE_TIME_IN_MILLISECONDS 5000
|
#define AUTO_CLOSE_TIME_IN_MILLISECONDS 5000
|
||||||
#endif
|
#endif
|
||||||
@@ -689,7 +696,24 @@ int main(int argc, char** argv)
|
|||||||
if (deviceType == ma_device_type_playback) {
|
if (deviceType == ma_device_type_playback) {
|
||||||
if (g_State.sourceType == source_type_decoder) {
|
if (g_State.sourceType == source_type_decoder) {
|
||||||
ma_decoder_config decoderConfig;
|
ma_decoder_config decoderConfig;
|
||||||
|
ma_decoding_backend_vtable* ppDecodingBackends[16];
|
||||||
|
ma_uint32 decodingBackendCount;
|
||||||
|
|
||||||
|
decodingBackendCount = 0;
|
||||||
|
ppDecodingBackends[decodingBackendCount++] = ma_decoding_backend_wav;
|
||||||
|
ppDecodingBackends[decodingBackendCount++] = ma_decoding_backend_flac;
|
||||||
|
#ifdef ENABLE_LIBVORBIS
|
||||||
|
ppDecodingBackends[decodingBackendCount++] = ma_decoding_backend_libvorbis;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_LIBOPUS
|
||||||
|
ppDecodingBackends[decodingBackendCount++] = ma_decoding_backend_libopus;
|
||||||
|
#endif
|
||||||
|
ppDecodingBackends[decodingBackendCount++] = ma_decoding_backend_mp3; /* Do MP3 last since that's the problem child with our trial and error system. */
|
||||||
|
|
||||||
decoderConfig = ma_decoder_config_init(g_State.device.playback.format, g_State.device.playback.channels, g_State.device.sampleRate);
|
decoderConfig = ma_decoder_config_init(g_State.device.playback.format, g_State.device.playback.channels, g_State.device.sampleRate);
|
||||||
|
decoderConfig.ppBackendVTables = ppDecodingBackends;
|
||||||
|
decoderConfig.backendCount = decodingBackendCount;
|
||||||
|
|
||||||
result = ma_decoder_init_file(pFilePath, &decoderConfig, &g_State.decoder);
|
result = ma_decoder_init_file(pFilePath, &decoderConfig, &g_State.decoder);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
printf("Failed to open file for decoding \"%s\".\n", pFilePath);
|
printf("Failed to open file for decoding \"%s\".\n", pFilePath);
|
||||||
|
|||||||
Reference in New Issue
Block a user