Commit 9e39554f authored by Olga Sharonova's avatar Olga Sharonova Committed by Commit Bot

Remove memory allocation in RendererWebAudioDeviceImpl::Render

Bug: 1137718
Change-Id: Ia7108d84d09bc3f48058fc15989612389abd7664
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2470567
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@{#818465}
parent 67997087
...@@ -161,6 +161,9 @@ RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl( ...@@ -161,6 +161,9 @@ RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
// Specify the latency info to be passed to the browser side. // Specify the latency info to be passed to the browser side.
sink_params_.set_latency_tag(latency); sink_params_.set_latency_tag(latency);
web_audio_dest_data_ =
blink::WebVector<float*>(static_cast<size_t>(sink_params_.channels()));
} }
RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() { RendererWebAudioDeviceImpl::~RendererWebAudioDeviceImpl() {
...@@ -234,9 +237,9 @@ int RendererWebAudioDeviceImpl::Render(base::TimeDelta delay, ...@@ -234,9 +237,9 @@ int RendererWebAudioDeviceImpl::Render(base::TimeDelta delay,
int prior_frames_skipped, int prior_frames_skipped,
media::AudioBus* dest) { media::AudioBus* dest) {
// Wrap the output pointers using WebVector. // Wrap the output pointers using WebVector.
WebVector<float*> web_audio_dest_data(static_cast<size_t>(dest->channels())); CHECK_EQ(dest->channels(), sink_params_.channels());
for (int i = 0; i < dest->channels(); ++i) for (int i = 0; i < dest->channels(); ++i)
web_audio_dest_data[i] = dest->channel(i); web_audio_dest_data_[i] = dest->channel(i);
if (!delay.is_zero()) { // Zero values are send at the first call. if (!delay.is_zero()) { // Zero values are send at the first call.
// Substruct the bus duration to get hardware delay. // Substruct the bus duration to get hardware delay.
...@@ -246,7 +249,7 @@ int RendererWebAudioDeviceImpl::Render(base::TimeDelta delay, ...@@ -246,7 +249,7 @@ int RendererWebAudioDeviceImpl::Render(base::TimeDelta delay,
DCHECK_GE(delay, base::TimeDelta()); DCHECK_GE(delay, base::TimeDelta());
client_callback_->Render( client_callback_->Render(
web_audio_dest_data, dest->frames(), delay.InSecondsF(), web_audio_dest_data_, dest->frames(), delay.InSecondsF(),
(delay_timestamp - base::TimeTicks()).InSecondsF(), prior_frames_skipped); (delay_timestamp - base::TimeTicks()).InSecondsF(), prior_frames_skipped);
return dest->frames(); return dest->frames();
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "third_party/blink/public/common/tokens/tokens.h" #include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/platform/web_audio_device.h" #include "third_party/blink/public/platform/web_audio_device.h"
#include "third_party/blink/public/platform/web_audio_latency_hint.h" #include "third_party/blink/public/platform/web_audio_latency_hint.h"
#include "third_party/blink/public/platform/web_vector.h"
namespace base { namespace base {
class SingleThreadTaskRunner; class SingleThreadTaskRunner;
...@@ -97,6 +98,9 @@ class CONTENT_EXPORT RendererWebAudioDeviceImpl ...@@ -97,6 +98,9 @@ class CONTENT_EXPORT RendererWebAudioDeviceImpl
// Weak reference to the callback into WebKit code. // Weak reference to the callback into WebKit code.
blink::WebAudioDevice::RenderCallback* const client_callback_; blink::WebAudioDevice::RenderCallback* const client_callback_;
// Used to wrap AudioBus to be passed into |client_callback_|.
blink::WebVector<float*> web_audio_dest_data_;
// To avoid the need for locking, ensure the control methods of the // To avoid the need for locking, ensure the control methods of the
// blink::WebAudioDevice implementation are called on the same thread. // blink::WebAudioDevice implementation are called on the same thread.
base::ThreadChecker thread_checker_; base::ThreadChecker thread_checker_;
......
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