Commit Graph

332 Commits

Author SHA1 Message Date
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
David Reid edc44cbcaa PipeWire: Optimization to multi-threaded mode. 2026-01-01 09:38:21 +10:00
David Reid 552cf613b3 PipeWire: Add support for disabling runtime linking. 2025-12-31 18:19:52 +10:00
David Reid 114b9594c1 PipeWire: Finish work on removing the SPA dependency. 2025-12-31 18:18:17 +10:00
David Reid e1dfc9d77f PipeWire: Remove dependency on spa_format_audio_raw_parse(). 2025-12-31 13:30:49 +10:00
David Reid d2a93567df PipeWire: Remove dependency on spa_pod_builder. 2025-12-31 09:04:00 +10:00
David Reid c67b29de38 PipeWire: More work on removing the SPA dependency. 2025-12-30 18:00:07 +10:00
David Reid 9ebc3efa95 PipeWire: First tentative step towards removing the SPA dependency. 2025-12-30 16:40:16 +10:00
David Reid f073a40a1c Fix some warnings for the PipeWire backend. 2025-12-30 10:18:56 +10:00
David Reid fa2c1b49b3 Remove unused callbacks from the device backend system. 2025-12-29 18:02:51 +10:00
David Reid fd6ee4711b Generalize some backend stepping logic for the new backend architecture. 2025-12-22 17:10:03 +10:00
David Reid 9364a36f04 Whitespace. 2025-12-20 18:22:00 +10:00
David Reid ad7084c9ef SDL2: Add wakeup callback. 2025-12-20 18:21:31 +10:00
David Reid 2f18c53771 PipeWire: Fix a bug with non-blocking mode. 2025-12-20 14:27:29 +10:00
David Reid e97ab1ef32 Another pass on the PipeWire backend.
This removes the "wait" concept and replaces it with an extra parameter
for the step() callback for the blocking mode, which can be blocking or
non-blocking.

This also implements the wake() callback for waking up from a blocking
step.
2025-12-20 12:40:10 +10:00
David Reid 60d757a226 Return result codes from step/wait/loop callbacks. 2025-12-16 18:08:32 +10:00
David Reid 4f4f93a91b Finish first pass of the PipeWire backend. 2025-12-12 14:39:03 +10:00
David Reid 2f759f7b62 Convert the SDL2 backend to the new backend architecture. 2025-12-01 10:46:59 +10:00
David Reid ac7a8e691b Fix C++ build of the PipeWire backend. 2025-11-30 19:46:52 +10:00
David Reid 63485c2e7d Merge branch 'dev' into dev-0.12 2025-09-11 09:30:16 +10:00
David Reid f40cf03f80 Version 0.11.23 2025-09-11 06:46:45 +10:00
David Reid ce6c21fffc Fix some Clang warnings. 2025-08-22 07:09:06 +10:00
David Reid 747faa3390 Fix some errors with the Emscripten build. 2025-08-21 18:01:06 +10:00
David Reid 7263de3b64 Delete the PipeWire test.
The PipeWire backend is now tested with the deviceio test.
2025-08-21 14:18:58 +10:00
David Reid e826957a12 Disable the PipeWire backend when compiling as C89.
The SPA headers are not compatible with C89 which means the PipeWire
backend is not usable.
2025-08-21 07:33:08 +10:00
David Reid 5eb78ec819 Merge branch 'dev' into dev-0.12 2025-08-20 16:40:57 +10:00
David Reid 18055f34bb voclib: Fix a compilation error. 2025-08-20 16:40:46 +10:00
David Reid db38f0b003 Merge branch 'dev' into dev-0.12 2025-08-20 16:09:58 +10:00
David Reid f6bae251bd verblib: Try fixing a compilation error on macOS. 2025-08-20 16:09:44 +10:00
David Reid 76e97c6254 PipeWire: Try fixing some compilation errors. 2025-07-22 06:18:46 +10:00
David Reid 276dd4419d Fix some errors with the PipeWire backend. 2025-07-21 16:08:52 +10:00
David Reid de31f9ea49 Fix warnings in the PipeWire backend with GCC. 2025-07-21 14:07:24 +10:00
David Reid fa4107ae95 API CHANGE: Remove the onContextGetDeviceInfo backend callback.
Device information retrieval is now implemented in terms of device
enumeration. Backends should now return any information that would have
been returned from `onContextGetDeviceInfo` straight from
`onContextEnumerateDevices` instead.
2025-07-21 11:47:14 +10:00
David Reid 2b81f75cca API CHANGE: Change return type of device enumeration callback.
The callback passed into `ma_context_enumerate_devices()` would
previously return a boolean, with true telling miniaudio to continue
enumeration, and false to abort. This got a bit confusing to read at
times, so I've decided to make this more explicit.

The new return type is an enum called `ma_device_enumeration_result`.
Instead of returning true to continue enumeration, the new return value
is `MA_DEVICE_ENUMERATION_CONTINUE`. Similarly, instead of returning
false to abort enumeration, `MA_DEVICE_ENUMERATION_ABORT` should be
returned instead.
2025-07-21 11:33:15 +10:00
David Reid 5d86a6ef82 SDL: Include format information in device enumeration. 2025-07-21 10:08:15 +10:00
David Reid 8bb2b1ae80 Update to the PipeWire backend. 2025-07-18 19:16:50 +10:00
David Reid f0ff4b6de3 API CHANGE: Remove ma_performance_profile.
This also removes the `performanceProfile` config option from
`ma_device_config`. Increase the period size if you want to be more
conservative.

Backends that have their own notion of a "latency hint" or the like will
have those options exposed via a backend-specific configuration option.
2025-07-15 14:35:24 +10:00
David Reid a4072246c5 Rename some variables and try silencing a warning. 2025-07-15 07:21:30 +10:00
David Reid ebec10b068 Add early PipeWire backend.
This is incomplete.
2025-07-15 06:59:19 +10:00
David Reid 8890eac6aa One Big Beautiful Commit with refactoring to the device backend system.
This includes API changes that affect custom backends.

`ma_backend_callbacks` has been renamed to `ma_device_backend_vtable`.
The reason for this change is to to be consistent with the naming
convention used in other parts of the library. In addition, using the
term "device backend" rather than just "backend" removes ambiguity with
decoding backends.

A change has been made to the way backends manage their internal state,
and some functions in the vtable have been updated to reflect this.
Previously internal state for stock backends were located directly in
the `ma_device` structure. This works fine if stock backends are the
only backends to be concerned about, but it falls apart when you need
to consider how to manage the internal state of custom backends since
they cannot modify the `ma_device` structure. In order to simplify and
unify state management between stock and custom backends, the decision
was made to change the backend system such that backends now manage
their own internal state.

When the context is initialized with `onContextInit`, the backend must
now allocate an internal state object and output a pointer to it via
an output parameter. Typically you would do something like this:

    ma_result custom_context_init(..., void** ppContextState)
    {
        ctx_state_t* state = malloc(...);

        ...

        *ppContextState = state;
        return MA_SUCCESS;
    }

miniaudio will store a pointer to the state object internally. When you
need to access this later in other backend callbacks, you can retrieve
it straight from the context with `ma_context_get_backend_state()`:

    state = (ctx_state_t*)ma_context_get_backend_state(pContext);

The same idea applies to devices and `onDeviceInit`. You can use
`ma_device_get_backend_state()` to get a pointer to the internal state
object.

When a context and device is initialized, backend-specific
configurations can be supplied. The way these configs are provided to
`onContextInit` and `onDeviceInit` has been changed. Previously, these
callbacks would take a `ma_context/device_config` object. These have
been replaced with a `const void*` which points to a backend-specific
config object which is defined by the backend. All stock backends have
their own backend-specific config object:

    struct ma_context_config_wasapi
    struct ma_context_config_pulseaudio
    etc.

    struct ma_device_config_wasapi
    struct ma_device_config_pulseaudio
    etc.

You can cast the config object inside the relevant callbacks:

    ma_result custom_context_init(..., const void* pBackendConfig, ...)
    {
        ctx_config_t* pCustomConfig = (ctx_config_t*)pBackendConfig;
    }

The backend itself defines whether or not a config is required. None of
the stock backends require a config. If the config is NULL, it'll use
defaults. It's recommended custom backends follow this convention.

In addition to the above, `onContextUninit` and `onDeviceUninit` have
been updated to return void instead of `ma_result`.

The last change to the backend vtable is a new callback called
`onBackendInfo`. This is used to fill the `ma_device_backend_info`
structure.

In addition to the backend vtable, some changes have been made to the
public API to make it much easier to support plugging in custom
backends.

Previously, plugging in more than one custom backend was a complete
mess. It was possible, but you had to use a stupid wrapper thing to
make it work, and you had no control over prioritization. The entire
thing was just aweful, so it's now been stripped out and replaced with
a brand new system.

When a context or device is initialized, it is done so with a config
which is standard across the entire library. A complication to this is
that backends can sometimes require their own backend-specific configs.
But since miniaudio cannot possibly know about custom backends, it
cannot put their config options inside `ma_context/device_config`. The
functions for initializing a context and device have been updated to
allow plugging in backend-specific configs.

When initializing a context, instead of passing in an array of
`ma_backend` enums, an array of `ma_device_backend_config` objects is
passed in instead. This object has two members: A pointer to a backend
vtable, and a pointer to a config object. It can be initialized
something like this:

    ma_context_config_custom customContextConfig;
    ... initialize the custom backend config if necessary ...

    ma_device_backend_config backends[] =
    {
        { ma_device_backend_custom,     &customContextConfig },
        { ma_device_backend_wasapi,     NULL },
        { ma_device_backend_pulseaudio, NULL }
    };

    ma_context_init(backends, backendCount, ...);

Here `ma_device_backend_custom` is our custom backend. You can see how
the config is mapped to the backend. For stock backends (WASAPI and
PulseAudio in this example), you can pass in NULL and just set the
relevant config options straight in `ma_context_config` exactly how it
was done before:

    ma_context_config contextConfig = ma_context_config_init();
    contextConfig.pulseaudio.pApplicationName = "My App";

Here we are just using the standard `ma_context_config` object for
configuring the stock PulseAudio backend. This is possible for all
stock backends, but for custom backends an explicit config object will
be required. You can still use a separate explicit config object for
stock backends if you prefer that style:

    ma_context_config_pulseaudio paContextConfig;
    paContextConfig = ma_context_config_pulseaudio_init();
    paContextConfig.pApplicationName = "My App";

    ma_device_backend_config backends[] =
    {
        { ma_device_backend_pulseaudio, &paContextConfig }
    };

Note that if you do not use custom backends, you can still pass in NULL
for the backends in which case defaults will be used like how it's
always worked in the past.

As with contexts, devices can also have their own backend-specific
configs associated with them. These work exactly the same way, except
these configs are passed into the main `ma_device_config` object. (A
future commit may make this consistent between contexts and devices).

    ma_device_backend_config deviceBackendConfigs[] =
    {
        { ma_device_backend_custom, &customDeviceConfig }
    };

    deviceConfig.pBackendConfigs    = deviceBackendConfigs;
    deviceConfig.backendConfigCount = backendCount;

    ma_device_init(&deviceConfig, &device);

This commit is just the start of many backend related changes. Future
commits will be cleaning up a lot of residual code from the old system,
such as removing `ma_backend`.
2025-07-14 18:05:55 +10:00