108 Commits

Author SHA1 Message Date
David Reid f40cf03f80 Version 0.11.23 2025-09-11 06:46:45 +10:00
David Reid 7f2cd5b8d5 Fix an error in the splitting script. 2025-09-11 06:42:16 +10:00
David Reid 3afbdef285 Update dr_libs. 2025-09-10 18:56:36 +10:00
David Reid 9a091f73aa Fix an undefined behavior error in the s16 to s32 conversion routine. 2025-09-10 15:06:34 +10:00
David Reid 4de39a8a37 Update change history. 2025-09-10 14:55:00 +10:00
David Reid 7c8574210d Update gitignore. 2025-09-10 13:49:58 +10:00
David Reid 6648ed005a Initial commit of the documentation generation tool. 2025-09-10 13:47:00 +10:00
David Reid 87bae56937 Fix typos in the documentation. 2025-09-10 13:18:58 +10:00
David Reid 293f5de18f Minor fixes to the readme. 2025-09-10 13:11:34 +10:00
David Reid 233b9b69c4 Reinstate the Twitter badge. 2025-09-10 12:58:20 +10:00
David Reid db514e813f Add splitting script. 2025-09-10 12:45:06 +10:00
David Reid 8130543730 Update fs. 2025-09-10 10:04:27 +10:00
David Reid b306c6a270 Use pkg-config for libvorbis and libopus detection. 2025-09-10 09:51:13 +10:00
spevnev 9e1f02b12a Fix unsigned offset overflow 2025-09-10 06:44:31 +10:00
David Reid fa84240364 Fix a typo. 2025-09-09 17:27:25 +10:00
David Reid 70eb06d3bd CMake: Minor fix for pthread and m. 2025-08-23 09:54:32 +10:00
Marcin Serwin 959283f244 Ignore missing library dependencies in CMake
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-08-23 09:45:49 +10:00
David Reid ea59076ba9 Try fixing a warning with MA_FALLTHROUGH. 2025-08-23 08:33:53 +10:00
David Reid 1d7d8dfba0 Fix some CMake errors with the Emscripten build. 2025-08-23 08:09:03 +10:00
David Reid f48d903526 WASAPI: Add a missing field to ma_AudioClientProperties.
Public issue https://github.com/mackron/miniaudio/issues/1028
2025-08-23 06:46:09 +10:00
David Reid 3bdd39fd2c Make some sound functions const.
Public issue https://github.com/mackron/miniaudio/issues/990
2025-08-23 06:20:08 +10:00
David Reid e75a053908 Update CMake script to extract the version from miniaudio.h. 2025-08-23 05:50:15 +10:00
David Reid 346d86ffa1 Update gitignore. 2025-08-23 05:45:05 +10:00
Marcin Serwin a2f92095dc Expose compile defines in pkg-config file
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-08-23 05:41:27 +10:00
Marcin Serwin badf36a378 Generate and install pkg-config file
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-08-23 05:41:27 +10:00
Marcin Serwin c9d288c3dc Link linux backends if NO_RUNTIME_LINKING is enabled
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-08-23 05:41:27 +10:00
David Reid 825d2c4466 Update fs. 2025-08-22 11:27:45 +10:00
David Reid 6fd62e6bbc Update fs. 2025-08-22 07:12:34 +10:00
David Reid b1893aa8f1 Minor C89 compatibility fix. 2025-08-21 14:33:52 +10:00
David Reid df4baf8d40 Fix some errors. 2025-08-21 14:24:21 +10:00
David Reid 21237008df Silence some errors in the Steam Audio headers. 2025-08-21 14:23:31 +10:00
David Reid 587bd83cbb Update fs and fix some build errors with -std=c89. 2025-08-21 13:57:57 +10:00
David Reid b7e5451ef4 Try fixing a compilation error when pthread does not exist. 2025-08-20 18:07:59 +10:00
David Reid ba84e61a18 Try fixing a compilation error when libatomic does not exist. 2025-08-20 18:03:12 +10:00
David Reid a7ab58259e Don't try building C++ tests when forcing C89. 2025-08-20 17:36:07 +10:00
David Reid 18055f34bb voclib: Fix a compilation error. 2025-08-20 16:40:46 +10:00
David Reid f6bae251bd verblib: Try fixing a compilation error on macOS. 2025-08-20 16:09:44 +10:00
David Reid 3567d5cfef Fix compilation error with MA_NO_SSE2. 2025-08-20 16:04:15 +10:00
David Reid 4e3b778c62 Silence some warnings about unused functions. 2025-08-20 15:56:43 +10:00
David Reid 6315130ec6 Make ma_lcg.state uint32 to avoid UB on signed arthimethic overflow 2025-08-19 08:32:06 +10:00
David Reid 6e1cd41622 tests: fix memory leak in filtering and generation tests 2025-08-19 08:26:22 +10:00
David Reid 78cdb9c1cb Add batch file for setting up DJGPP environment. 2025-08-07 17:44:55 +10:00
David Reid 1ea69211ad Fix some errors with the DJGPP build.
This forces `MA_NO_THREADING` and `MA_NO_RUNTIME_LINKING`.

The DOS/DJGPP build currently requires `MA_NO_DEVICE_IO`.
2025-08-07 17:44:19 +10:00
David Reid e9e8f90137 Fix an error when setting loop points.
Public issue https://github.com/mackron/miniaudio/issues/1019
2025-08-07 16:20:00 +10:00
David Reid d93552283f Unify MA_NX and MA_SWITCH platform macros. 2025-08-07 16:17:51 +10:00
David Reid 61a85dca42 Fix NXDK build for Xbox.
This disables the WASAPI, DirectSound and WinMM backends which means
you will not get any actual audio output working. An Xbox backend will
need to come later. The main purpose of this commit is to get the main
library compiling.

The main complication arises from the fact that both _WIN32 and
_MSC_VER are defined which makes miniaudio think it's using a normal
desktop Windows build. In practice it mostly works, but there's a few
things needing to be changed specifically for NXDK:

  - `fopen_s()` is not a thing with NXDK. It always uses `fopen()`.
  - There is no `_wfopen()`, nor `wcsrtombs()`, so attempting to open
    a file from a wide character string will fail.
  - There is also no `CreateFileW()`, so this code path will also
    result in an error if you attempt to open a file from a wide
    character path.
  - `CoInitialize()` is not a thing with NXDK and has therefore been
    excluded from the build.
  - `GetFileInformationByHandle()` does not exist, and neither does
    `struct stat` or `stat()`. Since the only file information miniaudio
    attempts to retrieve is the file size, I've implemented a fall back
    which uses the seek/tell/seek pattern when info retrieval is
    unavailable.
  - A fall back has been implemented for comparing wide character path
    extensions which performs a case-sensitive compare instead. This
    means that if you are using wide character paths, miniaudio will not
    detect an extension like "wav" and "WAV" as the same thing. This
    might be made more robust later if there is enough demand.

Public issue https://github.com/mackron/miniaudio/issues/1023
2025-08-07 13:45:11 +10:00
David Reid c87f207f4e Win32: Use CreateSemaphore() instead of CreateSemaphoreW()
This should improve compiler compatibility for those that do not
define `CreateSemaphoreW()`, such as NXDK.
2025-08-07 13:23:35 +10:00
David Reid 02ae7e41f0 Update dr_libs. 2025-08-07 13:18:56 +10:00
David Reid 457a7279fa Update dr_wav. 2025-07-23 12:08:35 +10:00
David Reid fe1da60e1e Update change history. 2025-07-23 10:11:14 +10:00
David Reid 0b70a990ca Minor update to documentation. 2025-07-23 09:16:20 +10:00
David Reid 556160909e Try fixing the Switch build. 2025-07-22 15:46:17 +10:00
David Reid c48975f4a9 Don't link against dl with NO_RUNTIME_LINKING. 2025-07-21 17:06:34 +10:00
David Reid 79b4ddc27d Fix CMake script for NetBSD and OpenBSD. 2025-07-21 16:54:27 +10:00
Marcin Serwin 0b9f03a376 Respect CMAKE_INSTALL_INCLUDEDIR when installing headers
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-21 16:48:25 +10:00
Marcin Serwin 140b9c7f9f Add compile define for specific backends only in CMake
Fixes https://github.com/mackron/miniaudio/pull/1010#issuecomment-3093830252

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-21 16:47:46 +10:00
Marcin Serwin ac8c908283 Don't force static libraries
The default for creating libraries is static but can be overridden
by setting BUILD_SHARED_LIBS variable. Setting it explicitly makes it
impossible to override.

https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-21 16:47:03 +10:00
David Reid 8b87c10681 Fix some errors with MA_NO_RUNTIME_LINKING. 2025-07-20 19:41:28 +10:00
andy5995 629d509072 Fix warning: function declaration without a prototype
Harmless warning on FreeBSD 14.2,
https://cirrus-ci.com/task/4700955851096064?logs=build#L44

```
../subprojects/miniaudio-0.11.22/miniaudio.h:36997:36: warning: a
function declaration without a prototype is deprecated in all versions
of C [-Wstrict-prototypes]
 36997 | static int ma_open_temp_device__oss()
       |                                    ^
       |                                     void
```
2025-07-20 07:51:59 +10:00
David Reid 5c86dd9153 Fix a possible division by zero error. 2025-07-20 07:44:06 +10:00
David Reid e54336996d Update dr_libs. 2025-07-04 11:13:40 +10:00
David Reid 1c7967fc88 PulseAudio: Fix a crash if the requested channel count is too high. 2025-07-04 06:37:08 +10:00
David Reid 2bc0e14abf Minor clarifying comment. 2025-07-02 17:57:50 +10:00
Sam Tupy b348ab0155 fix assertion failure upon loading invalid sound path due to extra ma_fence_release
In ma_resource_manager_data_buffer_node_acquire_critical_section, a job which releases already acquired fences is either processed or posted based on MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT. However on job post or process failure, the fences were being unconditionally released.

This commit moves the fence releases in acquire_critical_section down into a nested branch which only executes if MA_RESOURCE_MANAGER_DATA_SOURCE_FLAG_WAIT_INIT is not set, causing the fence release to take place only if the job failed to post while relying on the job itself to release the fences if it processes rather than causing a duplicate ma_fence_release and thus an eventual assertion failure.
2025-07-02 17:54:30 +10:00
David Reid 346d65091a Don't use threading or device IO in the conversion test. 2025-07-02 10:30:47 +10:00
David Reid aa75d5f8e8 Don't include pthread.h if threading is disabled. 2025-07-02 10:30:06 +10:00
David Reid 0ac5c89157 MP3: Disable SIMD when disabled by miniaudio.
This applies when MA_NO_NEON or MA_NO_SSE2 is set.

Public issue https://github.com/mackron/miniaudio/issues/997
2025-06-09 07:37:25 +10:00
Guillaume Prieur 47020e4092 Fix seek origin conversion in ma_mp3_dr_callback__seek 2025-05-19 08:34:46 +10:00
David Reid 02873ca300 Update c89atomic. 2025-05-11 06:48:51 +10:00
David Reid 11177ed19f Style and formatting changes. 2025-05-08 14:15:12 +10:00
caturria 682fad7d55 Revert accidental include change. 2025-05-08 14:04:57 +10:00
caturria 1497f5e467 Fix leaked OggVorbis_File handle when input is not vorbis. Also implements ma_libvorbis_get_length_in_pcm_frames() for the common case of an ogg file with a single bitstream. 2025-05-08 14:04:57 +10:00
David Reid 853f27ed56 Whitespace. 2025-05-08 08:01:12 +10:00
Keith 05d367eed5 CMake: remove macro and fix warnings 2025-05-08 07:11:27 +10:00
Keith 97493bdfcd CMake: support install
All Miniaudio static libraries now install their headers such that they can
still use relative paths, but external code can #include "miniaudio/miniaudio.h"

Also adds a CMake macro to simplify adding static libraries
2025-05-08 07:11:27 +10:00
David Reid 3edfb70a26 Add amalgamation script. 2025-05-08 07:03:54 +10:00
David Reid 72e4721b2c Update c89atomic. 2025-05-08 06:57:38 +10:00
David Reid b255e91e08 Fix a regression with the MP3 amalgamation. 2025-04-30 09:02:32 +10:00
David Reid b261f4aeec Update dr_wav. 2025-04-30 09:01:27 +10:00
David Reid bd59c52309 Update dr_mp3. 2025-04-30 08:07:36 +10:00
David Reid f15ddefce8 Comment out some unused functions. 2025-04-29 07:44:51 +10:00
David Reid 29c17fcb22 Try improving compatibility of ma_yield().
My understanding is that "pause" was introduced with the Pentium 4 and
assembles to opcode F390 which is the same as "rep; nop". I believe this
should be backwards compatible.

Using "pause" here introduces an compilation error when targeting
architectures older than Pentium 4.
2025-04-27 21:01:59 +10:00
David Reid 5a9c322c83 Fix an error with a GCC version check. 2025-04-27 20:27:19 +10:00
David Reid cd14d18d0c Fix an error when pthread_attr_setstacksize() is unavailable. 2025-04-27 19:50:35 +10:00
David Reid 534b43e800 Comment out some unused functions. 2025-04-27 19:28:28 +10:00
David Reid caa3d2a339 Try fixing a compatibility issue with old GCC.
This is untested.
2025-04-27 19:22:20 +10:00
David Reid 4c2d1bb67c Add a missing va_end() to logging functions. 2025-04-27 18:58:15 +10:00
David Reid 5ba0fc51b6 Fix an error with old versions of GCC. 2025-04-27 18:41:05 +10:00
David Reid e58a24124a Try fixing an error with old versions of GCC. 2025-04-27 17:53:07 +10:00
David Reid 0b4646d31a Fix a compiler compatibility issue. 2025-04-27 17:26:49 +10:00
David Reid 9032fdbced Try fixing a null termination bug in ma_channel_map_to_string().
Public issue https://github.com/mackron/miniaudio/issues/980
2025-04-25 18:58:01 +10:00
David Reid 2ee920577e Attempt to fix an error with ma_log_postv().
Public issue https://github.com/mackron/miniaudio/issues/980
2025-04-25 18:41:44 +10:00
David Reid a944e19331 pthread: Add support for falling back to a non-realtime thread.
MA_NO_PTHREAD_REALTIME_PRIORITY_FALLBACK can be used to disable this
functionality for applications that have a hard requirement on a
realtime thread.
2025-04-19 14:38:29 +10:00
Pavel Galkin 8a9ea7ce07 ALSA: Fix undefined symbols during static compilation
These were undefined when linking with the -static flag on:

  1. Alpine Linux v3.21 x86_64
  2. Debian GNU/Linux 12 (bookworm) aarch64

In both cases I had to manually compile alsa-lib as a static library
because the systems have only .so versions. I did it with:

  cd path/to/alsa-libs
  ./gitcompile static
  <this will create alsa-libs/src/.libs/libasound.a>

Tested with alsa-libs 1.12.2 and 1.12.3.

It's possible to reproduce the errors like this:

clang -static -DMA_NO_RUNTIME_LINKING -DMA_ENABLE_ONLY_SPECIFIC_BACKENDS -DMA_ENABLE_ALSA -DMA_DEBUG_OUTPUT -Wall -Wextra -g3 simple_playback_sine.c -o build/miniwave -fcolor-diagnostics -ferror-limit=2 -fuse-ld=lld -I../
-L/home/antharas/code/alsa-lib/src/.libs/ -lasound

However, even though it compiles I can't verify that everything works.

  1. Alpine has musl which doesn't support runtime linking when
     compiling with -static. So even though I disabled it for
     miniaudio.h, libasound.a itself uses dlopen on
     libasound_module_pcm_pipewire.so.
  2. Debian uses glibc so it supports it but fails because my machine is
     a VPS that doesn't have a soundcard.

No big deal, I don't really need to statically link, it was just
something I stumbled upon.

Also these are currently unused:

  _snd_pcm_hw_params_set_rate_minmax
  ma_timer_init
  ma_timer_get_time_in_seconds
  ma_device__on_notification_rerouted
2025-04-19 13:59:09 +10:00
David Reid 80747f440a Minor style changes and add a comment. 2025-04-19 13:45:48 +10:00
Your Name d40a385e07 Make the COM-related code more reasonable 2025-04-19 13:37:23 +10:00
David Reid 7df2a50d7f Fix a ring buffer alignment error.
Public issue https://github.com/mackron/miniaudio/issues/979
2025-04-19 13:23:49 +10:00
David Reid ab80abf061 Fix typo. 2025-03-27 18:54:21 +10:00
caturria b9292a301f Address leaked pResourceManagerDataSource when invalid input causes sound init to fail. 2025-03-18 09:13:44 +10:00
David Reid 484a56499d Fix a warning. 2025-03-09 07:43:36 +10:00
David Reid b12959f1d4 Update dr_libs. 2025-03-09 07:31:55 +10:00
David Reid 94077d5a95 Minor style changes. 2025-03-08 18:23:34 +10:00
znakeeye b3ab0567c3 Final tweaks. Removed unnecessary if statement. 2025-03-08 17:47:48 +10:00
znakeeye 7158cf58f9 Re-route lock moved outside ma_device_reinit__aaudio
Re-route lock moved outside ma_device_reinit__aaudio call to avoid potential race condition. Also cleaned up the reroute code a bit.
2025-03-08 17:47:48 +10:00
znakeeye fe616c1a5a AAudio: Prevent re-routing while tearing down device. Fixes a crash where re-route thread would read ma_device while being destroyed from main thread. 2025-03-08 17:47:48 +10:00
David Reid cd16c5bcd3 Update fs. 2025-03-05 15:02:33 +10:00
David Reid 76dfabbb45 Remove a link from the readme since I no longer monitor it. 2025-02-26 09:08:26 +10:00
David Reid 46d8abf3de Add teardown to custom_decoder_engine. 2025-02-25 06:48:34 +10:00
32 changed files with 18017 additions and 6478 deletions
+2 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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}
)
+5 -5
View File
@@ -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.
+13
View File
@@ -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));
+289
View File
@@ -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));
+26
View File
@@ -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;
+3
View File
@@ -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;
}
+3 -1
View File
@@ -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);
}
+10
View File
@@ -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. */
+1 -1
View File
@@ -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);
}
+4404 -2240
View File
File diff suppressed because it is too large Load Diff
+2598 -260
View File
File diff suppressed because it is too large Load Diff
+34 -17
View File
@@ -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;
}
File diff suppressed because it is too large Load Diff
+69 -35
View File
@@ -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);
+16 -6
View File
@@ -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))
+16 -6
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -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@
+2
View File
@@ -0,0 +1,2 @@
set DJGPP=C:\DJGPP\DJGPP.ENV
set PATH=C:\DJGPP\BIN;%PATH%
+2 -2
View File
@@ -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);
+2 -1
View File
@@ -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)
+2
View File
@@ -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;
+1
View File
@@ -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;
+3
View File
@@ -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;
+1
View File
@@ -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;
+3
View File
@@ -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;
+1
View File
@@ -49,6 +49,7 @@ ma_result test_notch2__by_format(const char* pInputFilePath, const char* pOutput
}
}
ma_notch2_uninit(&notch, NULL);
ma_decoder_uninit(&decoder);
ma_encoder_uninit(&encoder);
return MA_SUCCESS;
+1
View File
@@ -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;
+1
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff