Commit Graph

1825 Commits

Author SHA1 Message Date
David Reid f189280766 Add some basic validation for decoders.
This fixes an issue where a decoding backend can report configurations
outside of miniaudio's limits.

Public issues:
  * https://github.com/dr-soft/miniaudio/issues/166
  * https://github.com/dr-soft/miniaudio/issues/167
2020-06-23 20:18:21 +10:00
David Reid e0294ac74c Fix a bug in fixed_sized_callback.
This is uninitializing the ring buffer before the device which results
in a situation where a stray data callback may try touching the buffer
after it's be uninitialized.
2020-06-23 19:55:46 +10:00
David Reid 825ab5d64a Update dr_flac, dr_wav and dr_mp3. 2020-06-23 19:48:17 +10:00
David Reid 0590fb073a dr_wav: Try fixing a buffer overflow with invalid IMA-ADPCM files. 2020-06-23 19:20:13 +10:00
David Reid 715abd641b Add some placeholder tags for dr_libs amalgamation. 2020-06-23 18:57:52 +10:00
David Reid 9467152730 Integrate c89atomic to replace the old atomics API.
This is an internal change and does not affect any public APIs. This
change is in preparation for future lock-free high level APIs.
2020-06-23 17:39:06 +10:00
David Reid 5cd8c3be34 Add placeholder tags for c89atomic amalgamation. 2020-06-23 16:53:55 +10:00
David Reid 080623d3ee Minor formatting change. 2020-06-23 13:30:55 +10:00
David Reid a98c40bcef Version 0.10.8 2020-06-22 21:03:22 +10:00
David Reid 45a12620bf Minor update to test code. 2020-06-22 21:03:07 +10:00
David Reid 97d1f445fd Update revision history. 2020-06-19 11:53:01 +10:00
David Reid 966aeb07a0 Update linear resampler expected output frame count calculations.
This updates ma_linear_resampler_get_expected_output_frame_count() to
calculate the expected output frame count in constant time rather than
linear time. This should improve performances of anything using
ma_calculate_frame_count_after_resampling() which includes
ma_decoder_get_length_in_pcm_frames().
2020-06-19 09:12:46 +10:00
David Reid c92c7764de Experimental work on some lock free queues.
These are completely untested. Nothing here is wired up to the main
system - they're just for experimenting with some ideas.
2020-06-16 21:06:04 +10:00
David Reid f9b7c64c05 Add ma_compare_and_swap_16(). 2020-06-15 21:14:23 +10:00
David Reid a04a318b44 Fix a copy/paste error. 2020-06-14 21:59:42 +10:00
David Reid badb651b79 Add next() and peek() APIs for messages to the resource manager.
This is in preparation for self-managed message handling.
2020-06-14 20:32:52 +10:00
David Reid 0ae21d0415 Update revision history. 2020-06-14 20:10:56 +10:00
David Reid cd4e5314ed Make the ma_event API public in preparation for some future work. 2020-06-14 19:45:54 +10:00
David Reid 318f4500f4 Optimization to file type specific loading routines.
When a decoding backend is not present, initialization should abort
immediately with MA_NO_BACKEND, however it is including code for no
reason. This commit excludes that useless code from the build.
2020-06-14 19:43:21 +10:00
David Reid 4b6c8f555b Add support for configuring thread stack sizes and fix GCC errors.
The thread priority can be set via ma_thread_create() and can be set in
the context config along side the thread priority for configuring the
size of the stack for the audio thread.
2020-06-14 19:27:02 +10:00
David Reid d4cdee82b5 Fix looping with data streams. 2020-06-14 17:24:15 +10:00
David Reid 50eb67f946 Update revision history. 2020-06-14 16:39:34 +10:00
David Reid 8bc153069a Clean up some formatting warnings with GCC and -Wall and -Wpedantic. 2020-06-14 15:29:30 +10:00
David Reid cb5e6f33df Tidy up a few things with the resource manager. 2020-06-14 15:22:11 +10:00
David Reid 9d81823a73 Fix a typo. 2020-06-14 15:20:31 +10:00
David Reid 9cb5ee06ac Comment out some unused functions. 2020-06-14 15:20:13 +10:00
David Reid 3a54f2b6a4 Add a Win32 specific VFS.
This addresses some 64-bit issues with stdio with older versions of VC.
2020-06-14 15:20:00 +10:00
David Reid 18a70db5a9 Make MA_MAX_CHANNELS configurable.
This needs to be #define-d before the header *and* implementation
because it affects the size of publicly visible structures.
2020-06-14 13:33:14 +10:00
David Reid 5a7c2be726 Update comment. 2020-06-14 13:16:47 +10:00
David Reid 80da67de3b Revert some earlier test code. 2020-06-14 13:04:03 +10:00
David Reid dedb843814 Fix ma_compare_and_swap_*() on non-MSVC builds. 2020-06-14 13:02:50 +10:00
David Reid c3e2038c3a Fix a crash trying to seek on a failed async data stream. 2020-06-14 12:54:14 +10:00
David Reid 9be52c7075 Remove a debugging line. 2020-06-14 12:34:16 +10:00
David Reid 78aeabfa41 Update ma_yield(). 2020-06-14 12:30:14 +10:00
David Reid 103574f108 Fix a bug where ma_default_vfs_open_w() is not being used. 2020-06-14 10:40:49 +10:00
David Reid d2cffd18d6 Add support for streaming data sources.
A streaming data source keeps in memory only two pages of audio data
and dynamically loads data from a background thread. It is essentially
a double buffering system - as one page is playing, the other is being
loaded by the async thread.

The size of a single page is defined by the following macro:

    MA_RESOURCE_MANAGER_PAGE_SIZE_IN_MILLISECONDS

By default this is currently set to 1 second of audio data. This means
each page has 1 second to load which should be plenty of time. If you
need additional time, the only way to do it is increase the size of the
page by changing the value of the above macro.
2020-06-14 10:39:41 +10:00
David Reid eb27826749 Fixes for the VC6 build. 2020-06-14 10:32:23 +10:00
David Reid 33aec2fcf9 Clean up and bug fixes to the resource manager.
* ma_resource_manager_uninit() has been implemented.
  * Bug fixes and inserting and removing data buffers from the BST.
  * Some old experimental code has been removed.
  * Minor whitespace clean up.
2020-06-13 10:40:04 +10:00
David Reid 005e19f783 Use ma_result instead of ma_bool32 for some internal sync primitives. 2020-06-13 09:43:33 +10:00
David Reid 96da8dd4bd Add ma_swap_endian_uint32() in preparation for future work. 2020-06-13 09:19:36 +10:00
David Reid 373234255a Add ma_decode_from_vfs(). 2020-06-13 09:15:47 +10:00
David Reid d65d714802 Rearrange some documents in preparation for repurposing the docs folder 2020-06-13 08:49:40 +10:00
David Reid f38dcab0f2 Rename data nodes to data buffers in the resource manager. 2020-06-13 08:44:15 +10:00
David Reid 213ee9dc52 Introduce paged decoding to the resource manager in the high level API.
This enables early playback of the sound while the remainder of the
sound is loaded in the background. When the first page is loaded, the
sound can start playback. While it's playing, the rest of the sound is
loaded in a background thread. In addition, sounds no longer need to
wait for every sound prior to it in the queue to fully decode before it
is able to start - it only needs to wait for the first page of each of
the queued sounds to decode. This enables much fairer prioritization of
asynchronously loaded sounds.

This paged decoding system is *not* a true streaming solution for long
sounds. Support for true streaming will be added in future commits.
This commit is only concerned with filling in-memory buffers containing
the whole sound in an asynchronous manner.
2020-06-12 21:47:49 +10:00
David Reid 7f49fca227 Add support for initializing decoders from a VFS. 2020-06-12 21:28:08 +10:00
David Reid 37669bcc8c Fix with Vorbis decoding. 2020-06-11 08:39:29 +10:00
David Reid 8734e8f578 Work in progress on the new high level API.
* Early work on asynchronously decoding into a memory buffer. This is
    just an early implementation - there are still issues needing to be
    figured out. In particular, sounds do not automatically start until
    the entire file has been decoded. It would be good if they could
    start as soon as the first second or so of data has been decoded.
2020-06-10 22:07:16 +10:00
David Reid 86181dfac8 Updates to data sources.
* ma_data_source_read_pcm_frames and ma_data_source_seek_pcm_frames
    now return a result code and output the frames read/seeked as an
    output parameter.
  * These return MA_AT_END if the end of the data source has been
    reached. This should never be returned if the loop parameter is set
    to true.
2020-06-10 22:01:55 +10:00
David Reid 5f766acf8e Update revision history. 2020-06-08 17:15:35 +10:00
David Reid 13c7a0389f Add custom semaphore implementation for POSIX platforms.
This is needing to be done manually because Apple has decided to
deprecate anonymous semaphores from semaphore.h which we're going to
need.
2020-06-08 17:10:44 +10:00