mirror of https://github.com/auygun/kaliber.git
Do not reset source index when streaming is in progress
This commit is contained in:
parent
467e73d3a8
commit
b07ce8514e
|
@ -204,6 +204,7 @@ void AudioMixer::RenderAudio(float* output_buffer, size_t num_frames) {
|
|||
DCHECK(num_samples > 0);
|
||||
|
||||
for (size_t i = 0; i < num_frames * kChannelCount;) {
|
||||
if (src_index < num_samples) {
|
||||
// Mix the 1st channel.
|
||||
output_buffer[i++] += src[0][src_index] * amplitude;
|
||||
|
||||
|
@ -229,18 +230,16 @@ void AudioMixer::RenderAudio(float* output_buffer, size_t num_frames) {
|
|||
accumulator += step;
|
||||
src_index += accumulator / 100;
|
||||
accumulator %= 100;
|
||||
|
||||
// Remove, loop or stream if the source data is consumed
|
||||
if (src_index >= num_samples) {
|
||||
src_index %= num_samples;
|
||||
|
||||
} else {
|
||||
if (audio_bus->EndOfStream()) {
|
||||
src_index %= num_samples;
|
||||
marked_for_removal = !(flags & kLoop);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!it->get()->streaming_in_progress.load(
|
||||
std::memory_order_acquire)) {
|
||||
src_index %= num_samples;
|
||||
it->get()->streaming_in_progress.store(true,
|
||||
std::memory_order_relaxed);
|
||||
|
||||
|
|
Loading…
Reference in New Issue