Commit b3486043 authored by Olga Sharonova's avatar Olga Sharonova Committed by Commit Bot

Less dynamic memory allocs on RT thread in MediaStreamWebAudioSource

Reduce the frequency of dynamic memory allocation in
blink::MediaStreamWebAudioSource::ProvideInput()
which runs on a real-time audio thread.

With the fix it's one-off allocation, rather than on each call.

Bug: 1137778
Change-Id: Ibd33bc3fc8715c1cd9f49033476b97138fbfa027
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2471397
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Auto-Submit: Olga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818466}
parent 9e39554f
......@@ -54,11 +54,13 @@ void MediaStreamWebAudioSource::ProvideInput(AudioBus* bus,
// Wrap the AudioBus channel data using WebVector.
uint32_t n = bus->NumberOfChannels();
WebVector<float*> web_audio_data(n);
if (web_audio_data_.size() != n)
web_audio_data_ = WebVector<float*>(static_cast<size_t>(n));
for (uint32_t i = 0; i < n; ++i)
web_audio_data[i] = bus->Channel(i)->MutableData();
web_audio_data_[i] = bus->Channel(i)->MutableData();
web_audio_source_provider_->ProvideInput(web_audio_data, frames_to_process);
web_audio_source_provider_->ProvideInput(web_audio_data_, frames_to_process);
}
} // namespace blink
......@@ -54,6 +54,7 @@ class PLATFORM_EXPORT MediaStreamWebAudioSource : public AudioSourceProvider {
void ProvideInput(AudioBus*, uint32_t frames_to_process) override;
std::unique_ptr<WebAudioSourceProvider> web_audio_source_provider_;
WebVector<float*> web_audio_data_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamWebAudioSource);
};
......
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