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);
|
DCHECK(num_samples > 0);
|
||||||
|
|
||||||
for (size_t i = 0; i < num_frames * kChannelCount;) {
|
for (size_t i = 0; i < num_frames * kChannelCount;) {
|
||||||
|
if (src_index < num_samples) {
|
||||||
// Mix the 1st channel.
|
// Mix the 1st channel.
|
||||||
output_buffer[i++] += src[0][src_index] * amplitude;
|
output_buffer[i++] += src[0][src_index] * amplitude;
|
||||||
|
|
||||||
|
@ -229,18 +230,16 @@ void AudioMixer::RenderAudio(float* output_buffer, size_t num_frames) {
|
||||||
accumulator += step;
|
accumulator += step;
|
||||||
src_index += accumulator / 100;
|
src_index += accumulator / 100;
|
||||||
accumulator %= 100;
|
accumulator %= 100;
|
||||||
|
} else {
|
||||||
// Remove, loop or stream if the source data is consumed
|
|
||||||
if (src_index >= num_samples) {
|
|
||||||
src_index %= num_samples;
|
|
||||||
|
|
||||||
if (audio_bus->EndOfStream()) {
|
if (audio_bus->EndOfStream()) {
|
||||||
|
src_index %= num_samples;
|
||||||
marked_for_removal = !(flags & kLoop);
|
marked_for_removal = !(flags & kLoop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!it->get()->streaming_in_progress.load(
|
if (!it->get()->streaming_in_progress.load(
|
||||||
std::memory_order_acquire)) {
|
std::memory_order_acquire)) {
|
||||||
|
src_index %= num_samples;
|
||||||
it->get()->streaming_in_progress.store(true,
|
it->get()->streaming_in_progress.store(true,
|
||||||
std::memory_order_relaxed);
|
std::memory_order_relaxed);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue