Commit Graph

4197 Commits

Author SHA1 Message Date
David Reid a9bdbc3033 Update backend priority order in documentation. 2025-08-07 19:23:22 +10:00
David Reid e6483d8bd9 Add some fallback stubs for threading APIs.
These will be used when a platform lacks any kind of threading support,
such as DOS. This is in preparation for future work to allow the device
API to work without threading support.

With this commit, the DJGPP DOS build can be compiled without
`MA_NO_THREADING`.
2025-08-07 19:16:02 +10:00
David Reid 08b8fcd4c6 Fix timing functions with the DJGPP build. 2025-08-07 19:12:43 +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 1ea69211ad Fix some errors with the DJGPP build.
This forces `MA_NO_THREADING` and `MA_NO_RUNTIME_LINKING`.

The DOS/DJGPP build currently requires `MA_NO_DEVICE_IO`.
2025-08-07 17:44:19 +10:00
David Reid e9e8f90137 Fix an error when setting loop points.
Public issue https://github.com/mackron/miniaudio/issues/1019
2025-08-07 16:20:00 +10:00
David Reid d93552283f Unify MA_NX and MA_SWITCH platform macros. 2025-08-07 16:17:51 +10:00
David Reid 61a85dca42 Fix NXDK build for Xbox.
This disables the WASAPI, DirectSound and WinMM backends which means
you will not get any actual audio output working. An Xbox backend will
need to come later. The main purpose of this commit is to get the main
library compiling.

The main complication arises from the fact that both _WIN32 and
_MSC_VER are defined which makes miniaudio think it's using a normal
desktop Windows build. In practice it mostly works, but there's a few
things needing to be changed specifically for NXDK:

  - `fopen_s()` is not a thing with NXDK. It always uses `fopen()`.
  - There is no `_wfopen()`, nor `wcsrtombs()`, so attempting to open
    a file from a wide character string will fail.
  - There is also no `CreateFileW()`, so this code path will also
    result in an error if you attempt to open a file from a wide
    character path.
  - `CoInitialize()` is not a thing with NXDK and has therefore been
    excluded from the build.
  - `GetFileInformationByHandle()` does not exist, and neither does
    `struct stat` or `stat()`. Since the only file information miniaudio
    attempts to retrieve is the file size, I've implemented a fall back
    which uses the seek/tell/seek pattern when info retrieval is
    unavailable.
  - A fall back has been implemented for comparing wide character path
    extensions which performs a case-sensitive compare instead. This
    means that if you are using wide character paths, miniaudio will not
    detect an extension like "wav" and "WAV" as the same thing. This
    might be made more robust later if there is enough demand.

Public issue https://github.com/mackron/miniaudio/issues/1023
2025-08-07 13:45:11 +10:00
David Reid c87f207f4e Win32: Use CreateSemaphore() instead of CreateSemaphoreW()
This should improve compiler compatibility for those that do not
define `CreateSemaphoreW()`, such as NXDK.
2025-08-07 13:23:35 +10:00
David Reid 02ae7e41f0 Update dr_libs. 2025-08-07 13:18:56 +10:00
David Reid 8bb1dc5a88 Merge branch 'dev' into dev-0.12 2025-07-23 12:12:53 +10:00
David Reid 457a7279fa Update dr_wav. 2025-07-23 12:08:35 +10:00
David Reid fe1da60e1e Update change history. 2025-07-23 10:11:14 +10:00
David Reid 0b70a990ca Minor update to documentation. 2025-07-23 09:16:20 +10:00
David Reid 26c347e506 Merge branch 'dev' into dev-0.12 2025-07-22 16:34:01 +10:00
David Reid 556160909e Try fixing the Switch build. 2025-07-22 15:46:17 +10:00
David Reid 2d4cc9c910 ALSA: Add a new config option to use the default channel layout.
This can sometimes be more reliable than `snd_pcm_get_chmap()`.
2025-07-22 15:29:51 +10:00
David Reid 20b9b9c533 Android: Remove enableCompatibilityWorkarounds config options. 2025-07-22 07:53:11 +10:00
David Reid 76e97c6254 PipeWire: Try fixing some compilation errors. 2025-07-22 06:18:46 +10:00
David Reid 384afa3a5f Whitespace. 2025-07-21 17:09:09 +10:00
David Reid 397cadbd64 Merge branch 'dev' into dev-0.12 2025-07-21 17:07:08 +10:00
David Reid c48975f4a9 Don't link against dl with NO_RUNTIME_LINKING. 2025-07-21 17:06:34 +10:00
David Reid db9ad08bf0 Merge branch 'dev' into dev-0.12 2025-07-21 17:04:02 +10:00
David Reid 79b4ddc27d Fix CMake script for NetBSD and OpenBSD. 2025-07-21 16:54:27 +10:00
David Reid 377f589a01 Merge branch 'dev' into dev-0.12 2025-07-21 16:51:09 +10:00
Marcin Serwin 0b9f03a376 Respect CMAKE_INSTALL_INCLUDEDIR when installing headers
Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-21 16:48:25 +10:00
Marcin Serwin 140b9c7f9f Add compile define for specific backends only in CMake
Fixes https://github.com/mackron/miniaudio/pull/1010#issuecomment-3093830252

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-21 16:47:46 +10:00
Marcin Serwin ac8c908283 Don't force static libraries
The default for creating libraries is static but can be overridden
by setting BUILD_SHARED_LIBS variable. Setting it explicitly makes it
impossible to override.

https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Signed-off-by: Marcin Serwin <marcin@serwin.dev>
2025-07-21 16:47:03 +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 276dd4419d Fix some errors with the PipeWire backend. 2025-07-21 16:08:52 +10:00
David Reid 2a7446fb46 Add some globals for standard sample rates.
It's been useful for backends to be able to iterate over an array of
sample rates in a standard order of priority, so I've made this public
for the benefit of custom backends.

This also removes a hard coding for `ma_standard_sample_rate_count`.
2025-07-21 14:13:18 +10:00
David Reid de31f9ea49 Fix warnings in the PipeWire backend with GCC. 2025-07-21 14:07:24 +10:00
David Reid ed65f5d7ee Standardize naming convention of data source vtable variables.
This naming convention is consistent with decoding and device backends.
2025-07-21 13:06:02 +10:00
David Reid ff73bd7af6 Remove new lines from log messages. 2025-07-21 12:57:48 +10:00
David Reid bd75bcb592 Make ma_context/device_get_backend_state() atomic.
It is technically possible for a backend to create a thread which
calls `ma_context/device_get_backend_state()` before miniaudio has
set the internal pointer.
2025-07-21 12:43:13 +10:00
David Reid 93167d108e Move an implementation detail out of the header section. 2025-07-21 11:50:29 +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 5b21699ba9 Fix Emscripten test. 2025-07-21 09:13:53 +10:00
David Reid 497f18c4a4 Web Audio: Include format information in device enumeration. 2025-07-21 09:13:40 +10:00
David Reid 4a646fe191 WinMM: Remove ma_context_get_device_info__winmm(). 2025-07-21 08:49:16 +10:00
David Reid b184d81a46 DirectSound: Remove ma_context_get_device_info__dsound(). 2025-07-21 08:48:53 +10:00
David Reid ced8f9e091 DirectSound: Include format information in device enumeration. 2025-07-21 08:40:11 +10:00
David Reid 8b3ac67c89 Improvements to the WASAPI backend.
* Fix an error with the recent refactoring work.
  * Fix some build errors with the UWP build.
  * Update device enumeration to include format information.
2025-07-21 08:14:50 +10:00
David Reid 9507f61689 Merge branch 'dev' into dev-0.12 2025-07-20 19:49:06 +10:00
David Reid 8b87c10681 Fix some errors with MA_NO_RUNTIME_LINKING. 2025-07-20 19:41:28 +10:00
David Reid c62dc472eb Core Audio: Include format information in device enumeration. 2025-07-20 18:23:31 +10:00
David Reid e49fc58584 ALSA: Improve a log message. 2025-07-20 16:40:11 +10:00