mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
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.
This commit is contained in:
@@ -34,13 +34,13 @@ int main(int argc, char** argv)
|
||||
|
||||
|
||||
#if 1
|
||||
result = ma_engine_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE | MA_DATA_SOURCE_FLAG_ASYNC, NULL, &sound);
|
||||
result = ma_engine_sound_init_from_file(&engine, argv[1], MA_DATA_SOURCE_FLAG_DECODE | MA_DATA_SOURCE_FLAG_ASYNC | MA_DATA_SOURCE_FLAG_STREAM, NULL, &sound);
|
||||
if (result != MA_SUCCESS) {
|
||||
ma_engine_uninit(&engine);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*ma_data_source_seek_to_pcm_frame(sound.pDataSource, 1000000);*/
|
||||
/*ma_data_source_seek_to_pcm_frame(sound.pDataSource, 5000000);*/
|
||||
|
||||
ma_engine_sound_set_volume(&engine, &sound, 0.25f);
|
||||
ma_engine_sound_set_pitch(&engine, &sound, 1.0f);
|
||||
|
||||
+992
-219
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user