mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Merge branch 'dev' into dev-0.12
This commit is contained in:
+21
-20
@@ -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()
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
|
||||
@@ -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 <stdio.h>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Vendored
+11
-11
@@ -11,18 +11,18 @@
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h> /* <-- 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 <stdint.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+7
@@ -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;
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
|
||||
#include "miniaudio_libopus.h"
|
||||
|
||||
#if !defined(MA_NO_LIBOPUS)
|
||||
#include <opusfile.h>
|
||||
#endif
|
||||
|
||||
#include <string.h> /* For memset(). */
|
||||
#include <assert.h>
|
||||
|
||||
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 */
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#endif
|
||||
|
||||
#include <string.h> /* For memset(). */
|
||||
#include <assert.h>
|
||||
|
||||
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. */
|
||||
}
|
||||
|
||||
#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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14995,8 +14995,10 @@ typedef int ma_atomic_memory_order;
|
||||
}
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#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)
|
||||
{
|
||||
__atomic_compare_exchange_n(dst, &expected, desired, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user