Commit Graph

2822 Commits

Author SHA1 Message Date
David Reid e0bfc59bc0 Restructuring in preparation for future work. 2021-07-01 15:22:13 +10:00
David Reid c54bb96964 Rename some config variables. 2021-07-01 14:58:05 +10:00
David Reid 6ec9a1c1fb Minor code restructure. 2021-07-01 14:55:20 +10:00
David Reid 9f4460797f Fix memory leaks. 2021-07-01 14:36:22 +10:00
David Reid 022b38517e Simplify the custom_decoder example. 2021-07-01 13:46:43 +10:00
David Reid 6dbb31849b Fix copy/paste errors. 2021-07-01 10:08:22 +10:00
David Reid d80c41f414 Update wording in comments. 2021-07-01 06:45:55 +10:00
David Reid a70515a96d Add example for using custom decoders with the resource manager. 2021-06-30 20:59:16 +10:00
David Reid 9ed296b3b9 Fix a bug where custom decoding backends aren't being used. 2021-06-30 20:58:43 +10:00
David Reid 52f471ae43 Try to standardize the use of MA_AT_END.
With this change, MA_AT_END should only ever be returned the number of
bytes or frames returned is equal to 0.
2021-06-30 20:58:07 +10:00
David Reid 07fbb6ac6d Update custom_decoder example. 2021-06-30 20:43:05 +10:00
David Reid 998bd995bc Add libvorbis and libopus data sources to the extras folder. 2021-06-30 20:42:43 +10:00
David Reid 54aae74d6e Rename ma_engine_config_init_default() to ma_engine_config_init(). 2021-06-30 20:30:57 +10:00
David Reid 8567a4bc37 Hook up custom decoders to the resource manager. 2021-06-30 16:36:36 +10:00
David Reid 4559253587 Remove the MA_END_OF_FILE result code.
Use MA_AT_END instead. Use of MA_END_OF_FILE is too easily confused
with MA_AT_END, and MA_AT_END is a more generally applicable.
2021-06-30 12:30:31 +10:00
David Reid 1c179fb475 Try fixing an infinite loop. 2021-06-30 12:17:21 +10:00
David Reid 38f2754edb Fix compilation errors on 32-bit. 2021-06-30 06:10:44 +10:00
David Reid dad754b745 Add support for custom decoding backends.
Public issue https://github.com/mackron/miniaudio/issues/311
2021-06-27 21:43:31 +10:00
David Reid fca4d5c16a Fix an edge case where async notifications are not getting fired. 2021-06-26 15:07:24 +10:00
David Reid 1597f6c041 Update test code. 2021-06-26 13:49:55 +10:00
David Reid 5df38de8ad Improvements to the async notification system.
These changes expand on the notification system which allows a program
to be notified on when a sound has reached various stages in the async
loading process. There are two stages:

  1) Decoder initialization
  2) Completion of decoding

The previous system has the following problems:

  * There's no way to wait on only the decoder initialization
  * The callback doesn't work well if you want to pass it through
    multiple layers. Example:
    - Client wants to wait for the sound to complete
    - Pass the callback into ma_sound_init_from_file(), which passes
      it into ma_resource_manager_data_source_init(). The latter will
      fire the callback, but will do so before ma_sound_init_from_file()
      has returned. The client will think the sound has finished
      loading and will reference the `ma_sound` object before it's
      completed initialization.
  * It's not easy to wait on object in bulk. Clients may want to pump a
    bunch of ASYNC sounds in one go, and then just have a single
    notification for the group.

The new system introduces the notion of a "fence". A fence contains a
counter which is incremented and decremented from anywhere. It also has
a wait routine which will block until the counter hits zero:

  ma_fence_acquire() - Increments the counter
  ma_fence_release() - Decrements the counter
  ma_fence_wait()    - Blocks until the counter is 0.

The fence system can be used to wait for a number of sounds to finish
decoding rather than only one at a time, which is the case with the
previous system. Example:

```
/* Fences must be initialized before use. */
ma_fence_init(&fence);

/* Loop over each sound and start loading them, passing in the fence. */
for each sound in sounds
{
    flags = MA_DATA_SOURCE_FLAG_DECODE | MA_DATA_SOURCE_FLAG_ASYNC;
    ma_sound_init_from_file(&engine, pFilePath, flags, &group, &fence, &sound);
}

... do some other stuff while sounds are loading ...

/* Wait for sounds to finish loading. */
ma_fence_wait(&fence);
ma_fence_uninit(&fence);
```

The above example initializes a sound, but it can also be used by
resource managed data sources. When loading data sources directly from
the resource manager, you can specify a second fence which is used to
only wait until the internal decoder has been initialized.
2021-06-26 13:24:22 +10:00
David Reid b4d6c37d13 Simplify async notifications. 2021-06-26 09:58:29 +10:00
David Reid ea84294d97 Fix the custom_backend example. 2021-06-24 19:23:30 +10:00
David Reid 5551dc67e1 Update wording in example. 2021-06-24 19:07:33 +10:00
David Reid 595ba3f729 Update wording in example. 2021-06-24 18:52:33 +10:00
David Reid 45d07688e5 Add ma_fence object in preparation for changes to async notifications. 2021-06-24 17:51:15 +10:00
David Reid cf2c9f2533 PulseAudio: Attempt to fix a division by zero error.
Public issue https://github.com/mackron/miniaudio/issues/323
2021-06-22 17:41:41 +10:00
David Reid cb9cbeba04 Fix a copy/paste error. 2021-06-20 20:33:23 +10:00
David Reid ef0abd01b7 Add delay effect.
This can be used for echo as well as a simple delay.
2021-06-20 20:15:57 +10:00
David Reid af72639d43 Fix a copy/paste error. 2021-06-20 20:13:49 +10:00
David Reid ac0afa061f Add example for the vocoder node. 2021-06-20 16:32:46 +10:00
David Reid a62def6d53 Add reverb node to examples.
This uses https://github.com/blastbay/verblib to achieve the effect.
2021-06-20 14:41:30 +10:00
David Reid f62e0d3b68 Rearrange some code for consistency with other code. 2021-06-20 14:36:07 +10:00
David Reid 4442f926c9 Fix compilation errors. 2021-06-20 14:35:42 +10:00
David Reid f96071f12d Add some filter nodes.
* Biquad
  * LPF
  * HPF
  * BPF
  * Notch
  * Peak
  * Low / High Shelf
2021-06-20 10:29:19 +10:00
David Reid a95c066218 Add alternate names for some structs.
This is in preparation for some work in the high level API.
2021-06-20 10:20:12 +10:00
David Reid 651520216d Fix a compilation warning on 32-bit. 2021-06-19 16:36:30 +10:00
David Reid 4257e070be Add ma_engine_set_time(). 2021-06-19 16:21:43 +10:00
David Reid 4be6201142 Merge branch 'dev' of https://github.com/mackron/miniaudio into dev 2021-06-19 15:13:59 +10:00
David Reid efc2fdcba3 Fix a seeking bug for sounds. 2021-06-19 15:13:47 +10:00
David Reid f24967f952 Comment out some code to try and fix an error on iOS.
Public issue https://github.com/mackron/miniaudio/issues/101
2021-06-17 18:05:06 +10:00
David Reid 2d43f4d01c Add support for data sources without support for seeking. 2021-06-13 18:05:20 +10:00
David Reid 9be681b848 Return MA_AT_END from ma_(pcm_)rb_commit_read/write(). 2021-06-13 18:04:57 +10:00
David Reid b48cb209e6 Fix an infinite loop when reading 0 frames from a data data buffer. 2021-06-13 14:50:27 +10:00
David Reid a26d41ed11 Fix a bug relating to the handling of looping sounds. 2021-06-13 12:50:27 +10:00
David Reid 7858e098f5 Add some helper functions to ma_audio_buffer/_ref. 2021-06-13 12:42:06 +10:00
David Reid b3d0858edf Fix a bug where data buffers never return MA_AT_END. 2021-06-13 07:24:40 +10:00
David Reid 7a9ce3d0d3 Fix a bug where MA_AT_END is not getting returned by audio buffers. 2021-06-13 07:17:26 +10:00
David Reid 73e1589afa Update dr_wav.
Public issue https://github.com/mackron/miniaudio/issues/320
2021-06-11 19:50:42 +10:00
David Reid 8234df87c9 Fix a possible double file close when decoder initialization fails.
Public issue https://github.com/mackron/miniaudio/issues/319
2021-06-11 19:03:01 +10:00