Commit Graph

17 Commits

Author SHA1 Message Date
David Reid f581a23f30 Fix a comment. 2024-03-01 09:35:01 +10:00
David Reid f01ce432be Merge branch 'dev' into dev-0.12 2024-02-25 09:37:21 +10:00
David Reid 766a155fb3 Stop using MA_ASSERT in examples.
This is useful because MA_ASSERT is only defined in the implementation
section of miniaudio.h which can cause issues when people copy/paste
the code and use it in a file that does not have visibility of the
implementation.

Note that there are still more references to implementation-defined
macros, but these have been moved to the public section in the dev-0.12
branch so I'm not bothering to change those just yet.

Public issue https://github.com/mackron/miniaudio/issues/787
2023-12-17 08:42:19 +10:00
David Reid 7e01c6535b More work on custom device backends.
With this commit, custom backends can now be implemented as
self-contained modules that can easily be plugged in and mixed and
matched depending on a programs requirements. The order in which
custom backends are specified in the context config determine their
priority.

This commit updates the custom_backend example by moving the SDL
code out into its own file in "extras/backends/sdl". The example will
now just include the SDL code files like normal. This represents a more
realistic scenario.
2023-08-07 16:14:05 +10:00
David Reid 04ab2a2d7b Merge branch 'dev' into dev-0.12 2023-05-27 15:45:00 +10:00
David Reid a8f3cb857e Fix compilation errors with MA_NO_DEVICE_IO. 2023-05-22 18:09:04 +10:00
David Reid 58166e2267 API CHANGE: Updates to custom backends.
Custom backends must now use the `ma_device_backend_vtable` object to
define their callbacks. All of these functions are largely the same,
except they all now take a `void*` as their first parameter which
represents the user data pointer.

The ma_backend_callbacks parameter has been removed from onContextInit
which means you must now statically define your callbacks in the
ma_device_backend_vtable object that you pass into the context config.

The `custom` member of the context config has been replaced with a new
set of members to support the ability to plug in multiple vtables.
2023-04-01 12:06:52 +10:00
David Reid efa95d998f Remove the loop parameter from ma_data_source_read_pcm_frames(). 2021-10-13 18:51:17 +10:00
David Reid 369d3b8df7 Fix compilation errors with examples. 2021-07-31 10:22:20 +10:00
David Reid 33aae652fe API CHANGE: Update ma_get_standard_channel_map().
This adds a capacity parameter for added safety. It also changes the
order of parameters to make it a bit more consistent.
2021-07-04 19:46:00 +10:00
David Reid ea84294d97 Fix the custom_backend example. 2021-06-24 19:23:30 +10:00
David Reid c715ead0e8 Minor simplification to the custom backend example. 2021-01-31 10:17:28 +10:00
David Reid 7fd98209ef Migrate the WebAudio backend over to the new callback system.
This changes a few things for custom backends and the calculation of
the size of the buffer. See the custom_backend example.
2020-11-17 20:43:29 +10:00
David Reid db0442fb78 Migrate the WASAPI backend over to the new callback system.
This includes changes to callbacks used by custom backends. It adds a
`pConfig` parameter to both onContextInit and onDeviceInit. This allows
custom backends to specify custom config properties.
2020-11-15 15:41:15 +10:00
David Reid a5bd015936 Explicitly set native data format flags in custom backend example. 2020-11-08 19:15:45 +10:00
David Reid dd8f6c4c66 Fix warnings on the Emscripten build. 2020-11-08 14:37:40 +10:00
David Reid 887bbeeeee Add support for custom backends.
This commit includes a few changes required for better supporting this:

  * Extra members have been added to ma_device_info which are going to
    eventually replace the min and max channels and sample rates. The
    new system is going to provide a list of supported data formats,
    groups by format/channels/rate and some flags. The only flag used
    at the moment is whether or not the format is usable in exclusive
    mode. The custom backend is the only backend currently using these
    new device info properties, and a backwards-compatibility layer has
    been implemented to fill out the old properties. Built-in backends
    will be migrated over to the new system in time.

  * A new set of backend callbacks have been implemented. Only the
    custom backend is using these at the moment. Built-in backends will
    be migrated over to these new backends soon.

  * A new public API called ma_device_get_state() has been added which
    returns the current state of the device (whether or not it's
    started or stopped). This is necessary for some custom backends.

  * A new public API called ma_device_handle_backend_data_callback()
    has been added. This is required for custom backends who use the
    callback paradigm for data delivery.

  * A new type of ring buffer has been created called ma_duplex_rb.
    This is used as an intermediary buffer for duplex devices running
    on backends that use the callback paradigm. It's used internally by
    ma_device_handle_backend_data_callback(). In the future it's
    planned to expand ma_duplex_rb to handle desyncs by dynamically
    resampling to get both sides back in sync. This is not implemented
    as of this commit.

Future work will involve converting existing built-in backends to be
consistent with the new ideas introduced with custom backend support.
2020-11-08 14:25:55 +10:00