Commit Graph

371 Commits

Author SHA1 Message Date
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 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 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 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 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 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 df6119890e Merge branch 'dev' into dev-0.12 2026-03-04 07:01:18 +10:00
David Reid 9634bedb5b Version 0.11.25 2026-03-04 06:25:00 +10:00
David Reid e35c1fd64b Update the backend template. 2026-02-27 20:18:25 +10:00
David Reid d94b45d058 Add a template for device backends. 2026-02-27 17:42:28 +10:00
David Reid b5eb987b86 SDL2: Include miniaudio.h in the header. 2026-02-23 17:19:54 +10:00
David Reid 2302e58045 API CHANGE: Rename vtable to pVTable.
This applies to `ma_data_source_config` and `ma_node_config` and makes
the naming consistent with other parts of the library.
2026-01-26 15:46:58 +10:00
David Reid 7c3b8fab04 Remove osaudio.
This belongs in its own repository.
2026-01-25 18:32:57 +10:00
David Reid f37ffed283 Merge PipeWire backend into the main library. 2026-01-20 17:15:32 +10:00
David Reid 9aa4744a94 PipeWire: Fix a memory leak. 2026-01-19 18:20:31 +10:00
David Reid 0cf35695c8 PipeWire: Set up some infrastructure for future work. 2026-01-18 16:29:40 +10:00
David Reid 3a1b85bb53 PipeWire: Rename some variables. 2026-01-18 12:48:25 +10:00
David Reid a187fb0450 PipeWire: Try fixing a compilation error. 2026-01-18 11:58:07 +10:00
David Reid 8d9d61d607 PipeWire: Improve sample rate detection for device enumeration. 2026-01-18 11:41:36 +10:00
David Reid 64b3dd6f66 PipeWire: Comment out some unshippable code.
A better workaround for this is still in progress.
2026-01-18 10:31:43 +10:00
David Reid f215062678 PipeWire: Refactoring in an attempt to work around an PipeWire issue.
It turns out this didn't actually fix the problem, but I actually prefer
this version so I'm going to keep this.
2026-01-18 09:30:49 +10:00
David Reid d043ce61b3 Merge branch 'dev' into dev-0.12 2026-01-18 06:06:51 +10:00
David Reid 13d161bc8d Update split version. 2026-01-18 06:05:35 +10:00
David Reid df405b1fb7 PipeWire: Fix a crash in device enumeration. 2026-01-17 20:30:05 +10:00
David Reid cb0e6afe70 Update to the decoding backend system.
The `onGetEncodingFormat` callback has been removed and replaced with an
`onInfo`. This new callback fills out a struct with the supported
encoding format (is recognized by miniaudio), in addition to the name of
the decoding backend, and the decoding library and vendor.
2026-01-17 14:49:26 +10:00
David Reid 72ed924fb5 PipeWire: Make native data format detection more specific. 2026-01-16 15:08:57 +10:00
David Reid 7ac50d477e Clean up some old code relating to the new device info system. 2026-01-16 06:26:01 +10:00
David Reid 08d4c60bc3 SDL2: Update to the new device info system. 2026-01-15 14:47:20 +10:00
David Reid 91ddce1d17 PipeWire: Update to the new device info system. 2026-01-15 14:42:14 +10:00
David Reid e5743d666c SDL2: Improve Emscripten support by limiting the period size.
Setting the period size to something too small results in glitching so
this commit will clamp it to a minimum size on the Emscripten build.
2026-01-13 13:03:15 +10:00
David Reid 629e751d56 Fix the SDL2 backend for Emscripten. 2026-01-13 12:56:07 +10:00
David Reid 1adad94ef8 Try fixing the Emscripten build. 2026-01-12 19:51:40 +10:00
David Reid cd521f9440 Comment out a printf() debugging statement. 2026-01-12 17:45:48 +10:00
David Reid 628f2c1640 Add a debugging VFS. 2026-01-12 17:29:18 +10:00
David Reid ca6361db5e PipeWire: Fix a bug with channel map negotiation. 2026-01-07 16:57:31 +10:00
David Reid 3b0391ad44 Silence an assigned-but-not-used warning. 2026-01-07 16:43:49 +10:00
David Reid 86d5f669e4 PipeWire: Comment out an unused function. 2026-01-07 11:10:21 +10:00
David Reid 882d7329f9 Add getter functions for backend vtables. 2026-01-07 09:22:43 +10:00
David Reid f3dfc97c2c Fix a format selection bug in the PipeWire backend.
This was incorrectly choosing the wrong endian-specific sample format
when the endian.h header was not included. This commit switches to
runtime endian detection.
2026-01-05 20:18:35 +10:00
David Reid bfe4b07da4 PipeWire: Fix some warnings. 2026-01-05 14:44:57 +10:00
David Reid 4e827fa977 Use consistent nomenclature for device backend wakeup callbacks.
It should be "wakeup" instead of "wake".
2026-01-05 06:05:17 +10:00
David Reid 44b39fe097 Rename SDL2 backend source files. 2026-01-03 13:56:40 +10:00
David Reid 3df99ce51d Rename the SDL backend to SDL2.
This distinction is needed because we'll be doing an SDL3 backend in the
future.
2026-01-03 13:50:48 +10:00
David Reid ce41f6cfc9 SDL2: Fix a compilation error due.
This is due to calling an internal miniaudio function.
2026-01-02 14:14:10 +10:00
David Reid da764a5a28 PipeWire: Fix an error when runtime linking is disabled. 2026-01-02 12:34:42 +10:00
David Reid e9fad62f44 Improve default device enumeration with the SDL2 backend. 2026-01-01 19:36:37 +10:00