Commit Graph

324 Commits

Author SHA1 Message Date
David Reid 1366842684 Fix some C89 build errors. 2026-05-02 15:52:55 +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 f40376031f Fix some warnings. 2026-04-29 13:55:41 +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 2cb46c7abd Whitespace. 2026-04-28 19:24:46 +10:00
David Reid a92139b686 Enable libvorbis and libopus decoding in the deviceio test. 2026-04-28 19:00:24 +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 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
David Reid 7533c9d341 Update build instructions for Emscripten test. 2026-04-26 08:10:43 +10:00
David Reid a6cb08579e Add sizeof profiling test. 2026-03-05 17:58:09 +10:00
David Reid bc52a82903 Add PS Vita backend. 2026-03-01 07:53:00 +10:00
David Reid 30e2ca2b46 Add XAudio backend.
This adds support for the original Xbox via NXDK.
2026-02-27 10:58:24 +10:00
David Reid 282ed02f46 Dreamcast: Add a readme to the romdisk folder. 2026-02-17 06:22:55 +10:00
David Reid 2324d5ad9e Add Dreamcast backend. 2026-02-16 19:07:35 +10:00
David Reid d6d26deeda Fix some compilation errors with the resampling test. 2026-02-16 07:12:42 +10:00
David Reid e490db3085 Optimizations to ma_interleave_pcm_frames(). 2026-02-16 06:52:12 +10:00
David Reid 6851858937 Fix a bug in the profiling test. 2026-02-16 06:01:35 +10:00
David Reid 242cbf4d8c Optimizations to ma_deinterleave_pcm_frames() for stereo. 2026-02-15 21:54:29 +10:00
David Reid 9edf1a558c Fix some warnings. 2026-02-15 06:29:22 +10:00
David Reid c8c11615e3 Try fixing the Emscripten build. 2026-02-14 20:55:02 +10:00
David Reid dbf391611d Add resampling test. 2026-02-14 20:26:20 +10:00
David Reid 5ffa29a80b Clear out an out of date test. 2026-02-14 20:20:28 +10:00
David Reid 07ea662dae Update the Emscripten test. 2026-01-25 19:45:01 +10:00
David Reid ba963e46b5 Web Audio: Experimental loopback support.
This uses `getDisplayMedia()`. Support for this is extremely browser and
system specific so I'm not advertising support for this documentation.

Public issue https://github.com/mackron/miniaudio/issues/967
2026-01-21 12:19:25 +10:00
David Reid f37ffed283 Merge PipeWire backend into the main library. 2026-01-20 17:15:32 +10:00
David Reid b29541068c Minor changes to deviceio output. 2026-01-16 15:08:19 +10:00
David Reid c3dcf0d1db Update tests readme. 2026-01-16 06:42:44 +10:00
David Reid cfed5b09a6 Web Audio: Update to the new device info system. 2026-01-15 16:27:06 +10:00
David Reid 434bfc6a0b Set up some infrastructure for the new device info structure. 2026-01-15 14:24:41 +10:00
David Reid e69049e6ac Fix a bug with duplex mode in the deviceio test. 2026-01-15 12:01:57 +10:00
David Reid 1509e9b375 Fix an error with the --enumerate-only option in deviceio test. 2026-01-15 10:45:11 +10:00
David Reid 6c0c35387d Add --only-enumerate option to deviceio test. 2026-01-15 09:09:55 +10:00
David Reid dd3cce3061 Add some infrastructure to the Emscripten test for testing SDL2. 2026-01-13 13:05:30 +10:00
David Reid 1adad94ef8 Try fixing the Emscripten build. 2026-01-12 19:51:40 +10:00
David Reid 26029b2250 Add a basic engine test.
This is currently just for some specific tests, but might be expanded
later to be something a bit more practical.
2026-01-12 17:30:05 +10:00
David Reid f028249019 Add a command line option for exclusive mode to deviceio test. 2026-01-12 15:54:27 +10:00
David Reid adce75cba6 Show device IDs in the deviceio test. 2026-01-11 07:06:23 +10:00
David Reid fb132046d4 Add command line switches for periods and period sizes to deviceio test. 2026-01-09 19:21:24 +10:00
David Reid 46adfae3bb Update the deviceio test with a few more command line switches. 2026-01-09 13:38:49 +10:00
David Reid 4e28636ed8 Update deviceio test to allow explicit channel count selection. 2026-01-09 13:23:27 +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 c314eb0fa5 Add a new errored status.
This allows a backend to put the device into an errored state to
indicate that it is no longer usable and needs to be reinitialized.
2026-01-03 11:01:46 +10:00
David Reid 53b4d6a4a0 Update build instructions for Emscripten example. 2026-01-02 15:51:35 +10:00
David Reid 45c7a64299 Add support for device selection the deviceio test. 2026-01-01 15:58:37 +10:00
David Reid 1d308f69bc Add a basic single-threaded test to deviceio test. 2026-01-01 14:52:01 +10:00
David Reid 1d0a598485 Rename MA_THREADING_MODE_MULTITHREADED.
This not having an underscore while SINGLE_THREADED did was driving me
crazy.
2026-01-01 09:19:43 +10:00
David Reid e086de4eb3 Web Audio: Get single-threaded mode working to spec. 2025-12-30 14:54:36 +10:00
David Reid fc677beac9 Add SDL2 and PipeWire logs to deviceio test. 2025-11-30 19:47:33 +10:00