This is the first backend to experiment with the new wait/step backend
model which, if it works out, will allow miniaudio to work in a single
threaded mode which in turn will open up the opportunity for
applications to have greater control over thread management and to
possibly allow miniaudio to work on single threaded systems like DOS.
This is still heavily WIP and should be considered unstable as of this
commit.
This is the foundation work for getting all device backend callbacks
executing from a single thread. This will not include context related
callbacks, nor the wakeup callback.
Once this work is done, backends can rely on the property that all the
main callbacks, except wakeup, will be executed from the same thread.
Where this is particularly useful is thread hostile backends like
WASAPI. In particular, we'll be able to do isolate the initialization of
COM to only the miniaudio-managed thread which make it easier to use
miniaudio alongside frameworks which do their own COM initialization,
such as Qt.
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`.
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
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`.
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.