Commit 99fea233 authored by David Reid's avatar David Reid

Fix a bug when mixing a data source using mmap mode.

This was causing mmaped data sources to not loop if they coincidentally
reached the end at the same time as the final output frame was written.
parent 0be72c02
...@@ -2557,10 +2557,14 @@ static ma_result ma_mixer_mix_data_source_mmap(ma_mixer* pMixer, ma_data_source* ...@@ -2557,10 +2557,14 @@ static ma_result ma_mixer_mix_data_source_mmap(ma_mixer* pMixer, ma_data_source*
result = ma_data_source_unmap(pDataSource, framesMapped); /* Do this last because the result code is used below to determine whether or not we need to loop. */ result = ma_data_source_unmap(pDataSource, framesMapped); /* Do this last because the result code is used below to determine whether or not we need to loop. */
} }
totalFramesProcessed += framesToProcess;
pRunningAccumulationBuffer = ma_offset_ptr(pRunningAccumulationBuffer, framesToProcess * ma_get_accumulation_bytes_per_frame(pMixer->format, pMixer->channels));
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
if (result == MA_AT_END) { if (result == MA_AT_END) {
if (loop) { if (loop) {
ma_data_source_seek_to_pcm_frame(pDataSource, 0); ma_data_source_seek_to_pcm_frame(pDataSource, 0);
result = MA_SUCCESS; /* Make sure we don't return MA_AT_END which will happen if we conicidentally hit the end of the data source at the same time as we finish outputting. */
} else { } else {
break; /* We've reached the end and we're not looping. */ break; /* We've reached the end and we're not looping. */
} }
...@@ -2568,9 +2572,6 @@ static ma_result ma_mixer_mix_data_source_mmap(ma_mixer* pMixer, ma_data_source* ...@@ -2568,9 +2572,6 @@ static ma_result ma_mixer_mix_data_source_mmap(ma_mixer* pMixer, ma_data_source*
return result; /* An error occurred. */ return result; /* An error occurred. */
} }
} }
totalFramesProcessed += framesToProcess;
pRunningAccumulationBuffer = ma_offset_ptr(pRunningAccumulationBuffer, framesToProcess * ma_get_accumulation_bytes_per_frame(pMixer->format, pMixer->channels));
} }
return result; return result;
......
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