Commit d2cffd18 authored by David Reid's avatar David Reid

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.
parent eb278267
......@@ -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);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment