mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Compare commits
108 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f40cf03f80 | |||
| 7f2cd5b8d5 | |||
| 3afbdef285 | |||
| 9a091f73aa | |||
| 4de39a8a37 | |||
| 7c8574210d | |||
| 6648ed005a | |||
| 87bae56937 | |||
| 293f5de18f | |||
| 233b9b69c4 | |||
| db514e813f | |||
| 8130543730 | |||
| b306c6a270 | |||
| 9e1f02b12a | |||
| fa84240364 | |||
| 70eb06d3bd | |||
| 959283f244 | |||
| ea59076ba9 | |||
| 1d7d8dfba0 | |||
| f48d903526 | |||
| 3bdd39fd2c | |||
| e75a053908 | |||
| 346d86ffa1 | |||
| a2f92095dc | |||
| badf36a378 | |||
| c9d288c3dc | |||
| 825d2c4466 | |||
| 6fd62e6bbc | |||
| b1893aa8f1 | |||
| df4baf8d40 | |||
| 21237008df | |||
| 587bd83cbb | |||
| b7e5451ef4 | |||
| ba84e61a18 | |||
| a7ab58259e | |||
| 18055f34bb | |||
| f6bae251bd | |||
| 3567d5cfef | |||
| 4e3b778c62 | |||
| 6315130ec6 | |||
| 6e1cd41622 | |||
| 78cdb9c1cb | |||
| 1ea69211ad | |||
| e9e8f90137 | |||
| d93552283f | |||
| 61a85dca42 | |||
| c87f207f4e | |||
| 02ae7e41f0 | |||
| 457a7279fa | |||
| fe1da60e1e | |||
| 0b70a990ca | |||
| 556160909e | |||
| c48975f4a9 | |||
| 79b4ddc27d | |||
| 0b9f03a376 | |||
| 140b9c7f9f | |||
| ac8c908283 | |||
| 8b87c10681 | |||
| 629d509072 | |||
| 5c86dd9153 | |||
| e54336996d | |||
| 1c7967fc88 | |||
| 2bc0e14abf | |||
| b348ab0155 | |||
| 346d65091a | |||
| aa75d5f8e8 | |||
| 0ac5c89157 | |||
| 47020e4092 | |||
| 02873ca300 | |||
| 11177ed19f | |||
| 682fad7d55 | |||
| 1497f5e467 | |||
| 853f27ed56 | |||
| 05d367eed5 | |||
| 97493bdfcd | |||
| 3edfb70a26 | |||
| 72e4721b2c | |||
| b255e91e08 | |||
| b261f4aeec | |||
| bd59c52309 | |||
| f15ddefce8 | |||
| 29c17fcb22 | |||
| 5a9c322c83 | |||
| cd14d18d0c | |||
| 534b43e800 | |||
| caa3d2a339 | |||
| 4c2d1bb67c | |||
| 5ba0fc51b6 | |||
| e58a24124a | |||
| 0b4646d31a | |||
| 9032fdbced | |||
| 2ee920577e | |||
| a944e19331 | |||
| 8a9ea7ce07 | |||
| 80747f440a | |||
| d40a385e07 | |||
| 7df2a50d7f | |||
| ab80abf061 | |||
| b9292a301f | |||
| 484a56499d | |||
| b12959f1d4 | |||
| 94077d5a95 | |||
| b3ab0567c3 | |||
| 7158cf58f9 | |||
| fe616c1a5a | |||
| cd16c5bcd3 | |||
| 76dfabbb45 | |||
| 46d8abf3de |
+2
-6
@@ -21,6 +21,7 @@
|
||||
/research/_build/
|
||||
/tests/_build/bin/
|
||||
/tests/_build/res/output/
|
||||
/tests/_build/cmake-emcc/
|
||||
/tests/_build/tcc/
|
||||
/tests/_build/vc6/
|
||||
/tests/_build/vc15/
|
||||
@@ -32,7 +33,6 @@
|
||||
/tests/debugging/archive/
|
||||
/tests/*.c
|
||||
/tests/*.cpp
|
||||
/tools/_build/
|
||||
/website/docs/
|
||||
*.vcxproj.user
|
||||
.vs/
|
||||
@@ -46,8 +46,4 @@
|
||||
/research/ma_atomic.c
|
||||
/research/miniaudio_engine.c
|
||||
/tests/stress/
|
||||
/tools/codegen/miniaudio_amalgamator.c
|
||||
/tools/codegen/miniaudio_codegen_utils.c
|
||||
/tools/codegen/miniaudio_docgen.c
|
||||
/tools/codegen/miniaudio_hrtfgen.c
|
||||
/tools/codegen/miniaudio_splitter.c
|
||||
/tools/hrtfgen/
|
||||
+28
@@ -1,3 +1,31 @@
|
||||
v0.11.23 - 2025-09-11
|
||||
=====================
|
||||
* Fixed an error in `ma_channel_map_to_string()` where the output string is not null terminated correctly.
|
||||
* Fixed an error with logging due to mishandling of va_list.
|
||||
* Fixed some errors when compiling with `MA_NO_RUNTIME_LINKING`.
|
||||
* Fixed an error with `ma_sound` initialization where the initial loop points are not set correctly.
|
||||
* Fixed an alignment error with the ring buffer.
|
||||
* Fixed a memory leak in the resource manager when opening a file fails.
|
||||
* Fixed an assertion failure in the resource manager when opening a file fails.
|
||||
* Fixed a compilation warning relating to `MA_FALLTHROUGH`
|
||||
* Fixed an undefined behavior error in the s16 to s32 conversion routine.
|
||||
* Fixed an undefined behavior error relating to MurmurHash3.
|
||||
* Fixed an undefined behavior error with the LCG random number generator.
|
||||
* Fixed a compilation error with `MA_NO_SSE2`.
|
||||
* Fixed some unused function warnings.
|
||||
* Fixed a rare, but technically possible division by zero error.
|
||||
* Some const correctness fixes for `ma_sound`.
|
||||
* Improved compatibility with old versions of GCC.
|
||||
* Miscellaneous documentation fixes.
|
||||
* WAV, FLAC and MP3 decoders have been brought up to date with dr_libs. Of particular note, this should fix some long outstanding bugs with MP3 due to metadata not being handled correctly.
|
||||
* POSIX: Added a fallback for when creation of a real-time thread fails. This fallback can be disabled with `MA_NO_PTHREAD_REALTIME_PRIORITY_FALLBACK` if you need an explicit failure.
|
||||
* POSIX: pthread.h is no longer included when `MA_NO_THREADING` is defined.
|
||||
* WASAPI: Improved handling of COM initialization and shutdown to make it a bit more robust.
|
||||
* WASAPI: Fix an error due to a missing struct member.
|
||||
* PulseAudio: Fixed a crash when requesting a channel count greater than 32.
|
||||
* AAudio: Fixed a crash when uninitializing the device while in the middle of rerouting.
|
||||
|
||||
|
||||
v0.11.22 - 2025-02-24
|
||||
=====================
|
||||
* Starting from version 0.12, miniaudio will be switching to a split .c/h pair, away from a single header. In preparation for this, a file named "miniaudio.c" has been added to repository. Currently this is just a simple wrapper around miniaudio.h and `MINIAUDIO_IMPLEMENTATION`. Nothing has changed in miniaudio.h, however when version 0.12 is released you will need to use miniaudio.c for the implementation. It's recommended you start the transition away from `MINIAUDIO_IMPLEMENTATION` and towards miniaudio.c. If you want to keep building your project as a single translation unit, you can do `#include "miniaudio.c"` which will continue to be supported with version 0.12 and beyond.
|
||||
|
||||
+262
-43
@@ -1,12 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(miniaudio
|
||||
VERSION 0.11
|
||||
)
|
||||
|
||||
# Extract version from miniaudio.h
|
||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h" MINIAUDIO_HEADER_CONTENTS)
|
||||
string(REGEX MATCH "#define MA_VERSION_MAJOR[ \t]+([0-9]+)" _major_match "${MINIAUDIO_HEADER_CONTENTS}")
|
||||
set(MA_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "#define MA_VERSION_MINOR[ \t]+([0-9]+)" _minor_match "${MINIAUDIO_HEADER_CONTENTS}")
|
||||
set(MA_VERSION_MINOR "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "#define MA_VERSION_REVISION[ \t]+([0-9]+)" _revision_match "${MINIAUDIO_HEADER_CONTENTS}")
|
||||
set(MA_VERSION_REVISION "${CMAKE_MATCH_1}")
|
||||
set(MINIAUDIO_VERSION "${MA_VERSION_MAJOR}.${MA_VERSION_MINOR}.${MA_VERSION_REVISION}")
|
||||
|
||||
project(miniaudio VERSION ${MINIAUDIO_VERSION})
|
||||
|
||||
|
||||
# Options
|
||||
option(MINIAUDIO_BUILD_EXAMPLES "Build miniaudio examples" OFF)
|
||||
option(MINIAUDIO_BUILD_TESTS "Build miniaudio tests" OFF)
|
||||
option(MINIAUDIO_BUILD_TOOLS "Build miniaudio development tools. Leave this disabled unless you know what you're doing. If you enable this and you get build errors, you clearly do not know what you're doing and yet you still enabled this option. Why would you do that?" OFF)
|
||||
option(MINIAUDIO_FORCE_CXX "Force compilation as C++" OFF)
|
||||
option(MINIAUDIO_FORCE_C89 "Force compilation as C89" OFF)
|
||||
option(MINIAUDIO_NO_EXTRA_NODES "Do not build extra node graph nodes" OFF)
|
||||
@@ -62,9 +72,31 @@ option(MINIAUDIO_USE_STDINT "Use <stdint.h> for sized types"
|
||||
option(MINIAUDIO_DEBUG_OUTPUT "Enable stdout debug output" OFF)
|
||||
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Construct compiler options.
|
||||
set(COMPILE_OPTIONS)
|
||||
|
||||
# Store libraries to install
|
||||
# When installing any header that imports miniaudio.h from a relative path, we
|
||||
# need to maintain its place in the directory tree so it can find Miniaudio
|
||||
set(LIBS_TO_INSTALL)
|
||||
|
||||
|
||||
# Special rules for Emscripten.
|
||||
#
|
||||
# - MINIAUDIO_FORCE_C89 is not supported.
|
||||
# - MINIAUDIO_NO_RUNTIME_LINKING must be enabled.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
||||
set(MINIAUDIO_FORCE_C89 OFF)
|
||||
set(MINIAUDIO_NO_RUNTIME_LINKING ON)
|
||||
|
||||
# This is a hack to work around some errors relating to generation of the pkg-config file.
|
||||
set(MINIAUDIO_ENABLE_ONLY_SPECIFIC_BACKENDS ON)
|
||||
set(MINIAUDIO_ENABLE_WEBAUDIO ON)
|
||||
endif()
|
||||
|
||||
|
||||
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()
|
||||
@@ -88,7 +120,7 @@ if(MINIAUDIO_FORCE_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.")
|
||||
message(WARNING "MINIAUDIO_FORCE_C89 is enabled but the compiler does not support it. Ignoring.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -149,6 +181,8 @@ if(MINIAUDIO_NO_NULL)
|
||||
list(APPEND COMPILE_DEFINES MA_NO_NULL)
|
||||
endif()
|
||||
if(MINIAUDIO_ENABLE_ONLY_SPECIFIC_BACKENDS)
|
||||
list(APPEND COMPILE_DEFINES MA_ENABLE_ONLY_SPECIFIC_BACKENDS)
|
||||
|
||||
if(MINIAUDIO_ENABLE_WASAPI)
|
||||
list(APPEND COMPILE_DEFINES MA_ENABLE_WASAPI)
|
||||
endif()
|
||||
@@ -312,15 +346,21 @@ endfunction()
|
||||
# vorbisfile
|
||||
#
|
||||
# The vorbisfile target is required for miniaudio_libvorbis. If the vorbisfile target has already been
|
||||
# defined we'll just use that. Otherwise we'll try to find_library(). If that fails, as a last resort
|
||||
# defined we'll just use that. Otherwise we'll try to use pkg-config. If that fails, as a last resort
|
||||
# we'll allow building it from source from the external/vorbis directory.
|
||||
if(NOT MINIAUDIO_NO_LIBVORBIS)
|
||||
if(NOT TARGET vorbisfile)
|
||||
find_library(LIBVORBISFILE NAMES vorbisfile)
|
||||
if(LIBVORBISFILE)
|
||||
message(STATUS "Found libvorbisfile: ${LIBVORBISFILE}")
|
||||
# Try pkg-config first
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_VORBISFILE vorbisfile)
|
||||
endif()
|
||||
|
||||
if(PC_VORBISFILE_FOUND)
|
||||
message(STATUS "Found vorbisfile via pkg-config: ${PC_VORBISFILE_LIBRARIES}")
|
||||
set(HAS_LIBVORBIS TRUE)
|
||||
else()
|
||||
# Fallback to building from source.
|
||||
add_libvorbis_subdirectory()
|
||||
if(NOT TARGET vorbisfile)
|
||||
message(STATUS "libvorbisfile not found. miniaudio_libvorbis will be excluded.")
|
||||
@@ -336,27 +376,20 @@ endif()
|
||||
|
||||
# opusfile
|
||||
#
|
||||
# This is the same as vorbisfile above.
|
||||
# This is the same as vorbisfile above, but for opusfile.
|
||||
if(NOT MINIAUDIO_NO_LIBOPUS)
|
||||
if(NOT TARGET opusfile)
|
||||
find_library(LIBOPUSFILE NAMES opusfile)
|
||||
if(LIBOPUSFILE)
|
||||
message(STATUS "Found libopusfile: ${LIBOPUSFILE}")
|
||||
# Try pkg-config first
|
||||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_OPUSFILE opusfile)
|
||||
endif()
|
||||
|
||||
# opusfile is very annoying because they do "#include <opus_multistream.h>" in opusfile.h which results
|
||||
# in an error unless we explicitly add the include path to the opus include directory.
|
||||
find_path(OPUSFILE_INCLUDE_DIR
|
||||
NAMES opus/opusfile.h
|
||||
DOC "Directory containing opusfile.h"
|
||||
)
|
||||
|
||||
if(OPUSFILE_INCLUDE_DIR)
|
||||
message(STATUS "Found opusfile.h in ${OPUSFILE_INCLUDE_DIR}")
|
||||
set(HAS_LIBOPUS TRUE)
|
||||
else()
|
||||
message(STATUS "Could not find opusfile.h. miniaudio_libopus will be excluded.")
|
||||
endif()
|
||||
if(PC_OPUSFILE_FOUND)
|
||||
message(STATUS "Found opusfile via pkg-config: ${PC_OPUSFILE_LIBRARIES}")
|
||||
set(HAS_LIBOPUS TRUE)
|
||||
else()
|
||||
# Fallback to building from source.
|
||||
add_libopusfile_subdirectory()
|
||||
if(NOT TARGET opusfile)
|
||||
message(STATUS "libopusfile not found. miniaudio_libopus will be excluded.")
|
||||
@@ -440,23 +473,43 @@ endif()
|
||||
set(COMMON_LINK_LIBRARIES)
|
||||
|
||||
if (UNIX)
|
||||
list(APPEND COMMON_LINK_LIBRARIES dl) # For dlopen(), etc. Most compilers will link to this by default, but some may not.
|
||||
list(APPEND COMMON_LINK_LIBRARIES pthread) # Some compilers will not link to pthread by default so list it here just in case.
|
||||
list(APPEND COMMON_LINK_LIBRARIES m)
|
||||
if(NOT MINIAUDIO_NO_RUNTIME_LINKING)
|
||||
# Not all platforms actually use a separate "dl" library, notably NetBSD and OpenBSD.
|
||||
find_library(LIB_DL NAMES dl)
|
||||
if(LIB_DL)
|
||||
list(APPEND COMMON_LINK_LIBRARIES ${LIB_DL}) # For dlopen(), etc. Most compilers will link to this by default, but some may not.
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_library(LIB_PTHREAD NAMES pthread)
|
||||
if(LIB_PTHREAD)
|
||||
list(APPEND COMMON_LINK_LIBRARIES ${LIB_PTHREAD}) # Some compilers will not link to pthread by default so list it here just in case.
|
||||
endif()
|
||||
|
||||
find_library(LIB_M NAMES m)
|
||||
if(LIB_M)
|
||||
list(APPEND COMMON_LINK_LIBRARIES ${LIB_M})
|
||||
endif()
|
||||
|
||||
# If we're compiling for 32-bit ARM we need to link to -latomic.
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
list(APPEND COMMON_LINK_LIBRARIES atomic)
|
||||
find_library(LIB_ATOMIC NAMES atomic)
|
||||
if(LIB_ATOMIC)
|
||||
list(APPEND COMMON_LINK_LIBRARIES ${LIB_ATOMIC})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Static Libraries
|
||||
add_library(miniaudio STATIC
|
||||
add_library(miniaudio
|
||||
miniaudio.c
|
||||
miniaudio.h
|
||||
)
|
||||
|
||||
list(APPEND LIBS_TO_INSTALL miniaudio)
|
||||
install(FILES miniaudio.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/miniaudio)
|
||||
|
||||
target_include_directories(miniaudio PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_options (miniaudio PRIVATE ${COMPILE_OPTIONS})
|
||||
target_compile_definitions(miniaudio PRIVATE ${COMPILE_DEFINES})
|
||||
@@ -466,17 +519,23 @@ add_library(libvorbis_interface INTERFACE)
|
||||
if(HAS_LIBVORBIS)
|
||||
if(TARGET vorbisfile)
|
||||
target_link_libraries(libvorbis_interface INTERFACE vorbisfile)
|
||||
else()
|
||||
target_link_libraries(libvorbis_interface INTERFACE ${LIBVORBISFILE})
|
||||
elseif(PC_VORBISFILE_FOUND)
|
||||
target_link_libraries (libvorbis_interface INTERFACE ${PC_VORBISFILE_LIBRARIES})
|
||||
target_include_directories(libvorbis_interface INTERFACE ${PC_VORBISFILE_INCLUDE_DIRS})
|
||||
target_link_directories (libvorbis_interface INTERFACE ${PC_VORBISFILE_LIBRARY_DIRS})
|
||||
target_compile_options (libvorbis_interface INTERFACE ${PC_VORBISFILE_CFLAGS_OTHER})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAS_LIBVORBIS)
|
||||
add_library(miniaudio_libvorbis STATIC
|
||||
add_library(miniaudio_libvorbis
|
||||
extras/decoders/libvorbis/miniaudio_libvorbis.c
|
||||
extras/decoders/libvorbis/miniaudio_libvorbis.h
|
||||
)
|
||||
|
||||
list(APPEND LIBS_TO_INSTALL miniaudio_libvorbis)
|
||||
install(FILES extras/decoders/libvorbis/miniaudio_libvorbis.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/miniaudio/extras/decoders/libvorbis)
|
||||
|
||||
target_compile_options (miniaudio_libvorbis PRIVATE ${COMPILE_OPTIONS})
|
||||
target_compile_definitions(miniaudio_libvorbis PRIVATE ${COMPILE_DEFINES})
|
||||
target_link_libraries (miniaudio_libvorbis PRIVATE libvorbis_interface)
|
||||
@@ -487,18 +546,24 @@ add_library(libopus_interface INTERFACE)
|
||||
if(HAS_LIBOPUS)
|
||||
if(TARGET opusfile)
|
||||
target_link_libraries (libopus_interface INTERFACE opusfile)
|
||||
else()
|
||||
target_link_libraries (libopus_interface INTERFACE ${LIBOPUSFILE})
|
||||
target_include_directories(libopus_interface INTERFACE ${OPUSFILE_INCLUDE_DIR}/opus)
|
||||
elseif(PC_OPUSFILE_FOUND)
|
||||
target_link_libraries (libopus_interface INTERFACE ${PC_OPUSFILE_LIBRARIES})
|
||||
target_include_directories(libopus_interface INTERFACE ${PC_OPUSFILE_INCLUDE_DIRS})
|
||||
target_link_directories (libopus_interface INTERFACE ${PC_OPUSFILE_LIBRARY_DIRS})
|
||||
target_compile_options (libopus_interface INTERFACE ${PC_OPUSFILE_CFLAGS_OTHER})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAS_LIBOPUS)
|
||||
add_library(miniaudio_libopus STATIC
|
||||
add_library(miniaudio_libopus
|
||||
extras/decoders/libopus/miniaudio_libopus.c
|
||||
extras/decoders/libopus/miniaudio_libopus.h
|
||||
)
|
||||
|
||||
|
||||
list(APPEND LIBS_TO_INSTALL miniaudio_libopus)
|
||||
install(FILES extras/decoders/libopus/miniaudio_libopus.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/miniaudio/extras/decoders/libopus)
|
||||
|
||||
target_compile_options (miniaudio_libopus PRIVATE ${COMPILE_OPTIONS})
|
||||
target_compile_definitions(miniaudio_libopus PRIVATE ${COMPILE_DEFINES})
|
||||
target_link_libraries (miniaudio_libopus PRIVATE libopus_interface)
|
||||
@@ -507,10 +572,16 @@ endif()
|
||||
|
||||
if (NOT MINIAUDIO_NO_EXTRA_NODES)
|
||||
function(add_extra_node name)
|
||||
add_library(miniaudio_${name}_node STATIC
|
||||
add_library(miniaudio_${name}_node
|
||||
extras/nodes/ma_${name}_node/ma_${name}_node.c
|
||||
extras/nodes/ma_${name}_node/ma_${name}_node.h
|
||||
)
|
||||
|
||||
set(libs "${LIBS_TO_INSTALL}")
|
||||
|
||||
list(APPEND libs miniaudio_${name}_node)
|
||||
set(LIBS_TO_INSTALL "${libs}" PARENT_SCOPE) # without PARENT_SCOPE, any changes are lost
|
||||
install(FILES extras/nodes/ma_${name}_node/ma_${name}_node.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/miniaudio/extras/nodes/ma_${name}_node)
|
||||
|
||||
target_include_directories(miniaudio_${name}_node PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extras/nodes/ma_${name}_node)
|
||||
target_compile_options (miniaudio_${name}_node PRIVATE ${COMPILE_OPTIONS})
|
||||
@@ -537,6 +608,98 @@ add_library(miniaudio_common_options INTERFACE)
|
||||
target_compile_options(miniaudio_common_options INTERFACE ${COMPILE_OPTIONS})
|
||||
target_link_libraries (miniaudio_common_options INTERFACE ${COMMON_LINK_LIBRARIES})
|
||||
|
||||
function(is_backend_enabled NAME)
|
||||
if (NOT MINIAUDIO_NO_${NAME} AND (NOT MINIAUDIO_ENABLE_ONLY_SPECIFIC_BACKENDS OR MINIAUDIO_ENABLE_${NAME}))
|
||||
set(${NAME}_ENABLED TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set(${NAME}_ENABLED FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(LINKED_LIBS)
|
||||
|
||||
if(MINIAUDIO_NO_RUNTIME_LINKING)
|
||||
is_backend_enabled(PULSEAUDIO)
|
||||
if (PULSEAUDIO_ENABLED)
|
||||
find_package(PulseAudio)
|
||||
|
||||
if (PulseAudio_FOUND)
|
||||
target_link_libraries(miniaudio PRIVATE ${PULSEAUDIO_LIBRARY})
|
||||
target_include_directories(miniaudio SYSTEM PRIVATE ${PULSEAUDIO_INCLUDE_DIR})
|
||||
list(APPEND LINKED_LIBS libpulse)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
is_backend_enabled(ALSA)
|
||||
if (ALSA_ENABLED)
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_ALSA alsa)
|
||||
endif()
|
||||
|
||||
find_library(ALSA_LIBRARY
|
||||
NAMES asound
|
||||
HINTS ${PC_ALSA_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if (ALSA_LIBRARY)
|
||||
find_path(ALSA_INCLUDE_DIR
|
||||
NAMES alsa/asoundlib.h
|
||||
HINTS ${PC_ALSA_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(miniaudio PRIVATE ${ALSA_LIBRARY})
|
||||
target_include_directories(miniaudio PRIVATE ${ALSA_INCLUDE_DIR})
|
||||
list(APPEND LINKED_LIBS alsa)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
is_backend_enabled(SNDIO)
|
||||
if (SNDIO_ENABLED)
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_SNDIO sndio)
|
||||
endif()
|
||||
|
||||
find_library(SNDIO_LIBRARY
|
||||
NAMES sndio
|
||||
HINTS ${PC_SNDIO_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if (SNDIO_LIBRARY)
|
||||
target_link_libraries(miniaudio PRIVATE ${SNDIO_LIBRARY})
|
||||
list(APPEND LINKED_LIBS sndio)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
is_backend_enabled(JACK)
|
||||
if (JACK_ENABLED)
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_JACK jack)
|
||||
endif()
|
||||
|
||||
find_library(JACK_LIBRARY
|
||||
NAMES jack
|
||||
HINTS ${PC_JACK_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if (JACK_LIBRARY)
|
||||
find_path(JACK_INCLUDE_DIR
|
||||
NAMES jack/jack.h
|
||||
HINTS ${PC_JACK_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(miniaudio PRIVATE ${JACK_LIBRARY})
|
||||
target_include_directories(miniaudio PRIVATE ${JACK_INCLUDE_DIR})
|
||||
list(APPEND LINKED_LIBS jack)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Tests
|
||||
#
|
||||
# All tests are compiled as a single translation unit. There is no need to add miniaudio as a link library.
|
||||
@@ -550,15 +713,18 @@ if(MINIAUDIO_BUILD_TESTS)
|
||||
target_link_libraries(${name} PRIVATE miniaudio_common_options)
|
||||
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.
|
||||
add_miniaudio_test(miniaudio_debugging debugging/debugging.cpp)
|
||||
# Disable C++ tests when forcing C89. This is needed because we'll be passing -std=c89 which will cause errors when trying to compile a C++ file.
|
||||
if(NOT MINIAUDIO_FORCE_C89)
|
||||
# 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.
|
||||
add_miniaudio_test(miniaudio_debugging debugging/debugging.cpp)
|
||||
|
||||
add_miniaudio_test(miniaudio_cpp cpp/cpp.cpp)
|
||||
add_test(NAME miniaudio_cpp COMMAND miniaudio_cpp --auto) # This is just the deviceio test.
|
||||
endif()
|
||||
|
||||
add_miniaudio_test(miniaudio_deviceio deviceio/deviceio.c)
|
||||
add_test(NAME miniaudio_deviceio COMMAND miniaudio_deviceio --auto)
|
||||
|
||||
add_miniaudio_test(miniaudio_cpp cpp/cpp.cpp)
|
||||
add_test(NAME miniaudio_cpp COMMAND miniaudio_cpp --auto) # This is just the deviceio test.
|
||||
|
||||
add_miniaudio_test(miniaudio_conversion conversion/conversion.c)
|
||||
add_test(NAME miniaudio_conversion COMMAND miniaudio_conversion)
|
||||
|
||||
@@ -645,3 +811,56 @@ if (MINIAUDIO_BUILD_EXAMPLES)
|
||||
add_miniaudio_example(miniaudio_simple_playback simple_playback.c)
|
||||
add_miniaudio_example(miniaudio_simple_spatialization simple_spatialization.c)
|
||||
endif()
|
||||
|
||||
|
||||
# Tools
|
||||
if (MINIAUDIO_BUILD_TOOLS)
|
||||
set(TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools)
|
||||
|
||||
add_executable(madoc ${TOOLS_DIR}/madoc/madoc.c)
|
||||
endif()
|
||||
|
||||
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(MINIAUDIO_PC_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(MINIAUDIO_PC_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(MINIAUDIO_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(MINIAUDIO_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
string(JOIN ", " MINIAUDIO_PC_REQUIRES_PRIVATE ${LINKED_LIBS})
|
||||
|
||||
# Add vorbisfile and opusfile to pkg-config dependencies if found via pkg-config
|
||||
set(PC_REQUIRES_PRIVATE_LIST)
|
||||
if(PC_VORBISFILE_FOUND AND HAS_LIBVORBIS)
|
||||
list(APPEND PC_REQUIRES_PRIVATE_LIST "vorbisfile")
|
||||
endif()
|
||||
if(PC_OPUSFILE_FOUND AND HAS_LIBOPUS)
|
||||
list(APPEND PC_REQUIRES_PRIVATE_LIST "opusfile")
|
||||
endif()
|
||||
if(PC_REQUIRES_PRIVATE_LIST)
|
||||
if(MINIAUDIO_PC_REQUIRES_PRIVATE)
|
||||
string(APPEND MINIAUDIO_PC_REQUIRES_PRIVATE ", ")
|
||||
endif()
|
||||
string(JOIN ", " PC_REQUIRES_STR ${PC_REQUIRES_PRIVATE_LIST})
|
||||
string(APPEND MINIAUDIO_PC_REQUIRES_PRIVATE "${PC_REQUIRES_STR}")
|
||||
endif()
|
||||
list(TRANSFORM COMMON_LINK_LIBRARIES PREPEND "-l")
|
||||
string(JOIN " " MINIAUDIO_PC_LIBS_PRIVATE ${COMMON_LINK_LIBRARIES})
|
||||
list(TRANSFORM COMPILE_DEFINES PREPEND "-D")
|
||||
string(JOIN " " MINIAUDIO_PC_CFLAGS ${COMPILE_DEFINES})
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/miniaudio.pc" @ONLY)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/miniaudio.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
message(STATUS "Library list: ${LIBS_TO_INSTALL}")
|
||||
install(TARGETS ${LIBS_TO_INSTALL}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/9vpqbjU"><img src="https://img.shields.io/discord/712952679415939085?label=discord&logo=discord&style=flat-square" alt="discord"></a>
|
||||
<a href="https://fosstodon.org/@mackron"><img src="https://img.shields.io/mastodon/follow/109293691403797709?color=blue&domain=https%3A%2F%2Ffosstodon.org&label=mastodon&logo=mastodon&style=flat-square" alt="mastodon"></a>
|
||||
<a href="https://x.com/mackron"><img alt="x" src="https://img.shields.io/twitter/url?url=https%3A%2F%2Fx.com%2Fmackron&style=flat-square&logo=x&label=%40mackron"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -33,7 +33,7 @@ Features
|
||||
- High-level API for sound management, mixing, effects and optional 3D spatialization.
|
||||
- Flexible node graph system for advanced mixing and effect processing.
|
||||
- Resource management for loading sound files.
|
||||
- Decoding, with built-in support for WAV, FLAC and MP3, in addition to being able to plug in custom decoders.
|
||||
- Decoding, with built-in support for WAV, FLAC, and MP3, in addition to being able to plug in custom decoders.
|
||||
- Encoding (WAV only).
|
||||
- Data conversion.
|
||||
- Resampling, including custom resamplers.
|
||||
@@ -51,7 +51,7 @@ Examples
|
||||
This example shows one way to play a sound using the high level API.
|
||||
|
||||
```c
|
||||
#include "miniaudio.h"
|
||||
#include "miniaudio/miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -79,7 +79,7 @@ int main()
|
||||
This example shows how to decode and play a sound using the low level API.
|
||||
|
||||
```c
|
||||
#include "miniaudio.h"
|
||||
#include "miniaudio/miniaudio.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -207,7 +207,7 @@ Security
|
||||
========
|
||||
I deal with all security related issues publicly and transparently, and it can sometimes take a while before I
|
||||
get a chance to address it. If this is an issue for you, you need to use another library. The fastest way to get
|
||||
a bug fixed is to submit a pull request, but if this is unpractical for you please post a ticket to the public
|
||||
a bug fixed is to submit a pull request, but if this is impractical for you please post a ticket to the public
|
||||
GitHub issue tracker.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
miniaudio_h := <../miniaudio.h>;
|
||||
miniaudio_c := <../miniaudio.c>;
|
||||
|
||||
cleanup :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["\r\n"] <= "\n" // Normalize line endings to "\n". Needed for very old versions of GCC.
|
||||
["\t"] <= " " // Tabs to spaces.
|
||||
;
|
||||
}
|
||||
|
||||
miniaudio_h = cleanup(@(miniaudio_h));
|
||||
miniaudio_c = cleanup(@(miniaudio_c));
|
||||
@@ -0,0 +1,289 @@
|
||||
miniaudio_h := <../miniaudio.h>;
|
||||
miniaudio_c := <../miniaudio.c>;
|
||||
dr_wav_h :: <../../dr_libs/dr_wav.h>;
|
||||
dr_flac_h :: <../../dr_libs/dr_flac.h>;
|
||||
dr_mp3_h :: <../../dr_libs/dr_mp3.h>;
|
||||
c89atomic_h :: <../../c89atomic/c89atomic.h>;
|
||||
c89atomic_c :: <../../c89atomic/c89atomic.c>;
|
||||
|
||||
minify :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["/\*[^*]*\*+(?:[^/*][^*]*\*+)*/"] <= "" // Remove all block comments to keep things clean.
|
||||
["(?m)^\s*\R"] <= "" // Remove all empty lines to compress it all down.
|
||||
["[ \t]+(?=(?:\R|$))"] <= "" // Remove trailing whitespace.
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
// dr_wav
|
||||
rename_wav_namespace :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["\bdrwav"] <= "ma_dr_wav"
|
||||
["\bDRWAV"] <= "MA_DR_WAV"
|
||||
["\bdr_wav"] <= "ma_dr_wav"
|
||||
["\bDR_WAV"] <= "MA_DR_WAV"
|
||||
["\bg_drwav"] <= "ma_dr_wav_g"
|
||||
|
||||
// Some common tokens will be namespaced as "ma_dr_wav" when we really want them to be "ma_".
|
||||
["\bma_dr_wav_int"] <= "ma_int"
|
||||
["\bma_dr_wav_uint"] <= "ma_uint"
|
||||
["\bma_dr_wav_bool"] <= "ma_bool"
|
||||
["\bma_dr_wav_uintptr"] <= "ma_uintptr"
|
||||
["\bMA_DR_WAV_TRUE"] <= "MA_TRUE"
|
||||
["\bMA_DR_WAV_FALSE"] <= "MA_FALSE"
|
||||
["\bMA_DR_WAV_UINT64_MAX"] <= "MA_UINT64_MAX"
|
||||
["\bMA_DR_WAV_32BIT"] <= "MA_32BIT"
|
||||
["\bMA_DR_WAV_64BIT"] <= "MA_64BIT"
|
||||
["\bMA_DR_WAV_ARM32"] <= "MA_ARM32"
|
||||
["\bMA_DR_WAV_ARM64"] <= "MA_ARM64"
|
||||
["\bMA_DR_WAV_X64"] <= "MA_X64"
|
||||
["\bMA_DR_WAV_X86"] <= "MA_X86"
|
||||
["\bMA_DR_WAV_ARM"] <= "MA_ARM"
|
||||
["\bMA_DR_WAV_API"] <= "MA_API"
|
||||
["\bMA_DR_WAV_PRIVATE"] <= "MA_PRIVATE"
|
||||
["\bMA_DR_WAV_DLL"] <= "MA_DLL"
|
||||
["\bMA_DR_WAV_DLL_IMPORT"] <= "MA_DLL_IMPORT"
|
||||
["\bMA_DR_WAV_DLL_EXPORT"] <= "MA_DLL_EXPORT"
|
||||
["\bMA_DR_WAV_DLL_PRIVATE"] <= "MA_DLL_PRIVATE"
|
||||
["\bma_dr_wav_result"] <= "ma_result"
|
||||
["\bma_dr_wav_allocation_callbacks"] <= "ma_allocation_callbacks"
|
||||
["\bMA_DR_WAV_INLINE"] <= "MA_INLINE"
|
||||
["\bMA_DR_WAV_SIZE_MAX"] <= "MA_SIZE_MAX"
|
||||
["\bma_dr_wav_result_from_errno"] <= "ma_result_from_errno"
|
||||
["\bma_dr_wav_fopen"] <= "ma_fopen"
|
||||
["\bma_dr_wav_wfopen"] <= "ma_wfopen"
|
||||
|
||||
// Result codes.
|
||||
["MA_DR_WAV_SUCCESS"] <= "MA_SUCCESS"
|
||||
["MA_DR_WAV_INVALID_ARGS"] <= "MA_INVALID_ARGS"
|
||||
["MA_DR_WAV_OUT_OF_MEMORY"] <= "MA_OUT_OF_MEMORY"
|
||||
["MA_DR_WAV_INVALID_FILE"] <= "MA_INVALID_FILE"
|
||||
["MA_DR_WAV_AT_END"] <= "MA_AT_END"
|
||||
["MA_DR_WAV_BAD_SEEK"] <= "MA_BAD_SEEK"
|
||||
;
|
||||
}
|
||||
|
||||
convert_wav_h :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* Sized Types \*/\R" : "\R/\* End Sized Types \*/" ] = "";
|
||||
stripped["/\* Decorations \*/\R" : "\R/\* End Decorations \*/" ] = "";
|
||||
stripped["/\* Result Codes \*/\R" : "\R/\* End Result Codes \*/" ] = "";
|
||||
stripped["/\* Allocation Callbacks \*/\R" : "\R/\* End Allocation Callbacks \*/" ] = "";
|
||||
|
||||
return minify(rename_wav_namespace(stripped));
|
||||
}
|
||||
|
||||
convert_wav_c :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* Architecture Detection \*/\R" : "\R/\* End Architecture Detection \*/"] = "";
|
||||
stripped["/\* Inline \*/\R" : "\R/\* End Inline \*/" ] = "";
|
||||
stripped["/\* SIZE_MAX \*/\R" : "\R/\* End SIZE_MAX \*/" ] = "";
|
||||
stripped["/\* Errno \*/\R" : "\R/\* End Errno \*/" ] = "";
|
||||
stripped["/\* fopen \*/\R" : "\R/\* End fopen \*/" ] = "";
|
||||
|
||||
return minify(rename_wav_namespace(stripped));
|
||||
}
|
||||
|
||||
miniaudio_h("/\* dr_wav_h begin \*/\R":"\R/\* dr_wav_h end \*/") = convert_wav_h(@(dr_wav_h["#ifndef dr_wav_h\R":"\R#endif /\* dr_wav_h \*/"]));
|
||||
miniaudio_h("/\* dr_wav_c begin \*/\R":"\R/\* dr_wav_c end \*/") = convert_wav_c(@(dr_wav_h["#ifndef dr_wav_c\R":"\R#endif /\* dr_wav_c \*/"]));
|
||||
|
||||
|
||||
// dr_flac
|
||||
rename_flac_namespace :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["\bdrflac"] <= "ma_dr_flac"
|
||||
["\bDRFLAC"] <= "MA_DR_FLAC"
|
||||
["\bdr_flac"] <= "ma_dr_flac"
|
||||
["\bDR_FLAC"] <= "MA_DR_FLAC"
|
||||
["\bg_drflac"] <= "ma_dr_flac_g"
|
||||
|
||||
// Some common tokens will be namespaced as "ma_dr_flac" when we really want them to be "ma_".
|
||||
["\bma_dr_flac_int"] <= "ma_int"
|
||||
["\bma_dr_flac_uint"] <= "ma_uint"
|
||||
["\bma_dr_flac_bool"] <= "ma_bool"
|
||||
["\bma_dr_flac_uintptr"] <= "ma_uintptr"
|
||||
["\bMA_DR_FLAC_TRUE"] <= "MA_TRUE"
|
||||
["\bMA_DR_FLAC_FALSE"] <= "MA_FALSE"
|
||||
["\bMA_DR_FLAC_UINT64_MAX"] <= "MA_UINT64_MAX"
|
||||
["\bMA_DR_FLAC_32BIT"] <= "MA_32BIT"
|
||||
["\bMA_DR_FLAC_64BIT"] <= "MA_64BIT"
|
||||
["\bMA_DR_FLAC_ARM32"] <= "MA_ARM32"
|
||||
["\bMA_DR_FLAC_ARM64"] <= "MA_ARM64"
|
||||
["\bMA_DR_FLAC_X64"] <= "MA_X64"
|
||||
["\bMA_DR_FLAC_X86"] <= "MA_X86"
|
||||
["\bMA_DR_FLAC_ARM"] <= "MA_ARM"
|
||||
["\bMA_DR_FLAC_API"] <= "MA_API"
|
||||
["\bMA_DR_FLAC_PRIVATE"] <= "MA_PRIVATE"
|
||||
["\bMA_DR_FLAC_DLL"] <= "MA_DLL"
|
||||
["\bMA_DR_FLAC_DLL_IMPORT"] <= "MA_DLL_IMPORT"
|
||||
["\bMA_DR_FLAC_DLL_EXPORT"] <= "MA_DLL_EXPORT"
|
||||
["\bMA_DR_FLAC_DLL_PRIVATE"] <= "MA_DLL_PRIVATE"
|
||||
["\bma_dr_flac_result"] <= "ma_result"
|
||||
["\bma_dr_flac_allocation_callbacks"] <= "ma_allocation_callbacks"
|
||||
["\bMA_DR_FLAC_INLINE"] <= "MA_INLINE"
|
||||
["\bMA_DR_FLAC_SIZE_MAX"] <= "MA_SIZE_MAX"
|
||||
["\bma_dr_flac_result_from_errno"] <= "ma_result_from_errno"
|
||||
["\bma_dr_flac_fopen"] <= "ma_fopen"
|
||||
["\bma_dr_flac_wfopen"] <= "ma_wfopen"
|
||||
|
||||
// Result codes.
|
||||
["MA_DR_FLAC_SUCCESS"] <= "MA_SUCCESS"
|
||||
["MA_DR_FLAC_ERROR"] <= "MA_ERROR"
|
||||
["MA_DR_FLAC_AT_END"] <= "MA_AT_END"
|
||||
["MA_DR_FLAC_CRC_MISMATCH"] <= "MA_CRC_MISMATCH"
|
||||
;
|
||||
}
|
||||
|
||||
convert_flac_h :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* Sized Types \*/\R" : "\R/\* End Sized Types \*/" ] = "";
|
||||
stripped["/\* Architecture Detection \*/\R" : "\R/\* End Architecture Detection \*/"] = "";
|
||||
stripped["/\* Decorations \*/\R" : "\R/\* End Decorations \*/" ] = "";
|
||||
stripped["/\* Allocation Callbacks \*/\R" : "\R/\* End Allocation Callbacks \*/" ] = "";
|
||||
|
||||
return minify(rename_flac_namespace(stripped));
|
||||
}
|
||||
|
||||
convert_flac_c :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* Result Codes \*/\R" : "\R/\* End Result Codes \*/" ] = "";
|
||||
stripped["/\* Inline \*/\R" : "\R/\* End Inline \*/" ] = "";
|
||||
stripped["/\* SIZE_MAX \*/\R" : "\R/\* End SIZE_MAX \*/" ] = "";
|
||||
stripped["/\* Errno \*/\R" : "\R/\* End Errno \*/" ] = "";
|
||||
stripped["/\* fopen \*/\R" : "\R/\* End fopen \*/" ] = "";
|
||||
|
||||
return minify(rename_flac_namespace(stripped));
|
||||
}
|
||||
|
||||
miniaudio_h("/\* dr_flac_h begin \*/\R":"\R/\* dr_flac_h end \*/") = convert_flac_h(@(dr_flac_h["#ifndef dr_flac_h\R":"\R#endif /\* dr_flac_h \*/"]));
|
||||
miniaudio_h("/\* dr_flac_c begin \*/\R":"\R/\* dr_flac_c end \*/") = convert_flac_c(@(dr_flac_h["#ifndef dr_flac_c\R":"\R#endif /\* dr_flac_c \*/"]));
|
||||
|
||||
|
||||
|
||||
// dr_mp3
|
||||
rename_mp3_namespace :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["\bdrmp3"] <= "ma_dr_mp3"
|
||||
["\bDRMP3"] <= "MA_DR_MP3"
|
||||
["\bdr_mp3"] <= "ma_dr_mp3"
|
||||
["\bDR_MP3"] <= "MA_DR_MP3"
|
||||
["\bg_drmp3"] <= "ma_dr_mp3_g"
|
||||
|
||||
// Some common tokens will be namespaced as "ma_dr_mp3" when we really want them to be "ma_".
|
||||
["\bma_dr_mp3_int"] <= "ma_int"
|
||||
["\bma_dr_mp3_uint"] <= "ma_uint"
|
||||
["\bma_dr_mp3_bool"] <= "ma_bool"
|
||||
["\bma_dr_mp3_uintptr"] <= "ma_uintptr"
|
||||
["\bMA_DR_MP3_TRUE"] <= "MA_TRUE"
|
||||
["\bMA_DR_MP3_FALSE"] <= "MA_FALSE"
|
||||
["\bMA_DR_MP3_UINT64_MAX"] <= "MA_UINT64_MAX"
|
||||
["\bMA_DR_MP3_32BIT"] <= "MA_32BIT"
|
||||
["\bMA_DR_MP3_64BIT"] <= "MA_64BIT"
|
||||
["\bMA_DR_MP3_ARM32"] <= "MA_ARM32"
|
||||
["\bMA_DR_MP3_ARM64"] <= "MA_ARM64"
|
||||
["\bMA_DR_MP3_X64"] <= "MA_X64"
|
||||
["\bMA_DR_MP3_X86"] <= "MA_X86"
|
||||
["\bMA_DR_MP3_ARM"] <= "MA_ARM"
|
||||
["\bMA_DR_MP3_API"] <= "MA_API"
|
||||
["\bMA_DR_MP3_PRIVATE"] <= "MA_PRIVATE"
|
||||
["\bMA_DR_MP3_DLL"] <= "MA_DLL"
|
||||
["\bMA_DR_MP3_DLL_IMPORT"] <= "MA_DLL_IMPORT"
|
||||
["\bMA_DR_MP3_DLL_EXPORT"] <= "MA_DLL_EXPORT"
|
||||
["\bMA_DR_MP3_DLL_PRIVATE"] <= "MA_DLL_PRIVATE"
|
||||
["\bma_dr_mp3_result"] <= "ma_result"
|
||||
["\bma_dr_mp3_allocation_callbacks"] <= "ma_allocation_callbacks"
|
||||
["\bMA_DR_MP3_INLINE"] <= "MA_INLINE"
|
||||
["\bMA_DR_MP3_SIZE_MAX"] <= "MA_SIZE_MAX"
|
||||
["\bma_dr_mp3_result_from_errno"] <= "ma_result_from_errno"
|
||||
["\bma_dr_mp3_fopen"] <= "ma_fopen"
|
||||
["\bma_dr_mp3_wfopen"] <= "ma_wfopen"
|
||||
|
||||
// Result codes.
|
||||
["MA_DR_MP3_SUCCESS"] <= "MA_SUCCESS"
|
||||
;
|
||||
}
|
||||
|
||||
convert_mp3_h :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* Sized Types \*/\R" : "\R/\* End Sized Types \*/" ] = "";
|
||||
stripped["/\* Decorations \*/\R" : "\R/\* End Decorations \*/" ] = "";
|
||||
stripped["/\* Result Codes \*/\R" : "\R/\* End Result Codes \*/" ] = "";
|
||||
stripped["/\* Inline \*/\R" : "\R/\* End Inline \*/" ] = "";
|
||||
stripped["/\* Allocation Callbacks \*/\R" : "\R/\* End Allocation Callbacks \*/" ] = "";
|
||||
|
||||
return minify(rename_mp3_namespace(stripped));
|
||||
}
|
||||
|
||||
convert_mp3_c :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* SIZE_MAX \*/\R" : "\R/\* End SIZE_MAX \*/" ] = "";
|
||||
stripped["/\* Errno \*/\R" : "\R/\* End Errno \*/" ] = "";
|
||||
stripped["/\* fopen \*/\R" : "\R/\* End fopen \*/" ] = "";
|
||||
|
||||
return minify(rename_mp3_namespace(stripped));
|
||||
}
|
||||
|
||||
miniaudio_h("/\* dr_mp3_h begin \*/\R":"\R/\* dr_mp3_h end \*/") = convert_mp3_h(@(dr_mp3_h["#ifndef dr_mp3_h\R":"\R#endif /\* dr_mp3_h \*/"]));
|
||||
miniaudio_h("/\* dr_mp3_c begin \*/\R":"\R/\* dr_mp3_c end \*/") = convert_mp3_c(@(dr_mp3_h["#ifndef dr_mp3_c\R":"\R#endif /\* dr_mp3_c \*/"]));
|
||||
|
||||
|
||||
// c89atomic
|
||||
rename_c89atomic_namespace :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["\bc89atomic"] <= "ma_atomic"
|
||||
["\bC89ATOMIC"] <= "MA_ATOMIC"
|
||||
|
||||
// Some common tokens will be namespaced as "ma_atomic" when we really want them to be "ma_".
|
||||
["\bma_atomic_int"] <= "ma_int"
|
||||
["\bma_atomic_uint"] <= "ma_uint"
|
||||
["\bma_atomic_bool"] <= "ma_bool32"
|
||||
["\bMA_ATOMIC_32BIT"] <= "MA_32BIT"
|
||||
["\bMA_ATOMIC_64BIT"] <= "MA_64BIT"
|
||||
["\bMA_ATOMIC_ARM32"] <= "MA_ARM32"
|
||||
["\bMA_ATOMIC_ARM64"] <= "MA_ARM64"
|
||||
["\bMA_ATOMIC_X64"] <= "MA_X64"
|
||||
["\bMA_ATOMIC_X86"] <= "MA_X86"
|
||||
["\bMA_ATOMIC_ARM"] <= "MA_ARM"
|
||||
["\bMA_ATOMIC_INLINE"] <= "MA_INLINE"
|
||||
|
||||
// We have an "extern c89atomic_spinlock" in c89atomic.h, but since we're putting this into the implementation section we can just
|
||||
// drop the extern and not bother importing anything from c89atomic.c.
|
||||
["\bextern ma_atomic_spinlock"] <= "ma_atomic_spinlock"
|
||||
;
|
||||
}
|
||||
|
||||
convert_c89atomic_h :: function(src:string) string
|
||||
{
|
||||
stripped := @(src);
|
||||
stripped["/\* Sized Types \*/\R" : "\R/\* End Sized Types \*/" ] = "";
|
||||
stripped["/\* Architecture Detection \*/\R" : "\R/\* End Architecture Detection \*/"] = "";
|
||||
stripped["/\* Inline \*/\R" : "\R/\* End Inline \*/" ] = "";
|
||||
|
||||
return minify(rename_c89atomic_namespace(stripped));
|
||||
}
|
||||
|
||||
miniaudio_h("/\* c89atomic.h begin \*/\R":"\R/\* c89atomic.h end \*/") = convert_c89atomic_h(@(c89atomic_h["#ifndef c89atomic_h\R":"\R#endif /\* c89atomic_h \*/"]));
|
||||
|
||||
|
||||
// Cleanup. If we don't normalize line endings we'll fail to compile on old versions of GCC.
|
||||
cleanup :: function(src:string) string
|
||||
{
|
||||
return @(src)
|
||||
["\r\n"] <= "\n" // Normalize line endings to "\n". Needed for very old versions of GCC.
|
||||
["\t"] <= " " // Tabs to spaces.
|
||||
;
|
||||
}
|
||||
|
||||
miniaudio_h = cleanup(@(miniaudio_h));
|
||||
miniaudio_c = cleanup(@(miniaudio_c));
|
||||
@@ -0,0 +1,26 @@
|
||||
miniaudio_h :: <../miniaudio.h>;
|
||||
miniaudio_split_h := <../extras/miniaudio_split/miniaudio.h>;
|
||||
miniaudio_split_c := <../extras/miniaudio_split/miniaudio.c>;
|
||||
|
||||
header := @(miniaudio_h["/\*" : "\*/"]);
|
||||
footer := @(miniaudio_h["/\*\RThis software" : "\*/"]);
|
||||
|
||||
content_h : string;
|
||||
content_h["$"] = header;
|
||||
content_h["$"] = "\n";
|
||||
content_h["$"] = @(miniaudio_h["#ifndef miniaudio_h" : "#endif /\* miniaudio_h \*/"]);
|
||||
content_h["$"] = "\n\n";
|
||||
content_h["$"] = footer;
|
||||
content_h["$"] = "\n";
|
||||
|
||||
content_c : string;
|
||||
content_c["$"] = header;
|
||||
content_c["$"] = "\n";
|
||||
content_c["$"] = '#include "miniaudio.h"\n\n';
|
||||
content_c["$"] = @(miniaudio_h["#ifndef miniaudio_c" : "#endif /\* miniaudio_c \*/"]);
|
||||
content_c["$"] = "\n\n";
|
||||
content_c["$"] = footer;
|
||||
content_c["$"] = "\n";
|
||||
|
||||
miniaudio_split_h = content_h;
|
||||
miniaudio_split_c = content_c;
|
||||
@@ -72,5 +72,8 @@ int main(int argc, char** argv)
|
||||
printf("Press Enter to quit...");
|
||||
getchar();
|
||||
|
||||
ma_engine_uninit(&engine);
|
||||
ma_resource_manager_uninit(&resourceManager);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,12 @@ static ma_sound g_sound; /* This example will play only a single soun
|
||||
|
||||
void data_callback(void* pUserData, ma_uint8* pBuffer, int bufferSizeInBytes)
|
||||
{
|
||||
ma_uint32 bufferSizeInFrames;
|
||||
|
||||
(void)pUserData;
|
||||
|
||||
/* Reading is just a matter of reading straight from the engine. */
|
||||
ma_uint32 bufferSizeInFrames = (ma_uint32)bufferSizeInBytes / ma_get_bytes_per_frame(ma_format_f32, ma_engine_get_channels(&g_engine));
|
||||
bufferSizeInFrames = (ma_uint32)bufferSizeInBytes / ma_get_bytes_per_frame(ma_format_f32, ma_engine_get_channels(&g_engine));
|
||||
ma_engine_read_pcm_frames(&g_engine, pBuffer, bufferSizeInFrames, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,17 @@ of buffering solution to your node.
|
||||
#include "../miniaudio.c"
|
||||
|
||||
#include <stdint.h> /* Required for uint32_t which is used by STEAMAUDIO_VERSION, and a random use of uint8_t. If there's a Steam Audio maintainer reading this, that needs to be fixed to use IPLuint32 and IPLuint8. */
|
||||
|
||||
/* Need to silence some warnings from the Steam Audio headers. */
|
||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
#include <phonon.h> /* Steam Audio */
|
||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#define FORMAT ma_format_f32 /* Must be floating point. */
|
||||
#define CHANNELS 2 /* Must be stereo for this example. */
|
||||
|
||||
@@ -67,7 +67,7 @@ int main(int argc, char** argv)
|
||||
/* Rotate the listener on the spot to create an orbiting effect. */
|
||||
for (;;) {
|
||||
listenerAngle += 0.01f;
|
||||
ma_engine_listener_set_direction(&engine, 0, sinf(listenerAngle), 0, cosf(listenerAngle));
|
||||
ma_engine_listener_set_direction(&engine, 0, (float)sin(listenerAngle), 0, (float)cos(listenerAngle));
|
||||
|
||||
ma_sleep(1);
|
||||
}
|
||||
|
||||
Vendored
+4404
-2240
File diff suppressed because it is too large
Load Diff
Vendored
+2598
-260
File diff suppressed because it is too large
Load Diff
@@ -112,9 +112,6 @@ static long ma_libvorbis_vf_callback__tell(void* pUserData)
|
||||
|
||||
static ma_result ma_libvorbis_init_internal(const ma_decoding_backend_config* pConfig, const ma_allocation_callbacks* pAllocationCallbacks, ma_libvorbis* pVorbis)
|
||||
{
|
||||
ma_result result;
|
||||
ma_data_source_config dataSourceConfig;
|
||||
|
||||
if (pVorbis == NULL) {
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
@@ -128,16 +125,19 @@ static ma_result ma_libvorbis_init_internal(const ma_decoding_backend_config* pC
|
||||
/* Getting here means something other than f32 and s16 was specified. Just leave this unset to use the default format. */
|
||||
}
|
||||
|
||||
dataSourceConfig = ma_data_source_config_init();
|
||||
dataSourceConfig.vtable = &g_ma_libvorbis_ds_vtable;
|
||||
|
||||
result = ma_data_source_init(&dataSourceConfig, &pVorbis->ds);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result; /* Failed to initialize the base data source. */
|
||||
}
|
||||
|
||||
#if !defined(MA_NO_LIBVORBIS)
|
||||
{
|
||||
ma_result result;
|
||||
ma_data_source_config dataSourceConfig;
|
||||
|
||||
dataSourceConfig = ma_data_source_config_init();
|
||||
dataSourceConfig.vtable = &g_ma_libvorbis_ds_vtable;
|
||||
|
||||
result = ma_data_source_init(&dataSourceConfig, &pVorbis->ds);
|
||||
if (result != MA_SUCCESS) {
|
||||
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);
|
||||
@@ -160,16 +160,16 @@ MA_API ma_result ma_libvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_
|
||||
ma_result result;
|
||||
|
||||
(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libvorbis. */
|
||||
|
||||
if (onRead == NULL || onSeek == NULL) {
|
||||
return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */
|
||||
}
|
||||
|
||||
result = ma_libvorbis_init_internal(pConfig, pAllocationCallbacks, pVorbis);
|
||||
if (result != MA_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (onRead == NULL || onSeek == NULL) {
|
||||
return MA_INVALID_ARGS; /* onRead and onSeek are mandatory. */
|
||||
}
|
||||
|
||||
pVorbis->onRead = onRead;
|
||||
pVorbis->onSeek = onSeek;
|
||||
pVorbis->onTell = onTell;
|
||||
@@ -188,6 +188,8 @@ MA_API ma_result ma_libvorbis_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_
|
||||
|
||||
libvorbisResult = ov_open_callbacks(pVorbis, (OggVorbis_File*)pVorbis->vf, NULL, 0, libvorbisCallbacks);
|
||||
if (libvorbisResult < 0) {
|
||||
ma_data_source_uninit(&pVorbis->ds);
|
||||
ma_free(pVorbis->vf, pAllocationCallbacks);
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
@@ -218,6 +220,8 @@ MA_API ma_result ma_libvorbis_init_file(const char* pFilePath, const ma_decoding
|
||||
|
||||
libvorbisResult = ov_fopen(pFilePath, (OggVorbis_File*)pVorbis->vf);
|
||||
if (libvorbisResult < 0) {
|
||||
ma_data_source_uninit(&pVorbis->ds);
|
||||
ma_free(pVorbis->vf, pAllocationCallbacks);
|
||||
return MA_INVALID_FILE;
|
||||
}
|
||||
|
||||
@@ -482,8 +486,21 @@ MA_API ma_result ma_libvorbis_get_length_in_pcm_frames(ma_libvorbis* pVorbis, ma
|
||||
|
||||
#if !defined(MA_NO_LIBVORBIS)
|
||||
{
|
||||
/* I don't know how to reliably retrieve the length in frames using libvorbis, so returning 0 for now. */
|
||||
*pLength = 0;
|
||||
/*
|
||||
Will work in the supermajority of cases where a file has a single logical bitstream. Concatenated streams
|
||||
are much harder to determine the length of since they can have sample rate changes, but they should be
|
||||
extremely rare outside of unseekable livestreams anyway.
|
||||
*/
|
||||
if (ov_streams((OggVorbis_File*)pVorbis->vf) == 1) {
|
||||
ogg_int64_t length = ov_pcm_total((OggVorbis_File*)pVorbis->vf, 0);
|
||||
if(length != OV_EINVAL) {
|
||||
*pLength = (ma_uint64)length;
|
||||
} else {
|
||||
/* Unseekable. */
|
||||
}
|
||||
} else {
|
||||
/* Concatenated stream. */
|
||||
}
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
+4052
-1902
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||
miniaudio - v0.11.22 - 2025-02-24
|
||||
miniaudio - v0.11.23 - 2025-09-11
|
||||
|
||||
David Reid - mackron@gmail.com
|
||||
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
|
||||
#define MA_VERSION_MAJOR 0
|
||||
#define MA_VERSION_MINOR 11
|
||||
#define MA_VERSION_REVISION 22
|
||||
#define MA_VERSION_REVISION 23
|
||||
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
@@ -127,6 +127,8 @@ typedef ma_uint16 wchar_t;
|
||||
#define MA_SIZE_MAX 0xFFFFFFFF /* When SIZE_MAX is not defined by the standard library just default to the maximum 32-bit unsigned integer. */
|
||||
#endif
|
||||
|
||||
#define MA_UINT64_MAX (((ma_uint64)0xFFFFFFFF << 32) | (ma_uint64)0xFFFFFFFF) /* Weird shifting syntax is for VC6 compatibility. */
|
||||
|
||||
|
||||
/* Platform/backend detection. */
|
||||
#if defined(_WIN32) || defined(__COSMOPOLITAN__)
|
||||
@@ -135,29 +137,55 @@ typedef ma_uint16 wchar_t;
|
||||
#define MA_WIN32_UWP
|
||||
#elif defined(WINAPI_FAMILY) && (defined(WINAPI_FAMILY_GAMES) && WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
|
||||
#define MA_WIN32_GDK
|
||||
#elif defined(NXDK)
|
||||
#define MA_WIN32_NXDK
|
||||
#else
|
||||
#define MA_WIN32_DESKTOP
|
||||
#endif
|
||||
|
||||
/* The original Xbox. */
|
||||
#if defined(NXDK) /* <-- Add other Xbox compiler toolchains here, and then add a toolchain-specific define in case we need to discriminate between them later. */
|
||||
#define MA_XBOX
|
||||
|
||||
#if defined(NXDK)
|
||||
#define MA_XBOX_NXDK
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(_WIN32) /* If it's not Win32, assume POSIX. */
|
||||
#if defined(__MSDOS__) || defined(MSDOS) || defined(_MSDOS) || defined(__DOS__)
|
||||
#define MA_DOS
|
||||
|
||||
/* No threading allowed on DOS. */
|
||||
#ifndef MA_NO_THREADING
|
||||
#define MA_NO_THREADING
|
||||
#endif
|
||||
|
||||
/* No runtime linking allowed on DOS. */
|
||||
#ifndef MA_NO_RUNTIME_LINKING
|
||||
#define MA_NO_RUNTIME_LINKING
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(MA_WIN32) && !defined(MA_DOS) /* If it's not Win32, assume POSIX. */
|
||||
#define MA_POSIX
|
||||
|
||||
/*
|
||||
Use the MA_NO_PTHREAD_IN_HEADER option at your own risk. This is intentionally undocumented.
|
||||
You can use this to avoid including pthread.h in the header section. The downside is that it
|
||||
results in some fixed sized structures being declared for the various types that are used in
|
||||
miniaudio. The risk here is that these types might be too small for a given platform. This
|
||||
risk is yours to take and no support will be offered if you enable this option.
|
||||
*/
|
||||
#ifndef MA_NO_PTHREAD_IN_HEADER
|
||||
#include <pthread.h> /* Unfortunate #include, but needed for pthread_t, pthread_mutex_t and pthread_cond_t types. */
|
||||
typedef pthread_t ma_pthread_t;
|
||||
typedef pthread_mutex_t ma_pthread_mutex_t;
|
||||
typedef pthread_cond_t ma_pthread_cond_t;
|
||||
#else
|
||||
typedef ma_uintptr ma_pthread_t;
|
||||
typedef union ma_pthread_mutex_t { char __data[40]; ma_uint64 __alignment; } ma_pthread_mutex_t;
|
||||
typedef union ma_pthread_cond_t { char __data[48]; ma_uint64 __alignment; } ma_pthread_cond_t;
|
||||
#if !defined(MA_NO_THREADING)
|
||||
/*
|
||||
Use the MA_NO_PTHREAD_IN_HEADER option at your own risk. This is intentionally undocumented.
|
||||
You can use this to avoid including pthread.h in the header section. The downside is that it
|
||||
results in some fixed sized structures being declared for the various types that are used in
|
||||
miniaudio. The risk here is that these types might be too small for a given platform. This
|
||||
risk is yours to take and no support will be offered if you enable this option.
|
||||
*/
|
||||
#ifndef MA_NO_PTHREAD_IN_HEADER
|
||||
#include <pthread.h> /* Unfortunate #include, but needed for pthread_t, pthread_mutex_t and pthread_cond_t types. */
|
||||
typedef pthread_t ma_pthread_t;
|
||||
typedef pthread_mutex_t ma_pthread_mutex_t;
|
||||
typedef pthread_cond_t ma_pthread_cond_t;
|
||||
#else
|
||||
typedef ma_uintptr ma_pthread_t;
|
||||
typedef union ma_pthread_mutex_t { char __data[40]; ma_uint64 __alignment; } ma_pthread_mutex_t;
|
||||
typedef union ma_pthread_cond_t { char __data[48]; ma_uint64 __alignment; } ma_pthread_cond_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__unix__)
|
||||
@@ -184,8 +212,11 @@ typedef ma_uint16 wchar_t;
|
||||
#if defined(__PROSPERO__)
|
||||
#define MA_PROSPERO
|
||||
#endif
|
||||
#if defined(__NX__)
|
||||
#define MA_NX
|
||||
#if defined(__3DS__)
|
||||
#define MA_3DS
|
||||
#endif
|
||||
#if defined(__SWITCH__) || defined(__NX__)
|
||||
#define MA_SWITCH
|
||||
#endif
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
#define MA_BEOS
|
||||
@@ -195,12 +226,13 @@ typedef ma_uint16 wchar_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__has_c_attribute)
|
||||
#if __has_c_attribute(fallthrough)
|
||||
#define MA_FALLTHROUGH [[fallthrough]]
|
||||
#endif
|
||||
#if !defined(MA_FALLTHROUGH) && defined(__cplusplus) && __cplusplus >= 201703L
|
||||
#define MA_FALLTHROUGH [[fallthrough]]
|
||||
#endif
|
||||
#if !defined(MA_FALLTHROUGH) && defined(__has_attribute) && (defined(__clang__) || defined(__GNUC__))
|
||||
#if !defined(MA_FALLTHROUGH) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L
|
||||
#define MA_FALLTHROUGH [[fallthrough]]
|
||||
#endif
|
||||
#if !defined(MA_FALLTHROUGH) && defined(__has_attribute)
|
||||
#if __has_attribute(fallthrough)
|
||||
#define MA_FALLTHROUGH __attribute__((fallthrough))
|
||||
#endif
|
||||
@@ -237,7 +269,7 @@ typedef ma_uint16 wchar_t;
|
||||
#define MA_NO_INLINE __attribute__((noinline))
|
||||
#else
|
||||
#define MA_INLINE MA_GNUC_INLINE_HINT
|
||||
#define MA_NO_INLINE __attribute__((noinline))
|
||||
#define MA_NO_INLINE
|
||||
#endif
|
||||
#elif defined(__WATCOMC__)
|
||||
#define MA_INLINE __inline
|
||||
@@ -620,7 +652,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ma_int32 state;
|
||||
ma_uint32 state;
|
||||
} ma_lcg;
|
||||
|
||||
|
||||
@@ -2839,7 +2871,7 @@ This section contains the APIs for device playback and capture. Here is where yo
|
||||
************************************************************************************************************************************************************/
|
||||
#ifndef MA_NO_DEVICE_IO
|
||||
/* Some backends are only supported on certain platforms. */
|
||||
#if defined(MA_WIN32)
|
||||
#if defined(MA_WIN32) && !defined(MA_XBOX)
|
||||
#define MA_SUPPORT_WASAPI
|
||||
|
||||
#if defined(MA_WIN32_DESKTOP) /* DirectSound and WinMM backends are only supported on desktops. */
|
||||
@@ -3696,6 +3728,7 @@ struct ma_context
|
||||
ma_proc snd_pcm_hw_params_set_rate_resample;
|
||||
ma_proc snd_pcm_hw_params_set_rate;
|
||||
ma_proc snd_pcm_hw_params_set_rate_near;
|
||||
ma_proc snd_pcm_hw_params_set_rate_minmax;
|
||||
ma_proc snd_pcm_hw_params_set_buffer_size_near;
|
||||
ma_proc snd_pcm_hw_params_set_periods_near;
|
||||
ma_proc snd_pcm_hw_params_set_access;
|
||||
@@ -4256,6 +4289,7 @@ struct ma_device
|
||||
/*AAudioStream**/ ma_ptr pStreamPlayback;
|
||||
/*AAudioStream**/ ma_ptr pStreamCapture;
|
||||
ma_mutex rerouteLock;
|
||||
ma_atomic_bool32 isTearingDown;
|
||||
ma_aaudio_usage usage;
|
||||
ma_aaudio_content_type contentType;
|
||||
ma_aaudio_input_preset inputPreset;
|
||||
@@ -7525,7 +7559,7 @@ typedef struct
|
||||
ma_log* pLog; /* When set to NULL, will use the context's log. */
|
||||
ma_uint32 listenerCount; /* Must be between 1 and MA_ENGINE_MAX_LISTENERS. */
|
||||
ma_uint32 channels; /* The number of channels to use when mixing and spatializing. When set to 0, will use the native channel count of the device. */
|
||||
ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native channel count of the device. */
|
||||
ma_uint32 sampleRate; /* The sample rate. When set to 0 will use the native sample rate of the device. */
|
||||
ma_uint32 periodSizeInFrames; /* If set to something other than 0, updates will always be exactly this size. The underlying device may be a different size, but from the perspective of the mixer that won't matter.*/
|
||||
ma_uint32 periodSizeInMilliseconds; /* Used if periodSizeInFrames is unset. */
|
||||
ma_uint32 gainSmoothTimeInFrames; /* The number of frames to interpolate the gain of spatialized sounds across. If set to 0, will use gainSmoothTimeInMilliseconds. */
|
||||
@@ -7689,11 +7723,11 @@ MA_API ma_bool32 ma_sound_is_looping(const ma_sound* pSound);
|
||||
MA_API ma_bool32 ma_sound_at_end(const ma_sound* pSound);
|
||||
MA_API ma_result ma_sound_seek_to_pcm_frame(ma_sound* pSound, ma_uint64 frameIndex); /* Just a wrapper around ma_data_source_seek_to_pcm_frame(). */
|
||||
MA_API ma_result ma_sound_seek_to_second(ma_sound* pSound, float seekPointInSeconds); /* Abstraction to ma_sound_seek_to_pcm_frame() */
|
||||
MA_API ma_result ma_sound_get_data_format(ma_sound* pSound, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
|
||||
MA_API ma_result ma_sound_get_cursor_in_pcm_frames(ma_sound* pSound, ma_uint64* pCursor);
|
||||
MA_API ma_result ma_sound_get_length_in_pcm_frames(ma_sound* pSound, ma_uint64* pLength);
|
||||
MA_API ma_result ma_sound_get_cursor_in_seconds(ma_sound* pSound, float* pCursor);
|
||||
MA_API ma_result ma_sound_get_length_in_seconds(ma_sound* pSound, float* pLength);
|
||||
MA_API ma_result ma_sound_get_data_format(const ma_sound* pSound, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap);
|
||||
MA_API ma_result ma_sound_get_cursor_in_pcm_frames(const ma_sound* pSound, ma_uint64* pCursor);
|
||||
MA_API ma_result ma_sound_get_length_in_pcm_frames(const ma_sound* pSound, ma_uint64* pLength);
|
||||
MA_API ma_result ma_sound_get_cursor_in_seconds(const ma_sound* pSound, float* pCursor);
|
||||
MA_API ma_result ma_sound_get_length_in_seconds(const ma_sound* pSound, float* pLength);
|
||||
MA_API ma_result ma_sound_set_end_callback(ma_sound* pSound, ma_sound_end_proc callback, void* pUserData);
|
||||
|
||||
MA_API ma_result ma_sound_group_init(ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup);
|
||||
|
||||
@@ -248,13 +248,23 @@ extern "C" {
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define VERBLIB_INLINE __forceinline
|
||||
#define VERBLIB_INLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#if defined(__STRICT_ANSI__)
|
||||
#define VERBLIB_GNUC_INLINE_HINT __inline__
|
||||
#else
|
||||
#define VERBLIB_GNUC_INLINE_HINT inline
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
|
||||
#define VERBLIB_INLINE VERBLIB_GNUC_INLINE_HINT __attribute__((always_inline))
|
||||
#else
|
||||
#define VERBLIB_INLINE VERBLIB_GNUC_INLINE_HINT
|
||||
#endif
|
||||
#elif defined(__WATCOMC__)
|
||||
#define VERBLIB_INLINE __inline
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define VERBLIB_INLINE inline __attribute__((always_inline))
|
||||
#else
|
||||
#define VERBLIB_INLINE inline
|
||||
#endif
|
||||
#define VERBLIB_INLINE
|
||||
#endif
|
||||
|
||||
#define verblib_max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
@@ -151,13 +151,23 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define VOCLIB_INLINE __forceinline
|
||||
#define VOCLIB_INLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#if defined(__STRICT_ANSI__)
|
||||
#define VOCLIB_GNUC_INLINE_HINT __inline__
|
||||
#else
|
||||
#define VOCLIB_GNUC_INLINE_HINT inline
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
|
||||
#define VOCLIB_INLINE VOCLIB_GNUC_INLINE_HINT __attribute__((always_inline))
|
||||
#else
|
||||
#define VOCLIB_INLINE VOCLIB_GNUC_INLINE_HINT
|
||||
#endif
|
||||
#elif defined(__WATCOMC__)
|
||||
#define VOCLIB_INLINE __inline
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define VOCLIB_INLINE inline __attribute__((always_inline))
|
||||
#else
|
||||
#define VOCLIB_INLINE inline
|
||||
#endif
|
||||
#define VOCLIB_INLINE
|
||||
#endif
|
||||
|
||||
/* Filters
|
||||
|
||||
+4134
-1953
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
includedir=@MINIAUDIO_PC_INCLUDEDIR@
|
||||
libdir=@MINIAUDIO_PC_LIBDIR@
|
||||
|
||||
Name: miniaudio
|
||||
Description: An audio playback and capture library.
|
||||
URL: https://miniaud.io/
|
||||
License: Unlicense OR MIT-0
|
||||
Version: @PROJECT_VERSION@
|
||||
|
||||
Requires.private: @MINIAUDIO_PC_REQUIRES_PRIVATE@
|
||||
Cflags: -I${includedir} @MINIAUDIO_PC_CFLAGS@
|
||||
Libs: -L${libdir} -lminiaudio
|
||||
Libs.private: @MINIAUDIO_PC_LIBS_PRIVATE@
|
||||
@@ -0,0 +1,2 @@
|
||||
set DJGPP=C:\DJGPP\DJGPP.ENV
|
||||
set PATH=C:\DJGPP\BIN;%PATH%
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../external/fs/fs.c" /* <-- Must come first due to some (hopefully temporary) hacks to work around some `-std=c89` errors. */
|
||||
#include "../../miniaudio.c"
|
||||
#include "../../external/fs/fs.c"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -43,7 +43,7 @@ int ma_run_tests(int argc, char** argv)
|
||||
ma_bool32 hasError = MA_FALSE;
|
||||
size_t iTest;
|
||||
|
||||
fs_mkdir(NULL, TEST_OUTPUT_DIR);
|
||||
fs_mkdir(NULL, TEST_OUTPUT_DIR, FS_IGNORE_MOUNTS);
|
||||
|
||||
for (iTest = 0; iTest < g_Tests.count; iTest += 1) {
|
||||
printf("=== BEGIN %s ===\n", g_Tests.pTests[iTest].pName);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
#define MA_NO_THREADING
|
||||
#define MA_NO_DEVICE_IO
|
||||
#include "../common/common.c"
|
||||
|
||||
ma_result init_data_converter(ma_uint32 rateIn, ma_uint32 rateOut, ma_resample_algorithm algorithm, ma_data_converter* pDataConverter)
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_bpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_bpf2_uninit(&bpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
@@ -110,6 +111,7 @@ ma_result test_bpf4__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_bpf_uninit(&bpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_hishelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
}
|
||||
}
|
||||
|
||||
ma_hishelf2_uninit(&hishelf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_hpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_hpf1_uninit(&hpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
@@ -110,6 +111,7 @@ ma_result test_hpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_hpf2_uninit(&hpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
@@ -171,6 +173,7 @@ ma_result test_hpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_hpf_uninit(&hpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_loshelf2__by_format(const char* pInputFilePath, const char* pOutp
|
||||
}
|
||||
}
|
||||
|
||||
ma_loshelf2_uninit(&loshelf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_lpf1__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_lpf1_uninit(&lpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
@@ -110,6 +111,7 @@ ma_result test_lpf2__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_lpf2_uninit(&lpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
@@ -172,6 +174,7 @@ ma_result test_lpf3__by_format(const char* pInputFilePath, const char* pOutputFi
|
||||
}
|
||||
}
|
||||
|
||||
ma_lpf_uninit(&lpf, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
|
||||
}
|
||||
}
|
||||
|
||||
ma_notch2_uninit(¬ch, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -49,6 +49,7 @@ ma_result test_peak2__by_format(const char* pInputFilePath, const char* pOutputF
|
||||
}
|
||||
}
|
||||
|
||||
ma_peak2_uninit(&peak, NULL);
|
||||
ma_decoder_uninit(&decoder);
|
||||
ma_encoder_uninit(&encoder);
|
||||
return MA_SUCCESS;
|
||||
|
||||
@@ -31,6 +31,7 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
|
||||
}
|
||||
|
||||
ma_encoder_uninit(&encoder);
|
||||
ma_noise_uninit(&noise, NULL);
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
+2018
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user