Commit Graph

4709 Commits

Author SHA1 Message Date
David Reid 45b63e4a0c Core Audio: Make capture more robust to format changes on the OS side.
When the data format of the capture device changes via the Audio MIDI
Setup settings, miniaudio will now reroute the device to take the new
data format into account. Prior to this commit AudioUnitRender() will
just keep failing forever.

Public issue https://github.com/mackron/miniaudio/issues/1136
2026-07-19 09:33:31 +10:00
David Reid ca91ee9bd0 Core Audio: Fix a deadlock when audio processing fails.
Public issue https://github.com/mackron/miniaudio/issues/1136
2026-07-19 09:11:08 +10:00
David Reid 22b9d84622 Merge branch 'dev' into dev-0.12 2026-07-16 07:03:37 +10:00
Steven Noonan 22fd206db9 resource_manager: fix data buffer teardown racing async load job tail
ma_resource_manager_data_buffer_uninit takes a synchronous teardown path as
soon as it observes result == MA_SUCCESS, freeing the buffer. But the load
job (ma_job_process__resource_manager__load_data_buffer) publishes that
result code via a CAS several instructions before it finishes referencing
the buffer: it still reads has_connector() and does the executionPointer
increment afterward. A concurrent uninit that observes MA_SUCCESS therefore
frees the buffer out from under the job tail, which then reads and
atomically increments freed (and possibly recycled) memory.

The asynchronous free path is safe because it waits on the order /
executionPointer ticket scheme; the synchronous shortcut bypassed it. Make
the synchronous path wait for executionPointer to catch up to
executionCounter before tearing down, so no job is still referencing the
buffer. Caught by ThreadSanitizer.
2026-07-16 07:00:30 +10:00
David Reid 5a43b27110 Merge branch 'dev' into dev-0.12 2026-07-13 10:52:02 +10:00
David Reid a98cc2a810 Update dr_wav. 2026-07-13 10:51:36 +10:00
David Reid 7bf545ac1c Merge branch 'dev' into dev-0.12 2026-07-13 08:40:15 +10:00
David Reid 87206fca67 Resource Manager: Fix a possible crash when loading fails.
Public issue: https://github.com/mackron/miniaudio/issues/1129
2026-07-13 08:39:19 +10:00
David Reid a65278353d Merge branch 'dev' into dev-0.12 2026-07-13 07:57:24 +10:00
David Reid cca9aaab77 Update change history. 2026-07-13 07:57:13 +10:00
David Reid fe7bb94e00 Merge branch 'dev' into dev-0.12 2026-07-13 07:47:20 +10:00
David Reid 5bf32c47e5 Fix a bug where the end of a sound is cutoff.
Public issue https://github.com/mackron/miniaudio/issues/1125
2026-07-13 07:45:59 +10:00
David Reid d29e673881 Rework of the attenuation model system.
Support for custom attenuation models has been added.

Attenuation models are now a callback rather than an enumerator. The
callback takes a user data pointer in case the standard distance/rolloff
variables do not suffice. The following APIs have changed in order to
accommodate this:

    ma_spatializer_set_attenuation_model()
    ma_sound_set_attenuation_model()
    ma_sound_group_set_attenuation_model()

These now take an extra parameter for the user data pointer. For stock
attenuation models this should always be set to NULL:

    ma_sound_set_attenuation_model(&sound,
        ma_attenuation_model_linear, NULL);

To plug in a custom model, just implement a callback and plug it in:

    float your_custom_attenuation_model(
        void* pUserData,
        float distance,
        float minDistance,
        float maxDistance,
        float rolloff)
    {
        // Return a value between 0 (silence) and 1 (full volume).
    }

    ...

    ma_sound_set_attenuation_model(&sound,
        your_custom_attenuation_model, &userDataIfRequiredByYourModel);

Previously, setting the attenuation model to none would disable
spatialization completely. This behaviour has changed and now
spatialization will still be applied in this case. You should use
`ma_sound_set_spatialization_enabled(&sound, MA_FALSE)` instead if you
want to disable spatialization.
2026-07-13 06:36:23 +10:00
Fancy2209 7cb28fcbc0 Fix ma_stbvorbis_init 2026-07-11 14:17:38 +10:00
David Reid b500d59f14 Merge branch 'dev' into dev-0.12 2026-07-11 10:49:33 +10:00
David Reid dd644e9269 Add placeholder RISC-V architecture detection.
Public issue https://github.com/mackron/miniaudio/pull/1135
2026-07-11 10:41:49 +10:00
David Reid a3a0005fca CMake: Fix a possible build error relating to the SteamAudio example.
Public issue https://github.com/mackron/miniaudio/pull/1135
2026-07-11 10:31:50 +10:00
David Reid 83e59f7df6 Merge branch 'dev' into dev-0.12 2026-07-11 10:12:52 +10:00
Alex Belanger 21349ce158 Bump CMake min version to 3.13 2026-07-11 09:58:24 +10:00
David Reid 87e22c68dd iOS: Use OBJCXX when FORCE_CXX is enabled. 2026-07-11 09:56:18 +10:00
雪竜 (Tommy Li) 00ce58dfa8 Exclude macOS from Objective-C handling 2026-07-11 09:53:27 +10:00
雪竜 (Tommy Li) 4844874cda Set implementation file as Objective-C in CMake for Apple platforms
This fixes CMake build targeting iOS due to usage of AVFoundation that requires Objective-C support.
2026-07-11 09:53:27 +10:00
toxieainc 9d98e9f887 slightly improve precision 2026-07-11 09:44:52 +10:00
David Reid 04429abf58 Merge branch 'dev' into dev-0.12 2026-07-07 08:00:20 +10:00
David Reid c4bf8a8488 Fix an error with node initialization. 2026-07-07 07:58:13 +10:00
David Reid e867785385 Remove audioconverter.
This has been superseded by the new CLI tool.
2026-06-30 06:57:44 +10:00
David Reid 19cbee7bc4 Initial work on the CLI tool. 2026-06-29 08:06:27 +10:00
David Reid 87439b7f66 Update dr_flac. 2026-06-29 07:35:48 +10:00
David Reid 1d11f50891 Fix a warning in a test. 2026-06-29 07:35:10 +10:00
David Reid 71e56ba403 Fix warnings in the resampling test. 2026-06-29 07:34:39 +10:00
David Reid 621a3c373b Fix warnings in the profiling test. 2026-06-29 07:34:22 +10:00
David Reid 1c1ea6ec93 Fix an error in ma_data_source_get_channel_map(). 2026-06-29 07:34:06 +10:00
David Reid b0a09dee88 Fix an error with interleaving and deinterleaving. 2026-06-29 07:33:20 +10:00
David Reid c073b36c96 Update dr_wav. 2026-06-25 09:39:21 +10:00
David Reid 459eb8b492 PipeWire: Fix a possible deadlock during initialization.
This occurs when attempting to initialize a capture device when not such
device is available, such as if the microphone is unplugged.
2026-06-25 09:38:54 +10:00
David Reid 4679631f5b Fix a node graph error.
Prior to this commit, the number of frames read was always reported as
the whole frame count. This is incorrect for leaf nodes which don't
always produce the full frame count (an example being when the end of a
sound is reached).
2026-05-28 08:37:16 +10:00
David Reid a55d2e7eb8 Merge branch 'dev' into dev-0.12 2026-05-11 05:36:45 +10:00
David Reid 1cb1c1be00 Update security. 2026-05-11 05:36:24 +10:00
David Reid 6ea04ff78e Merge branch 'dev' into dev-0.12 2026-05-10 15:10:57 +10:00
David Reid 40540a1502 PulseAudio: Fix a format negotiation error.
This addresses a case when PulseAudio may negotiate S24_32 which is not
a format supported by miniaudio. This commit does two things to guard
against this:

  * The requested format is now explicitly used instead of using the
    queried format from `pa_context_get_source_info_by_name()`.

  * The `PA_STREAM_FIX_FORMAT` stream flag is no longer used as that can
    possibly negotiate something different to what we request. I.e., it
    can possibly give us S24_32 which is not usable.
2026-05-10 15:00:27 +10:00
David Reid 156f0d678f Fix an example. 2026-05-07 08:44:09 +10:00
David Reid 1424b80ebd Add MA_NODE_FLAG_NONE. 2026-05-06 13:13:05 +10:00
David Reid 130e23ace8 Update some stale comments. 2026-05-06 13:12:55 +10:00
David Reid 931a22b900 Remove the generation test.
Noise and waveform generation can be tested with the deviceio test.
2026-05-04 08:40:49 +10:00
David Reid d6bb7d83fb Repository cleanup. 2026-05-03 10:40:06 +10:00
David Reid 6e3964c4b9 Remove the conversion test.
This was a nothing test. Probably a placeholder from earlier work. Tests
for conversion routines can be added to testbench later.
2026-05-02 17:06:12 +10:00
David Reid f45326a5f2 Remove the C++ test. 2026-05-02 17:01:18 +10:00
David Reid 1366842684 Fix some C89 build errors. 2026-05-02 15:52:55 +10:00
David Reid 27cfc27342 Merge branch 'dev' into dev-0.12 2026-05-02 15:43:46 +10:00
David Reid 326d7ec9a5 Update fs. 2026-05-02 15:43:29 +10:00