Commit Graph

293 Commits

Author SHA1 Message Date
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
David Reid e094807b46 Update readme for tests. 2025-08-22 12:33:01 +10:00
David Reid 0c245dd597 Fix the Android build. 2025-08-22 11:58:53 +10:00
David Reid 747faa3390 Fix some errors with the Emscripten build. 2025-08-21 18:01:06 +10:00
David Reid df0358c870 Merge branch 'dev' into dev-0.12 2025-08-21 14:09:02 +10:00
David Reid 587bd83cbb Update fs and fix some build errors with -std=c89. 2025-08-21 13:57:57 +10:00
David Reid f6453a1418 Add ma_get_stock_device_backends().
This commit many warnings when compiling as C89.
2025-08-21 07:27:42 +10:00
David Reid ba35370f74 Merge branch 'dev' into dev-0.12 2025-08-19 08:32:35 +10:00
David Reid 6e1cd41622 tests: fix memory leak in filtering and generation tests 2025-08-19 08:26:22 +10:00
David Reid 0923a484ee Merge branch 'dev' into dev-0.12 2025-08-07 18:00:40 +10:00
David Reid 78cdb9c1cb Add batch file for setting up DJGPP environment. 2025-08-07 17:44:55 +10:00
David Reid 110ded6fc6 Include the SDL2 and PipeWire backends in the deviceio test. 2025-07-21 16:11:31 +10:00
David Reid ff73bd7af6 Remove new lines from log messages. 2025-07-21 12:57:48 +10:00
David Reid 5b21699ba9 Fix Emscripten test. 2025-07-21 09:13:53 +10:00
David Reid 47f9287ac8 Don't unnecessarily call ma_device_get_info() in deviceio test. 2025-07-20 16:20:41 +10:00
David Reid a014181372 Update fs. 2025-07-15 14:31:56 +10:00
David Reid fabab10843 Remove the backend member from ma_context.
This is a legacy from the old backend system.
2025-07-15 10:11:18 +10:00
David Reid 180c7237f8 Fix a warning. 2025-07-15 07:21:04 +10:00
David Reid fd37406086 Update build instructions for Emscripten. 2025-07-15 06:53:52 +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
David Reid 346d65091a Don't use threading or device IO in the conversion test. 2025-07-02 10:30:47 +10:00
David Reid c92e662de7 Simplify some test code. 2025-02-23 18:22:17 +10:00
David Reid a497466f75 Add basic testing app for Android.
This is only very basic right now. Will be expanded on later.
2025-02-22 18:54:45 +10:00
David Reid e1f5ed4f79 Rename some more test source files. 2025-02-22 13:00:06 +10:00
David Reid ed5cda309c Simplify the conversion test. 2025-02-22 12:50:00 +10:00
David Reid 3435aafb34 Use a simplified naming scheme for tests. 2025-02-22 12:29:56 +10:00
David Reid deafb7e96f Add debugging sandbox for the purpose of debugging miniaudio. 2025-02-22 09:44:03 +10:00
David Reid e08c1303ef Fix a bug with the deviceio test. 2025-02-19 09:43:51 +10:00
David Reid 22a5c65c94 Update tests. 2025-02-18 17:46:57 +10:00
David Reid cff683a1b1 Add a non-interactive mode for the deviceio test. 2025-02-18 17:30:59 +10:00
David Reid cf9371748a Fix compilation warnings with some tests. 2025-02-17 18:15:22 +10:00
David Reid 059a25d9c5 Minor update to tests build instructions for Emscripten. 2025-01-04 09:05:39 +10:00