Commit Graph

4531 Commits

Author SHA1 Message Date
David Reid e5743d666c SDL2: Improve Emscripten support by limiting the period size.
Setting the period size to something too small results in glitching so
this commit will clamp it to a minimum size on the Emscripten build.
2026-01-13 13:03:15 +10:00
David Reid 629e751d56 Fix the SDL2 backend for Emscripten. 2026-01-13 12:56:07 +10:00
David Reid cdd3d39ac0 Emscripten: Force MA_NO_THREADING if not compiling with pthread support. 2026-01-13 12:53:30 +10:00
David Reid b3f32437b8 Update an out of date comment. 2026-01-13 12:46:51 +10:00
David Reid 2b50979bd3 Minor reorganization. 2026-01-13 12:44:35 +10:00
David Reid 2ead596562 PulseAudio: Revert a PipeWire compatibility workaround.
This is no longer needed since a native PipeWire backend is about to be
integrated.
2026-01-13 11:22:46 +10:00
David Reid 27f7eeba91 Change default period count from 3 to 2. 2026-01-13 11:12:08 +10:00
David Reid 51f8235bef Force a minimum of two periods for duplex mode.
Not all backends have the notion of a period, but for those that do this
can make it a bit more reliable.
2026-01-13 10:47:32 +10:00
David Reid d1316a58cf ALSA: Ensure at least two periods are used for duplex mode. 2026-01-13 10:37:25 +10:00
David Reid 98a23f9551 ALSA: Fix an error with underrun recovery.
When an underrun occurs the buffer needs to be filled with data before
restarting or else snd_pcm_start() will return EPIPE.
2026-01-13 10:36:30 +10:00
David Reid 55cdba084d ALSA: Fix an error when priming the playback buffer.
There was a possibility that this process could result in
snd_pcm_writei() getting stuck because the frame count is not being
clamped to the buffer size properly.
2026-01-13 10:22:39 +10:00
David Reid 92a58fae11 ALSA: Fix some typos. 2026-01-13 09:49:10 +10:00
David Reid 1adad94ef8 Try fixing the Emscripten build. 2026-01-12 19:51:40 +10:00
David Reid 994ae48feb CMake: Minor output cleanup. 2026-01-12 19:39:15 +10:00
David Reid c50cc675c9 CMake: Try fixing the build for Clang and FORCE_C89. 2026-01-12 19:38:33 +10:00
David Reid 676b84cad1 ALSA: Remove some out of date comments. 2026-01-12 19:25:02 +10:00
David Reid cd521f9440 Comment out a printf() debugging statement. 2026-01-12 17:45:48 +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 628f2c1640 Add a debugging VFS. 2026-01-12 17:29:18 +10:00
David Reid 82ec45e349 CMake: Fix an error with libvorbis. 2026-01-12 17:25:33 +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 94a79c9cda Fix a bug in ma_calculate_frame_count_after_resampling().
This now uses the same calculation that the linear resampler uses.

Public issue https://github.com/mackron/miniaudio/issues/760
2026-01-12 12:43:09 +10:00
David Reid 9a1b551658 WASAPI: Fix an error with rerouting.
When WASAPI reports `AUDCLNT_E_DEVICE_INVALIDATED` miniaudio will
attempt to reinitialize the device and continue processing. Prior to
this commit the reinit process would use NULL as the device ID which
is incorrect when an explicit device was requested.

With this commit the reinit process will correctly pass in the ID of the
device that it was initialized with. In practice, this will mean the
device will be put into an errored state if it is unplugged.
2026-01-12 10:57:09 +10:00
David Reid e9abcccd86 Update fs. 2026-01-12 07:11:43 +10:00
David Reid c649733b34 WASAPI: Remove old unused code. 2026-01-12 06:54:35 +10:00
David Reid 4d583a4508 WASAPI: Fix device enumeration. 2026-01-12 06:37:14 +10:00
David Reid 6a3d5fde05 Remove some line breaks from log entries. 2026-01-12 06:36:14 +10:00
David Reid df88373cd0 Silence a warning. 2026-01-11 20:21:19 +10:00
David Reid d4631208f9 WASAPI: Clean up a memory leak. 2026-01-11 20:15:51 +10:00
David Reid 8709bef653 WASAPI: Improvement to buffer size negotiation for exclusive mode. 2026-01-11 20:02:47 +10:00
David Reid de3946c9ec WASAPI: Properly recover from overruns in duplex mode. 2026-01-11 17:54:37 +10:00
David Reid 12256314a9 WASAPI: Add a debug log message. 2026-01-11 17:19:58 +10:00
David Reid 39abeb167e WASAPI: Prime the playback buffer before starting. 2026-01-11 17:03:55 +10:00
David Reid 3debb4a20f ALSA: Add some missing snd_pcm_state_t values. 2026-01-11 07:23:14 +10:00
David Reid c4c484794b ALSA: Add a timeout to poll().
I don't trust there won't be edge cases that result in this getting
stuck forever.
2026-01-11 07:22:44 +10:00
David Reid adce75cba6 Show device IDs in the deviceio test. 2026-01-11 07:06:23 +10:00
David Reid 660d5f6f9e ASLA: Fall back to NAME for the device description when DESC is empty. 2026-01-10 13:39:59 +10:00
David Reid 96c4b105b0 ALSA: Use more descriptive error messages. 2026-01-10 13:07:10 +10:00
David Reid 9a4318997b ALSA: Whitespace.
This was off by one space and it was annoying me!
2026-01-10 12:45:30 +10:00
David Reid 280c118dfd ALSA: Try improving native channel count detection heuristics. 2026-01-10 12:41:19 +10:00
David Reid 999c16d834 Merge branch 'dev' into dev-0.12 2026-01-10 12:14:40 +10:00
David Reid 88776cedb7 Whitespace. 2026-01-10 08:49:12 +10:00
spevnev e00cee2af1 Cast tv_sec to 64-bit int before converting 2026-01-10 08:47:03 +10:00
David Reid 760765ec93 ALSA: Use SND_PCM_NONBLOCK when enumerating devices. 2026-01-10 08:10:21 +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 4bed03a65e Fix a bug in ma_prev_power_of_2(). 2026-01-09 18:51:02 +10:00
David Reid e9eccf49a3 ALSA: Improvements buffer size negotiation.
This makes it so period sizes are a power of 2, which in turns makes it
so the value set by `snd_pcm_sw_params_set_avail_min()` is also a power
of 2. This is inline with a suggestion by the ALSA documentation, and
seems to have an actual positive impact in practice with my testing as
well.
2026-01-09 15:37:05 +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 948967dcbb ALSA: Change to device enumeration.
In order to get detailed information about a device, that is supported
formats, channels and sample rates, the PCM needs to be opened. This
can fail sometimes, in which case enumeration would previously just not
enumerate the device.

This is OK, but it creates issues. The first is that the enumerated
devices will not be consistent with what's reported by `aplay`. The
other is that when a hardware device is opened, iteration will not
include that device because it'll be opened in exclusive mode. This
creates a practical issue when trying to get the name of an already
opened device.

This commit makes it so that these devices will still be enumerated,
only they'll be missing detailed format, channels and rate information.
2026-01-09 13:38:07 +10:00
David Reid 224a4c9d3a ALSA: Fix a crash when failing to initialize a device. 2026-01-09 13:24:32 +10:00