diff --git a/CMakeLists.txt b/CMakeLists.txt index 57d2a38f..59931629 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ project(miniaudio # Options option(MINIAUDIO_BUILD_EXAMPLES "Build miniaudio examples" OFF) option(MINIAUDIO_BUILD_TESTS "Build miniaudio tests" OFF) -option(MINIAUDIO_FORCE_CXX "Use C++ compiler for C files" OFF) -option(MINIAUDIO_FORCE_C89 "Use C89 standard" OFF) +option(MINIAUDIO_FORCE_CXX "Force compilation as C++" OFF) +option(MINIAUDIO_FORCE_C89 "Force compilation as C89" OFF) option(MINIAUDIO_NO_LIBVORBIS "Disable miniaudio_libvorbis" OFF) option(MINIAUDIO_NO_LIBOPUS "Disable miniaudio_libopus" OFF) option(MINIAUDIO_NO_WASAPI "Disable the WASAPI backend" OFF) @@ -64,19 +64,30 @@ option(MINIAUDIO_DEBUG_OUTPUT "Enable stdout debug output" # Construct compiler options. set(COMPILE_OPTIONS) +if(MINIAUDIO_FORCE_CXX AND MINIAUDIO_FORCE_C89) + message(FATAL_ERROR "MINIAUDIO_FORCE_CXX and MINIAUDIO_FORCE_C89 cannot be enabled at the same time.") +endif() + if(MINIAUDIO_FORCE_CXX) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + message(STATUS "Compiling as C++ (GNU/Clang)") list(APPEND COMPILE_OPTIONS -x c++) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(STATUS "Compiling as C++ (MSVC)") list(APPEND COMPILE_OPTIONS /TP) + else() + message(WARNING "MINIAUDIO_FORCE_CXX is enabled but the compiler does not support it. Ignoring.") endif() endif() if(MINIAUDIO_FORCE_C89) - if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + message(STATUS "Compiling as C89") list(APPEND COMPILE_OPTIONS -std=c89) - elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - # MSVC does not have an option for forcing C89. + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(WARNING "MSVC does not support forcing C89. MINIAUDIO_FORCE_C89 ignored.") + else() + message(WARNING "MINIAUDIO_FORCE_C89 is enabled but the compiler does not support it. Ingoring.") endif() endif() @@ -84,7 +95,7 @@ endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") list(APPEND COMPILE_OPTIONS -Wall -Wextra -Wpedantic) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - list(APPEND COMPILE_OPTIONS /W4) + #list(APPEND COMPILE_OPTIONS /W4) endif() @@ -245,8 +256,6 @@ if(NOT MINIAUDIO_NO_LIBVORBIS) else() message(STATUS "libvorbisfile not found. miniaudio_libvorbis will be excluded.") endif() - - endif() if(NOT MINIAUDIO_NO_LIBOPUS) @@ -436,29 +445,21 @@ if (MINIAUDIO_BUILD_EXAMPLES) add_miniaudio_example(miniaudio_custom_backend custom_backend.c) add_miniaudio_example(miniaudio_custom_decoder_engine custom_decoder_engine.c) - if(HAS_LIBVORBIS) - target_link_libraries(miniaudio_custom_decoder_engine PRIVATE miniaudio_libvorbis) - else() + if(NOT HAS_LIBVORBIS) target_compile_definitions(miniaudio_custom_decoder_engine PRIVATE MA_NO_LIBVORBIS) message(STATUS "miniaudio_libvorbis is disabled. Vorbis support is disabled in miniaudio_custom_decoder_engine.") endif() - if(HAS_LIBOPUS) - target_link_libraries(miniaudio_custom_decoder_engine PRIVATE miniaudio_libopus) - else() + if(NOT HAS_LIBOPUS) target_compile_definitions(miniaudio_custom_decoder_engine PRIVATE MA_NO_LIBOPUS) message(STATUS "miniaudio_libopus is disabled. Opus support is disabled in miniaudio_custom_decoder_engine.") endif() add_miniaudio_example(miniaudio_custom_decoder custom_decoder.c) - if(HAS_LIBVORBIS) - target_link_libraries(miniaudio_custom_decoder PRIVATE miniaudio_libvorbis) - else() + if(NOT HAS_LIBVORBIS) target_compile_definitions(miniaudio_custom_decoder PRIVATE MA_NO_LIBVORBIS) message(STATUS "miniaudio_libvorbis is disabled. Vorbis support is disabled in miniaudio_custom_decoder.") endif() - if(HAS_LIBOPUS) - target_link_libraries(miniaudio_custom_decoder PRIVATE miniaudio_libopus) - else() + if(NOT HAS_LIBOPUS) target_compile_definitions(miniaudio_custom_decoder PRIVATE MA_NO_LIBOPUS) message(STATUS "miniaudio_libopus is disabled. Opus support is disabled in miniaudio_custom_decoder.") endif() diff --git a/examples/custom_decoder.c b/examples/custom_decoder.c index aef2fab9..f94158c6 100644 --- a/examples/custom_decoder.c +++ b/examples/custom_decoder.c @@ -29,8 +29,8 @@ The `onInitFile`, `onInitFileW` and `onInitMemory` functions are optional. For now these need to be declared before miniaudio.c due to some compatibility issues with the old MINIAUDIO_IMPLEMENTATION system. This will change from version 0.12. */ -#include "../extras/decoders/libvorbis/miniaudio_libvorbis.h" -#include "../extras/decoders/libopus/miniaudio_libopus.h" +#include "../extras/decoders/libvorbis/miniaudio_libvorbis.c" +#include "../extras/decoders/libopus/miniaudio_libopus.c" #include "../miniaudio.c" #include diff --git a/examples/custom_decoder_engine.c b/examples/custom_decoder_engine.c index a10b8cd7..e67a67da 100644 --- a/examples/custom_decoder_engine.c +++ b/examples/custom_decoder_engine.c @@ -10,8 +10,8 @@ example (via libopus). For now these need to be declared before miniaudio.c due to some compatibility issues with the old MINIAUDIO_IMPLEMENTATION system. This will change from version 0.12. */ -#include "../extras/decoders/libvorbis/miniaudio_libvorbis.h" -#include "../extras/decoders/libopus/miniaudio_libopus.h" +#include "../extras/decoders/libvorbis/miniaudio_libvorbis.c" +#include "../extras/decoders/libopus/miniaudio_libopus.c" #include "../miniaudio.c" #include diff --git a/examples/data_source_chaining.c b/examples/data_source_chaining.c index a66258ee..c9126976 100644 --- a/examples/data_source_chaining.c +++ b/examples/data_source_chaining.c @@ -135,15 +135,15 @@ int main(int argc, char** argv) deviceConfig.dataCallback = data_callback; deviceConfig.pUserData = NULL; - if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) { + result = ma_device_init(NULL, &deviceConfig, &device); + if (result != MA_SUCCESS) { printf("Failed to open playback device.\n"); - result = -1; goto done_decoders; } - if (ma_device_start(&device) != MA_SUCCESS) { + result = ma_device_start(&device); + if (result != MA_SUCCESS) { printf("Failed to start playback device.\n"); - result = -1; goto done; } diff --git a/examples/hilo_interop.c b/examples/hilo_interop.c index 620e238d..c5d1c7ff 100644 --- a/examples/hilo_interop.c +++ b/examples/hilo_interop.c @@ -46,7 +46,7 @@ void capture_data_callback(ma_device* pDevice, void* pFramesOut, const void* pFr } /* Copy the data from the capture buffer to the ring buffer. */ - ma_copy_pcm_frames(pMappedBuffer, ma_offset_pcm_frames_const_ptr_f32(pFramesIn, framesWritten, pDevice->capture.channels), framesToWrite, pDevice->capture.format, pDevice->capture.channels); + ma_copy_pcm_frames(pMappedBuffer, ma_offset_pcm_frames_const_ptr_f32((const float*)pFramesIn, framesWritten, pDevice->capture.channels), framesToWrite, pDevice->capture.format, pDevice->capture.channels); result = ma_pcm_rb_commit_write(&rb, framesToWrite); if (result != MA_SUCCESS) { diff --git a/examples/resource_manager_advanced.c b/examples/resource_manager_advanced.c index 43b0ba65..1784e06a 100644 --- a/examples/resource_manager_advanced.c +++ b/examples/resource_manager_advanced.c @@ -110,7 +110,7 @@ MA_API ma_result ma_data_source_read_pcm_frames_and_mix_f32(ma_data_source* pDat result = ma_data_source_read_pcm_frames_f32_ex(pDataSource, temp, framesToRead, &framesJustRead, format, channels); - ma_mix_pcm_frames_f32(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, ma_format_f32, channels), temp, framesJustRead, channels, volume); + ma_mix_pcm_frames_f32(ma_offset_pcm_frames_ptr_f32(pFramesOut, totalFramesRead, channels), temp, framesJustRead, channels, volume); totalFramesRead += framesJustRead; if (result != MA_SUCCESS) { diff --git a/external/fs/fs.c b/external/fs/fs.c index 5c7fe7f2..afc88fd4 100644 --- a/external/fs/fs.c +++ b/external/fs/fs.c @@ -11,18 +11,18 @@ #if defined(_WIN32) #include /* <-- Just can't get away from this darn thing... Needed for mutexes and file iteration. */ -static int fs_result_from_GetLastError(DWORD error) +static fs_result fs_result_from_GetLastError(DWORD error) { switch (error) { case ERROR_SUCCESS: return FS_SUCCESS; - case ERROR_NOT_ENOUGH_MEMORY: return ENOMEM; - case ERROR_SEM_TIMEOUT: return ETIMEDOUT; - case ERROR_BUSY: return EBUSY; + case ERROR_NOT_ENOUGH_MEMORY: return FS_OUT_OF_MEMORY; + case ERROR_BUSY: return FS_BUSY; + case ERROR_SEM_TIMEOUT: return FS_TIMEOUT; default: break; } - return EINVAL; + return FS_ERROR; } #endif @@ -1376,9 +1376,11 @@ static fs_result fs_file_duplicate_proxy(fs_file* pFile, fs_file* pDuplicatedFil /* Increment the reference count of the opened archive if necessary. */ if (fs_file_proxy_get_unref_archive_on_close(pFile)) { + fs* pOwnerFS; + fs_file_proxy_set_unref_archive_on_close(pDuplicatedFile, FS_TRUE); - fs* pOwnerFS = fs_proxy_get_owner_fs(pFS); + pOwnerFS = fs_proxy_get_owner_fs(pFS); if (pOwnerFS != NULL) { fs_increment_opened_archive_ref_count(pOwnerFS, pFS); } @@ -4517,7 +4519,7 @@ static fs_uint64 fs_FILETIME_to_unix(const FILETIME* pFT) li.HighPart = pFT->dwHighDateTime; li.LowPart = pFT->dwLowDateTime; - return (fs_uint64)(li.QuadPart / 10000000ULL - 11644473600ULL); /* Convert from Windows epoch to Unix epoch. */ + return (fs_uint64)(li.QuadPart / 10000000UL - 11644473600UL); /* Convert from Windows epoch to Unix epoch. */ } static fs_file_info fs_file_info_from_WIN32_FIND_DATAW(const WIN32_FIND_DATAW* pFD) @@ -5048,7 +5050,7 @@ FS_API fs_result fs_file_duplicate_stdio(fs_file* pFile, fs_file* pDuplicatedFil return fs_result_from_errno(GetLastError()); } - fdDuplicate = _open_osfhandle((intptr_t)hFileDuplicate, _O_RDONLY); + fdDuplicate = _open_osfhandle((fs_intptr)hFileDuplicate, _O_RDONLY); if (fdDuplicate == -1) { CloseHandle(hFileDuplicate); return fs_result_from_errno(errno); @@ -6003,8 +6005,6 @@ FS_API int fs_path_normalize(char* pDst, size_t dstCap, const char* pPath, size_ /* BEG fs_memory_stream.c */ -#include - static fs_result fs_memory_stream_read_internal(fs_stream* pStream, void* pDst, size_t bytesToRead, size_t* pBytesRead) { return fs_memory_stream_read((fs_memory_stream*)pStream, pDst, bytesToRead, pBytesRead); @@ -6030,7 +6030,7 @@ static fs_result fs_memory_stream_tell_internal(fs_stream* pStream, fs_int64* pC return result; } - if (cursor > INT64_MAX) { /* <-- INT64_MAX may not be defined on some compilers. Need to check this. Can easily define this ourselves. */ + if (cursor > FS_INT64_MAX) { /* <-- INT64_MAX may not be defined on some compilers. Need to check this. Can easily define this ourselves. */ return FS_ERROR; } diff --git a/external/fs/fs.h b/external/fs/fs.h index 53d201e7..e99686bb 100644 --- a/external/fs/fs.h +++ b/external/fs/fs.h @@ -580,8 +580,10 @@ extern "C" { #if FS_SIZEOF_PTR == 8 typedef unsigned long long fs_uintptr; + typedef long long fs_intptr; #else typedef unsigned int fs_uintptr; + typedef int fs_intptr; #endif typedef unsigned char fs_bool8; @@ -590,6 +592,9 @@ typedef unsigned int fs_bool32; #define FS_FALSE 0 +#define FS_INT64_MAX ((fs_int64)(((fs_uint64)0x7FFFFFFF << 32) | 0xFFFFFFFF)) + + #ifndef FS_API #define FS_API #endif @@ -659,8 +664,10 @@ typedef enum fs_result FS_IS_DIRECTORY = -15, FS_DIRECTORY_NOT_EMPTY = -16, FS_AT_END = -17, + FS_BUSY = -19, FS_BAD_SEEK = -25, FS_NOT_IMPLEMENTED = -29, + FS_TIMEOUT = -34, FS_CHECKSUM_MISMATCH = -100, FS_NO_BACKEND = -101 } fs_result; diff --git a/extras/decoders/libopus/miniaudio_libopus.c b/extras/decoders/libopus/miniaudio_libopus.c index 39df7ef0..d85eea10 100644 --- a/extras/decoders/libopus/miniaudio_libopus.c +++ b/extras/decoders/libopus/miniaudio_libopus.c @@ -3,8 +3,12 @@ #include "miniaudio_libopus.h" +#if !defined(MA_NO_LIBOPUS) #include +#endif + #include /* For memset(). */ +#include static ma_result ma_libopus_ds_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { @@ -221,7 +225,7 @@ MA_API void ma_libopus_uninit(ma_libopus* pOpus, const ma_allocation_callbacks* #else { /* libopus is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); } #endif @@ -296,7 +300,7 @@ MA_API ma_result ma_libopus_read_pcm_frames(ma_libopus* pOpus, void* pFramesOut, #else { /* libopus is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); (void)pFramesOut; (void)frameCount; @@ -331,7 +335,7 @@ MA_API ma_result ma_libopus_seek_to_pcm_frame(ma_libopus* pOpus, ma_uint64 frame #else { /* libopus is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); (void)frameIndex; @@ -385,7 +389,7 @@ MA_API ma_result ma_libopus_get_data_format(ma_libopus* pOpus, ma_format* pForma #else { /* libopus is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif @@ -417,7 +421,7 @@ MA_API ma_result ma_libopus_get_cursor_in_pcm_frames(ma_libopus* pOpus, ma_uint6 #else { /* libopus is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif @@ -449,7 +453,7 @@ MA_API ma_result ma_libopus_get_length_in_pcm_frames(ma_libopus* pOpus, ma_uint6 #else { /* libopus is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif @@ -459,6 +463,7 @@ MA_API ma_result ma_libopus_get_length_in_pcm_frames(ma_libopus* pOpus, ma_uint6 /* The code below defines the vtable that you'll plug into your `ma_decoder_config` object. */ +#if !defined(MA_NO_LIBOPUS) static ma_result ma_decoding_backend_init__libopus(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; @@ -535,7 +540,7 @@ static ma_encoding_format ma_decoding_backend_get_encoding_format__libopus(void* return ma_encoding_format_opus; } -static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libopus = +static ma_decoding_backend_vtable ma_gDecodingBackendVTable_libopus = { ma_decoding_backend_init__libopus, ma_decoding_backend_init_file__libopus, @@ -544,6 +549,9 @@ static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libopus = ma_decoding_backend_uninit__libopus, ma_decoding_backend_get_encoding_format__libopus }; -const ma_decoding_backend_vtable* ma_decoding_backend_libopus = &g_ma_decoding_backend_vtable_libopus; +const ma_decoding_backend_vtable* ma_decoding_backend_libopus = &ma_gDecodingBackendVTable_libopus; +#else +const ma_decoding_backend_vtable* ma_decoding_backend_libopus = NULL; +#endif #endif /* miniaudio_libopus_c */ diff --git a/extras/decoders/libvorbis/miniaudio_libvorbis.c b/extras/decoders/libvorbis/miniaudio_libvorbis.c index 75a68a3d..6d0bdb4c 100644 --- a/extras/decoders/libvorbis/miniaudio_libvorbis.c +++ b/extras/decoders/libvorbis/miniaudio_libvorbis.c @@ -11,6 +11,7 @@ #endif #include /* For memset(). */ +#include static ma_result ma_libvorbis_ds_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) { @@ -135,11 +136,20 @@ static ma_result ma_libvorbis_init_internal(const ma_decoding_backend_config* pC return result; /* Failed to initialize the base data source. */ } - pVorbis->vf = (OggVorbis_File*)ma_malloc(sizeof(OggVorbis_File), pAllocationCallbacks); - if (pVorbis->vf == NULL) { - ma_data_source_uninit(&pVorbis->ds); - return MA_OUT_OF_MEMORY; + #if !defined(MA_NO_LIBVORBIS) + { + pVorbis->vf = (OggVorbis_File*)ma_malloc(sizeof(OggVorbis_File), pAllocationCallbacks); + if (pVorbis->vf == NULL) { + ma_data_source_uninit(&pVorbis->ds); + return MA_OUT_OF_MEMORY; + } } + #else + { + /* libvorbis is disabled. */ + return MA_NOT_IMPLEMENTED; + } + #endif return MA_SUCCESS; } @@ -236,7 +246,7 @@ MA_API void ma_libvorbis_uninit(ma_libvorbis* pVorbis, const ma_allocation_callb #else { /* libvorbis is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); } #endif @@ -298,7 +308,7 @@ MA_API ma_result ma_libvorbis_read_pcm_frames(ma_libvorbis* pVorbis, void* pFram } } } else { - libvorbisResult = ov_read((OggVorbis_File*)pVorbis->vf, ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), framesToRead * ma_get_bytes_per_frame(format, channels), 0, 2, 1, NULL); + libvorbisResult = ov_read((OggVorbis_File*)pVorbis->vf, (char*)ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), framesToRead * ma_get_bytes_per_frame(format, channels), 0, 2, 1, NULL); if (libvorbisResult < 0) { result = MA_ERROR; /* Error while decoding. */ break; @@ -327,7 +337,7 @@ MA_API ma_result ma_libvorbis_read_pcm_frames(ma_libvorbis* pVorbis, void* pFram #else { /* libvorbis is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); (void)pFramesOut; (void)frameCount; @@ -362,7 +372,7 @@ MA_API ma_result ma_libvorbis_seek_to_pcm_frame(ma_libvorbis* pVorbis, ma_uint64 #else { /* libvorbis is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); (void)frameIndex; @@ -419,7 +429,7 @@ MA_API ma_result ma_libvorbis_get_data_format(ma_libvorbis* pVorbis, ma_format* #else { /* libvorbis is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif @@ -451,7 +461,7 @@ MA_API ma_result ma_libvorbis_get_cursor_in_pcm_frames(ma_libvorbis* pVorbis, ma #else { /* libvorbis is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif @@ -479,7 +489,7 @@ MA_API ma_result ma_libvorbis_get_length_in_pcm_frames(ma_libvorbis* pVorbis, ma #else { /* libvorbis is disabled. Should never hit this since initialization would have failed. */ - MA_ASSERT(MA_FALSE); + assert(MA_FALSE); return MA_NOT_IMPLEMENTED; } #endif @@ -489,6 +499,7 @@ MA_API ma_result ma_libvorbis_get_length_in_pcm_frames(ma_libvorbis* pVorbis, ma /* The code below defines the vtable that you'll plug into your `ma_decoder_config` object. */ +#if !defined(MA_NO_LIBVORBIS) static ma_result ma_decoding_backend_init__libvorbis(void* pUserData, ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_proc onTell, void* pReadSeekTellUserData, const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_data_source** ppBackend) { ma_result result; @@ -565,7 +576,7 @@ static ma_encoding_format ma_decoding_backend_get_encoding_format__libvorbis(voi return ma_encoding_format_vorbis; } -static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libvorbis = +static ma_decoding_backend_vtable ma_gDecodingBackendVTable_libvorbis = { ma_decoding_backend_init__libvorbis, ma_decoding_backend_init_file__libvorbis, @@ -574,6 +585,9 @@ static ma_decoding_backend_vtable g_ma_decoding_backend_vtable_libvorbis = ma_decoding_backend_uninit__libvorbis, ma_decoding_backend_get_encoding_format__libvorbis }; -const ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = &g_ma_decoding_backend_vtable_libvorbis; +const ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = &ma_gDecodingBackendVTable_libvorbis; +#else +const ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = NULL; +#endif #endif /* miniaudio_libvorbis_c */ diff --git a/extras/miniaudio_libvorbis.h b/extras/miniaudio_libvorbis.h index 34097dad..dfd2d184 100644 --- a/extras/miniaudio_libvorbis.h +++ b/extras/miniaudio_libvorbis.h @@ -334,7 +334,7 @@ MA_API ma_result ma_libvorbis_read_pcm_frames(ma_libvorbis* pVorbis, void* pFram } } } else { - libvorbisResult = ov_read(&pVorbis->vf, ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), framesToRead * ma_get_bytes_per_frame(format, channels), 0, 2, 1, NULL); + libvorbisResult = ov_read(&pVorbis->vf, (char*)ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), framesToRead * ma_get_bytes_per_frame(format, channels), 0, 2, 1, NULL); if (libvorbisResult < 0) { result = MA_ERROR; /* Error while decoding. */ break; diff --git a/miniaudio.h b/miniaudio.h index 2c57d6c7..761b8c94 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -14995,7 +14995,9 @@ typedef int ma_atomic_memory_order; } #if defined(__clang__) #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Watomic-alignment" + #if __clang_major__ >= 8 + #pragma clang diagnostic ignored "-Watomic-alignment" + #endif #endif static MA_INLINE ma_uint64 ma_atomic_compare_and_swap_64(volatile ma_uint64* dst, ma_uint64 expected, ma_uint64 desired) { diff --git a/tests/test_deviceio/ma_test_deviceio.c b/tests/test_deviceio/ma_test_deviceio.c index 495066e8..effc0027 100644 --- a/tests/test_deviceio/ma_test_deviceio.c +++ b/tests/test_deviceio/ma_test_deviceio.c @@ -594,7 +594,7 @@ int main(int argc, char** argv) } /* Now we just keep looping and wait for user input. */ - while (!g_State.wantsToClose) { + for (;;) { if (interactive) { int c; @@ -630,6 +630,10 @@ int main(int argc, char** argv) } } else { /* Running in auto-close mode. Just sleep for a bit. The data callback will control when this loop aborts. */ + if (g_State.wantsToClose) { + break; + } + ma_sleep(10); } }