Commit Graph

4518 Commits

Author SHA1 Message Date
David Reid 172f8beae6 Resampler: Optimization for floating point stereo.
This applies only to the f32 no-LPF code path. Other code paths will be
integrated later.
2026-02-08 22:01:23 +10:00
David Reid cd02ebe39c Resampler: A loop unrolling optimization experiment.
My idea here is to make it easier to for the compiler to SIMD-ify some
of the interpolation code. I have not confirmed that it is actually
being SIMD-ified by the compiler, but it is still significantly faster
in both debug and release builds.

There is a mono specialization here which further improves performance.
I have not yet experimented with a stereo specialization, but if it
works it'll be added in a future commit.

This applies only to the f32 no-LPF code path. Other paths will come
later once I'm done with this round of experiments.
2026-02-08 20:12:57 +10:00
David Reid 20180b0ae5 Resampler: For LPF orders to be a multiple of 2.
This is in preparation for an implementation simplification for the
purpose of some upcoming optimizations.
2026-02-08 19:21:10 +10:00
David Reid a04f300821 Stop encouraging the use of some resampling functions.
These functions are not reliably implemented by all backends and as such
I'd rather not encourage these use of these. These might be removed in
the future.
2026-02-07 17:09:51 +10:00
David Reid 2ea55eaeaf Resampler: Optimization to f32, no LPF code path. 2026-02-07 15:40:10 +10:00
David Reid c0b57c3aea Resampler: Optimization to s16, no LPF code path. 2026-02-07 11:26:05 +10:00
David Reid 4b8eb8588d Resampler: Stop allowing NULL input and output buffers. 2026-02-07 10:48:42 +10:00
David Reid b6467f3cd0 Resampler: Stop invoking the LPF when the order is zero. 2026-02-05 20:22:34 +10:00
David Reid 848025b9c0 Resampler: Fix a bug where the LPF is not being applied. 2026-02-05 20:17:46 +10:00
David Reid 5ea8bbf701 Minor change to a debugging function. 2026-02-05 20:02:01 +10:00
David Reid cff6c7e28a Resampler: Convert a double to a float.
This saves a a few bytes in `ma_linear_resampler`.
2026-02-05 10:18:20 +10:00
David Reid 445aefae06 Resampler: Optimization to the s16 path in the linear resampler.
The main thing here is moving an integer division out of the inner loop.
2026-02-05 08:06:52 +10:00
David Reid 2c14e2e5a7 Resampler: Move a division out of an inner loop. 2026-02-04 17:00:09 +10:00
David Reid 2683601481 Update the linear resampler in preparation for some optimizing. 2026-02-04 16:59:05 +10:00
David Reid 1e2427f5f7 Tighten up the audio thread.
This should close a hole that could possibly result in the audio thread
getting stuck if the `MA_DEVICE_OP_UNINIT` operation posted from
`ma_device_uninit()` fails.
2026-02-04 14:20:42 +10:00
David Reid 93e74aaf91 Reduce the size of the ma_device_op_queue struct.
This in turn reduces the size of the `ma_device` struct by about half
a kilobyte or so.
2026-02-04 14:18:08 +10:00
David Reid 89fea8a39f Remove channelMap and internalChannelMap arrays from ma_device.
This information is already stored in the data converter and can be
retrieved with `ma_device_get_channel_map()` and
`ma_device_get_internal_channel_map()`.

This reduces the size of the `ma_device` struct by ~1KB.
2026-02-04 13:32:14 +10:00
David Reid 9b66a480c7 Fix a bug with channel map retrieval with the channel converter.
This had the input and output channel maps the wrong way around.
2026-02-04 12:45:20 +10:00
David Reid cb26c7ec52 Remove an unnecessary function.
This removes the horrendously named `ma_device__post_init_setup()` which
I've been meaning to remove for years.
2026-02-04 12:44:35 +10:00
David Reid 02f8a6b952 Set up some infrastructure for some future optimizations.
This changes the way backends update the internal data format in
response to a device reroute. With this change we'll be able to remove
the `channelMap` and `internalChannel` map members from the `ma_device`
struct which should reduce its size by ~1KB.
2026-02-04 11:46:05 +10:00
David Reid dc72a5683b Add some getters:
ma_device_get_format()
  ma_device_get_channels()
  ma_device_get_sample_rate()
  ma_device_get_internal_format()
  ma_device_get_internal_channels()
  ma_device_get_internal_sample_rate()
  ma_device_get_internal_channel_map()
2026-02-04 10:52:08 +10:00
David Reid 5c4cb49ad8 Add ma_device_get_channel_map(). 2026-02-01 16:59:13 +10:00
David Reid d929fafb34 Add a specialized path for deinterleaving u8 samples.
This is not yet optimized.
2026-02-01 11:04:07 +10:00
David Reid 53fce8453c Rename a variable. 2026-02-01 11:03:46 +10:00
David Reid ac12fa70e0 Fix Dreamcast/KallistiOS build. 2026-01-29 16:29:14 +10:00
David Reid 3ab152afb3 audio(4): Failed context initialization if /dev/audioctl does not exist.
This allows initialization to abort at an earlier stage which gives the
fallback logic a chance to try a different backend.
2026-01-28 16:33:30 +10:00
David Reid 38e35935d7 Get the audio(4) backend compiling with Solaris.
I have not been able to figure out how to get audio working with my VM
so this is currently untested.
2026-01-28 16:20:09 +10:00
David Reid bbc7ad1921 audio(4): Make format encoding stuff more robust. 2026-01-28 14:47:24 +10:00
David Reid c134a1c870 Add Sun/Solaris compile-time detection. 2026-01-28 14:16:57 +10:00
David Reid 3b5b433e0c Fix some warnings with the release build. 2026-01-28 10:24:47 +10:00
David Reid 847711e291 Fix some warnings. 2026-01-28 09:48:25 +10:00
David Reid d1f34cd5db Update the audio ring buffer to use the standard config/init pattern.
This makes it consistent with everything else in the library.
2026-01-27 17:44:52 +10:00
David Reid 75b3f7dddc Update to the audio ring buffer.
This changes `write_pcm_frames()` so that when `pFramesWritten` is null,
the write is treated as all or nothing. If the entire write cannot be
performed, nothing at all will be written and `MA_NO_SPACE` will be
returned. The same applies with `read_pcm_frames()` and `pFramesRead` in
which case `MA_NO_DATA_AVAILABLE` will be returned.

The reason for this change is that if the called passes in null for
these values, they'll have no way to know how many frames were actually
written or read. Therefore the most practical way to treat it is as all
or nothing.
2026-01-27 17:04:22 +10:00
David Reid fcd386dd87 Remove ma_audio_queue. 2026-01-27 06:17:14 +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 28de8d8947 PipeWire: Try improving mono streams. 2026-01-26 14:04:12 +10:00
David Reid 18df387a84 Updates to ring buffers. 2026-01-26 12:18:41 +10:00
David Reid d30d1cfd89 Update ring buffer. 2026-01-26 06:26:29 +10:00
David Reid 8c2cbf6343 Fix some language in the documentation. 2026-01-25 20:45:15 +10:00
David Reid f99ff4cec0 Remove the old ring buffer.
Public issue https://github.com/mackron/miniaudio/issues/671
2026-01-25 20:30:27 +10:00
David Reid 07ea662dae Update the Emscripten test. 2026-01-25 19:45:01 +10:00
David Reid 5a7bfd7c2c Update the hilo_interop example to use the new ring buffer. 2026-01-25 18:46:25 +10:00
David Reid ca6afd1f49 Fix a bug with the audio ring buffer data source. 2026-01-25 18:45:05 +10:00
David Reid 7c3b8fab04 Remove osaudio.
This belongs in its own repository.
2026-01-25 18:32:57 +10:00
David Reid 7d1c994414 PipeWire: Use the new ring buffer. 2026-01-25 17:47:57 +10:00
David Reid af2cf5d161 Add a new ma_audio_ring_buffer data source.
This is a wrapper around `ma_ring_buffer` and is more specialized
towards audio. It is a data source and replaces `ma_pcm_rb` which will
be removed in a future commit.

Public issue https://github.com/mackron/miniaudio/issues/671
2026-01-25 16:50:28 +10:00
David Reid edb64e6017 Add a new SPSC ring buffer.
This improves on the old ring buffer by having a much simpler
implementation and a much simpler API that does not require the caller
to do reading and writing in a loop.

Future commits will be removing the old ring buffer.

Public issue https://github.com/mackron/miniaudio/issues/671
2026-01-25 14:05:30 +10:00
David Reid bef32b4419 Fix a null pointer dereference in the audio queue. 2026-01-22 11:34:35 +10:00
David Reid 8a43271555 Initial work on the audio queue data source.
Public issue https://github.com/mackron/miniaudio/issues/744
2026-01-22 11:29:53 +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