Commit Graph

4661 Commits

Author SHA1 Message Date
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
David Reid 15da9bd7ff API CHANGE: Add onProp callback to ma_data_source_vtable.
A new callback called `onProp` has been added to
`ma_data_source_vtable`. This replaces the following callbacks:

    onGetDataFormat
    onGetCursor
    onGetLength
    onSetLooping

This new callback is for retrieving and setting various properties
relating to the data source. It takes a `prop` parameter which is an ID
for the property being handled, and a `void*` pointer for
property-specific data.

Typically onProp implementations would discriminate on the property type
using a switch. The example below shows how to handle the old callbacks:

    switch (prop)
    {
        // Replaces onGetDataFormat (format/channels/rate).
        case MA_DATA_SOURCE_GET_DATA_SOURCE:
        {
            ma_data_source_data_format* pDataFormat =
                (ma_data_source_data_format*)pData;
            pDataFormat->format     = pCustomDataSource->format;
            pDataFormat->channels   = pCustomDataSource->channels;
            pDataFormat->sampleRate = pCustomDataSource->sampleRate;

            return MA_SUCCESS;
        }

        // Replaces onGetDataFormat (channel map)
        case MA_DATA_SOURCE_GET_CHANNEL_MAP:
        {
            ma_channel_map_init_standard(
                ma_standard_channel_map_default,
                (ma_channel*)pData,
                MA_MAX_CHANNELS,
                pCustomDataSource->channels);

            return MA_SUCCESS;
        }

        // Replaces onGetCursor
        case MA_DATA_SOURCE_GET_CURSOR:
        {
            *((ma_uint64*)pData) = pCustomDataSource->cursor;
            return MA_SUCCESS;
        }

        // Replaces onGetLength
        case MA_DATA_SOURCE_GET_LENGTH:
        {
            *((ma_uint64*)pData) = pCustomDataSource->length;
            return MA_SUCCESS;
        }

        // Replaces onSetLooping
        case MA_DATA_SOURCE_SET_LOOPING:
        {
            pCustomDataSource->isLooping = *((ma_bool32*)pData);
            return MA_SUCCESS;
        }

        // Mandatory when MA_DATA_SOURCE_SET_LOOPING is implemented.
        case MA_DATA_SOURCE_GET_LOOPING:
        {
            *((ma_bool32*)pData) = pCustomDataSource->isLooping;
            return MA_SUCCESS;
        }

        // Return MA_NOT_IMPLEMENTED for any ignored properties.
        default: return MA_NOT_IMPLEMENTED;
    }

Note how the format/channels/rate and channel map properties have been
split across two separate properties, `MA_DATA_SOURCE_GET_DATA_SOURCE`
and `MA_DATA_SOURCE_GET_CHANNEL_MAP`. Along with this change, the
channel map parameters have been removed from
`ma_data_source_get_data_format()` and a new function called
`ma_data_source_get_channel_map()` has been added.

New properties have also been added for handling ranges and loop points.
This allows the data source implementation itself to handle it rather
than miniaudio doing it at a higher level. Where this is useful is if
your data source is a wrapper around another data source and you want to
route ranges and loop points to the internal data source.

The reason for this change is that it allows for properties to be added
without having to break the build due to yet another callback being
added. It also hides away the more niche properties that the majority of
data sources do not care about. For example, rarely does a data source
need to handle the `onSetLooping` callback, yet every data source needed
to add a `NULL` entry to their vtables just for this one extremely niche
property.

See documentation for further details.

Tag: release-notes
Tag: api-change
2026-05-02 15:31:09 +10:00
David Reid afa3a0b855 Add support for copying audio buffer data sources. 2026-04-29 16:19:18 +10:00
David Reid ba8d25305c API CHANGE: Rename ma_audio_buffer_init_copy()
This has been renamed to ma_audio_buffer_init_and_copy_data(). This is
to free up the old name for a new purpose (creating a copy of the whole
`ma_audio_buffer` object).
2026-04-29 16:13:07 +10:00
David Reid 9ab3c55587 API CHANGE: Remove ma_audio_buffer_ref.
Use ma_audio_buffer instead.
2026-04-29 16:09:11 +10:00
David Reid d7cec8ba20 Remove an unused function. 2026-04-29 15:40:44 +10:00
David Reid 125f181b2b Add support for copying noise data sources. 2026-04-29 15:37:55 +10:00
David Reid ca9a1e8493 Add support for copying waveform data sources. 2026-04-29 15:37:45 +10:00
David Reid f68fe8b076 Add support for copying audio ring buffers. 2026-04-29 15:25:31 +10:00
David Reid bfd3c98797 Remove an unnecessary function. 2026-04-29 14:41:03 +10:00
David Reid f018f3cb85 Add support for copying decoders. 2026-04-29 14:39:45 +10:00
David Reid f40376031f Fix some warnings. 2026-04-29 13:55:41 +10:00
David Reid b73f0182d7 Add support for copying data streams.
This enables `ma_sound_init_copy()` to work with sounds that were
initialized with `MA_SOUND_FLAG_STREAM`.
2026-04-29 13:35:17 +10:00
David Reid af9c82f3dc API CHANGE: Simplify ma_resource_manager_data_buffer_init_copy()
This removes the ma_resource_manager parameter since it can just be
derived from the data source.
2026-04-29 13:30:26 +10:00
David Reid 1129061e19 Update reverb and vocoder examples. 2026-04-29 13:08:50 +10:00
David Reid ab15b24065 API CHANGE: Remove the flags member from ma_data_source_vtable. 2026-04-29 11:30:27 +10:00
David Reid fcb48c585a Remove an unused data source flag.
This removes MA_DATA_SOURCE_SELF_MANAGED_RANGE_AND_LOOP_POINT which is
no longer used by any data sources.
2026-04-29 11:23:35 +10:00
David Reid 265d250ec2 Simplify some resource manager code.
These changes are mostly for setting up support for copyable streams.
2026-04-29 11:10:20 +10:00
David Reid 50fcc2f41f Make ma_sound_init_copy() more generic.
The copying of the data source is now done generically through the new
data source copying system rather than being restricted to just the
resource manager.
2026-04-29 10:51:27 +10:00
David Reid f223d3e315 Add some new data source APIs.
ma_data_source_get_vtable()
  ma_data_source_init_copy()
2026-04-29 10:46:38 +10:00
David Reid 1403dfcdc9 Add copy callback for the ma_resource_manager_data_buffer data source. 2026-04-29 07:42:42 +10:00
David Reid a9043ba26d API CHANGE: Add an onCopy callback to ma_data_source_vtable.
This is used for making a copy of a data source.

Data sources are not required to support copying, in which case this
callback can be set to NULL, or it can return MA_NOT_IMPLEMENTED.

This commit just sets up the infrastructure. As of this commit, no data
sources actually implement this, however future commits will be
introducing support in stages.
2026-04-29 07:33:50 +10:00
David Reid 137298734e API CHANGE: Add an onSizeof callback to ma_data_source_vtable.
This should return the size of the implementations struct. For example,
`ma_decoder` would return `sizeof(ma_decoder)`.

This is in preparation for future work to support copying data sources.
2026-04-29 06:54:57 +10:00
David Reid 2cb46c7abd Whitespace. 2026-04-28 19:24:46 +10:00
David Reid 70d52e5eaa Simplify ma_allocation_callbacks_init_copy().
This returns the ma_allocation_callbacks object instead of a result
code.
2026-04-28 19:21:30 +10:00
David Reid d7802c3b14 API CHANGE: Remove decoding backend file initialization specializations.
This removes the onInitFile and onInitFileW callbacks from
ma_decoding_backend_vtable. This means decoding backends can no longer
implement a specialized initialization routine for loading from a file.
What this does is enforces all file IO to go through the same code path,
that being the `ma_decoder` and `ma_vfs` infrastructure. It also
simplifies the backend vtable.

The ability to initialize from memory (the onInitMemory callback) is
still available and there are not plans to remove this.
2026-04-28 19:07:23 +10:00
David Reid a92139b686 Enable libvorbis and libopus decoding in the deviceio test. 2026-04-28 19:00:24 +10:00
David Reid 77074f0597 API CHANGE: Add an onUninit callback to ma_data_source_vtable.
This callback to execute the data source's uninitialization routine.
2026-04-28 17:27:31 +10:00
David Reid 3e729e4b28 Make some APIs public.
This makes the following APIs public:

  ma_allocation_callbacks_init_default()
  ma_allocation_callbacks_init_copy()

This is required to allow things like custom data sources and backends
to be able to track allocation callbacks if necessary.
2026-04-28 17:25:23 +10:00
David Reid b5732f515a API CHANGE: Update ma_noise_uninit().
This removes the allocations callback parameter. It is no managed
internally in preparation for some changes to data source management.
2026-04-28 17:23:16 +10:00
David Reid 52f22d6597 API CHANGE: Update ma_node_graph_uninit().
This removes the allocation callbacks parameter. These are now managed
internally. This is in preparation for some future changes to data
source management.
2026-04-28 17:20:31 +10:00
David Reid 44323c9cae API CHANGE: Rename data source init and uninit APIs.
These have been renamed to the following:

  ma_data_source_init   > ma_data_source_base_init
  ma_data_source_uninit > ma_data_source_base_uninit

The new naming scheme makes it clearer that you're initializing the
base data source structure.
2026-04-28 16:24:22 +10:00
David Reid a267a4ca65 Merge branch 'dev' into dev-0.12 2026-04-26 18:56:20 +10:00
David Reid 09615e6bc1 Update c89atomic. 2026-04-26 18:56:05 +10:00
David Reid 3841d2858d Merge branch 'dev' into dev-0.12 2026-04-26 11:55:23 +10:00
David Reid 12a83fcf54 Update dr_wav. 2026-04-26 11:55:12 +10:00
David Reid dad1060489 PipeWire: Clean up to runtime linking.
This will cleanly fail when a required entry point is unavailable.

Public issue https://github.com/mackron/miniaudio/issues/1104
2026-04-26 09:18:26 +10:00
David Reid 72a6203849 Fix build errors with MA_NO_RUNTIME_LINKING. 2026-04-26 09:12:46 +10:00
David Reid 4635de9916 Merge branch 'dev' into dev-0.12 2026-04-26 08:33:38 +10:00
David Reid 2986173662 Emscripten: Fix an error with ALLOW_MEMORY_GROWTH.
Public issue https://github.com/mackron/miniaudio/issues/1114
2026-04-26 08:32:28 +10:00
David Reid 1cd746c5a6 Fix Emscripten test. 2026-04-26 08:23:13 +10:00
David Reid 07c4ae67cf Merge branch 'dev' into dev-0.12 2026-04-26 08:22:51 +10:00
Echo J dcfc24c100 Emscripten: Cast pointer arguments to pointer-sized integers
For some reason, 64-bit pointer arguments are casted to Numbers
in Emscripten's type handling (which causes conversion errors when
passing them back to native code)
2026-04-26 08:11:16 +10:00
David Reid 7533c9d341 Update build instructions for Emscripten test. 2026-04-26 08:10:43 +10:00
Yuri Khrustalev 56ffd77769 Make ma_android_sdk_version static to fix -Wmissing-prototypes. 2026-04-26 07:22:41 +10:00
amaldika 55f16e62f6 Support to build for arm64EC configuration on MSVC. 2026-04-26 07:21:35 +10:00
David Reid 5d8e72d54f Merge branch 'dev' into dev-0.12 2026-04-26 07:15:52 +10:00
David Reid 1df46ae9a0 Update dr_libs. 2026-04-26 07:08:13 +10:00
David Reid c64330dbd9 Clean up some stale comments. 2026-04-20 06:05:31 +10:00