Commit 56b0b3ff authored by xians@chromium.org's avatar xians@chromium.org

Remove unused RenderIO() interface.

BUG=337096
TEST=bots

Review URL: https://codereview.chromium.org/293673004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271536 0039d316-1c4b-4281-b951-d872f2087c98
parent 6635c886
...@@ -57,7 +57,7 @@ void RendererWebAudioDeviceImpl::start() { ...@@ -57,7 +57,7 @@ void RendererWebAudioDeviceImpl::start() {
output_device_ = AudioDeviceFactory::NewOutputDevice( output_device_ = AudioDeviceFactory::NewOutputDevice(
render_view ? render_view->routing_id() : MSG_ROUTING_NONE, render_view ? render_view->routing_id() : MSG_ROUTING_NONE,
render_frame ? render_frame->GetRoutingID(): MSG_ROUTING_NONE); render_frame ? render_frame->GetRoutingID(): MSG_ROUTING_NONE);
output_device_->InitializeUnifiedStream(params_, this, session_id_); output_device_->InitializeWithSessionId(params_, this, session_id_);
output_device_->Start(); output_device_->Start();
// Note: Default behavior is to auto-play on start. // Note: Default behavior is to auto-play on start.
} }
...@@ -77,32 +77,22 @@ double RendererWebAudioDeviceImpl::sampleRate() { ...@@ -77,32 +77,22 @@ double RendererWebAudioDeviceImpl::sampleRate() {
int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest, int RendererWebAudioDeviceImpl::Render(media::AudioBus* dest,
int audio_delay_milliseconds) { int audio_delay_milliseconds) {
RenderIO(NULL, dest, audio_delay_milliseconds);
return dest->frames();
}
void RendererWebAudioDeviceImpl::RenderIO(media::AudioBus* source,
media::AudioBus* dest,
int audio_delay_milliseconds) {
// Make the client callback for an I/O cycle.
if (client_callback_) { if (client_callback_) {
// Wrap the input pointers using WebVector.
size_t source_channels =
source ? static_cast<size_t>(source->channels()) : 0;
WebVector<float*> web_audio_source_data(source_channels);
for (size_t i = 0; i < source_channels; ++i)
web_audio_source_data[i] = source->channel(i);
// Wrap the output pointers using WebVector. // Wrap the output pointers using WebVector.
WebVector<float*> web_audio_dest_data( WebVector<float*> web_audio_dest_data(
static_cast<size_t>(dest->channels())); static_cast<size_t>(dest->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);
// TODO(xians): Remove the following |web_audio_source_data| after
// changing the blink interface.
WebVector<float*> web_audio_source_data(static_cast<size_t>(0));
client_callback_->render(web_audio_source_data, client_callback_->render(web_audio_source_data,
web_audio_dest_data, web_audio_dest_data,
dest->frames()); dest->frames());
} }
return dest->frames();
} }
void RendererWebAudioDeviceImpl::OnRenderError() { void RendererWebAudioDeviceImpl::OnRenderError() {
......
...@@ -36,10 +36,6 @@ class RendererWebAudioDeviceImpl ...@@ -36,10 +36,6 @@ class RendererWebAudioDeviceImpl
virtual int Render(media::AudioBus* dest, virtual int Render(media::AudioBus* dest,
int audio_delay_milliseconds) OVERRIDE; int audio_delay_milliseconds) OVERRIDE;
virtual void RenderIO(media::AudioBus* source,
media::AudioBus* dest,
int audio_delay_milliseconds) OVERRIDE;
virtual void OnRenderError() OVERRIDE; virtual void OnRenderError() OVERRIDE;
private: private:
......
...@@ -324,10 +324,8 @@ bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) { ...@@ -324,10 +324,8 @@ bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {
sink_ = AudioDeviceFactory::NewOutputDevice( sink_ = AudioDeviceFactory::NewOutputDevice(
source_render_view_id_, source_render_frame_id_); source_render_view_id_, source_render_frame_id_);
// TODO(tommi): Rename InitializeUnifiedStream to rather reflect association
// with a session.
DCHECK_GE(session_id_, 0); DCHECK_GE(session_id_, 0);
sink_->InitializeUnifiedStream(sink_params_, this, session_id_); sink_->InitializeWithSessionId(sink_params_, this, session_id_);
sink_->Start(); sink_->Start();
......
...@@ -287,7 +287,7 @@ void WebRtcLocalAudioRenderer::MaybeStartSink() { ...@@ -287,7 +287,7 @@ void WebRtcLocalAudioRenderer::MaybeStartSink() {
return; return;
DVLOG(1) << "WebRtcLocalAudioRenderer::MaybeStartSink() -- Starting sink_."; DVLOG(1) << "WebRtcLocalAudioRenderer::MaybeStartSink() -- Starting sink_.";
sink_->InitializeUnifiedStream(sink_params_, this, session_id_); sink_->InitializeWithSessionId(sink_params_, this, session_id_);
sink_->Start(); sink_->Start();
sink_started_ = true; sink_started_ = true;
UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates", UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates",
......
...@@ -32,7 +32,6 @@ class AudioOutputDevice::AudioThreadCallback ...@@ -32,7 +32,6 @@ class AudioOutputDevice::AudioThreadCallback
private: private:
AudioRendererSink::RenderCallback* render_callback_; AudioRendererSink::RenderCallback* render_callback_;
scoped_ptr<AudioBus> input_bus_;
scoped_ptr<AudioBus> output_bus_; scoped_ptr<AudioBus> output_bus_;
DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback); DISALLOW_COPY_AND_ASSIGN(AudioThreadCallback);
}; };
...@@ -57,10 +56,10 @@ AudioOutputDevice::AudioOutputDevice( ...@@ -57,10 +56,10 @@ AudioOutputDevice::AudioOutputDevice(
COMPILE_ASSERT(PAUSED < PLAYING, invalid_enum_value_assignment_3); COMPILE_ASSERT(PAUSED < PLAYING, invalid_enum_value_assignment_3);
} }
void AudioOutputDevice::InitializeUnifiedStream(const AudioParameters& params, void AudioOutputDevice::InitializeWithSessionId(const AudioParameters& params,
RenderCallback* callback, RenderCallback* callback,
int session_id) { int session_id) {
DCHECK(!callback_) << "Calling InitializeUnifiedStream() twice?"; DCHECK(!callback_) << "Calling InitializeWithSessionId() twice?";
DCHECK(params.IsValid()); DCHECK(params.IsValid());
audio_parameters_ = params; audio_parameters_ = params;
callback_ = callback; callback_ = callback;
...@@ -69,7 +68,7 @@ void AudioOutputDevice::InitializeUnifiedStream(const AudioParameters& params, ...@@ -69,7 +68,7 @@ void AudioOutputDevice::InitializeUnifiedStream(const AudioParameters& params,
void AudioOutputDevice::Initialize(const AudioParameters& params, void AudioOutputDevice::Initialize(const AudioParameters& params,
RenderCallback* callback) { RenderCallback* callback) {
InitializeUnifiedStream(params, callback, 0); InitializeWithSessionId(params, callback, 0);
} }
AudioOutputDevice::~AudioOutputDevice() { AudioOutputDevice::~AudioOutputDevice() {
...@@ -279,26 +278,10 @@ AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() { ...@@ -279,26 +278,10 @@ AudioOutputDevice::AudioThreadCallback::~AudioThreadCallback() {
void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() { void AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
CHECK_EQ(total_segments_, 1); CHECK_EQ(total_segments_, 1);
CHECK(shared_memory_.Map(memory_length_)); CHECK(shared_memory_.Map(memory_length_));
DCHECK_EQ(memory_length_, AudioBus::CalculateMemorySize(audio_parameters_));
// Calculate output and input memory size.
int output_memory_size = AudioBus::CalculateMemorySize(audio_parameters_);
int input_channels = audio_parameters_.input_channels();
int frames = audio_parameters_.frames_per_buffer();
int input_memory_size = AudioBus::CalculateMemorySize(input_channels, frames);
int io_size = output_memory_size + input_memory_size;
DCHECK_EQ(memory_length_, io_size);
output_bus_ = output_bus_ =
AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory()); AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory());
if (input_channels > 0) {
// The input data is after the output data.
char* input_data =
static_cast<char*>(shared_memory_.memory()) + output_memory_size;
input_bus_ = AudioBus::WrapMemory(input_channels, frames, input_data);
}
} }
// Called whenever we receive notifications about pending data. // Called whenever we receive notifications about pending data.
...@@ -315,13 +298,7 @@ void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) { ...@@ -315,13 +298,7 @@ void AudioOutputDevice::AudioThreadCallback::Process(int pending_data) {
// Update the audio-delay measurement then ask client to render audio. Since // Update the audio-delay measurement then ask client to render audio. Since
// |output_bus_| is wrapping the shared memory the Render() call is writing // |output_bus_| is wrapping the shared memory the Render() call is writing
// directly into the shared memory. // directly into the shared memory.
int input_channels = audio_parameters_.input_channels(); render_callback_->Render(output_bus_.get(), audio_delay_milliseconds);
if (input_bus_ && input_channels > 0) {
render_callback_->RenderIO(
input_bus_.get(), output_bus_.get(), audio_delay_milliseconds);
} else {
render_callback_->Render(output_bus_.get(), audio_delay_milliseconds);
}
} }
} // namespace media. } // namespace media.
...@@ -86,10 +86,7 @@ class MEDIA_EXPORT AudioOutputDevice ...@@ -86,10 +86,7 @@ class MEDIA_EXPORT AudioOutputDevice
// number of input channels which will be at the same sample-rate // number of input channels which will be at the same sample-rate
// and buffer-size as the output as specified in |params|. |session_id| is // and buffer-size as the output as specified in |params|. |session_id| is
// used for the browser to select the correct input device. // used for the browser to select the correct input device.
// In this case, the callback's RenderIO() method will be called instead void InitializeWithSessionId(const AudioParameters& params,
// of Render(), providing the synchronized input data at the same time as
// when new output data is to be rendered.
void InitializeUnifiedStream(const AudioParameters& params,
RenderCallback* callback, RenderCallback* callback,
int session_id); int session_id);
......
...@@ -37,9 +37,6 @@ class MockRenderCallback : public AudioRendererSink::RenderCallback { ...@@ -37,9 +37,6 @@ class MockRenderCallback : public AudioRendererSink::RenderCallback {
virtual ~MockRenderCallback() {} virtual ~MockRenderCallback() {}
MOCK_METHOD2(Render, int(AudioBus* dest, int audio_delay_milliseconds)); MOCK_METHOD2(Render, int(AudioBus* dest, int audio_delay_milliseconds));
MOCK_METHOD3(RenderIO, void(AudioBus* source,
AudioBus* dest,
int audio_delay_milliseconds));
MOCK_METHOD0(OnRenderError, void()); MOCK_METHOD0(OnRenderError, void());
}; };
...@@ -114,8 +111,6 @@ class AudioOutputDeviceTest ...@@ -114,8 +111,6 @@ class AudioOutputDeviceTest
private: private:
int CalculateMemorySize(); int CalculateMemorySize();
const bool synchronized_io_;
const int input_channels_;
SharedMemory shared_memory_; SharedMemory shared_memory_;
CancelableSyncSocket browser_socket_; CancelableSyncSocket browser_socket_;
CancelableSyncSocket renderer_socket_; CancelableSyncSocket renderer_socket_;
...@@ -124,24 +119,14 @@ class AudioOutputDeviceTest ...@@ -124,24 +119,14 @@ class AudioOutputDeviceTest
}; };
int AudioOutputDeviceTest::CalculateMemorySize() { int AudioOutputDeviceTest::CalculateMemorySize() {
// Calculate output and input memory size. // Calculate output memory size.
int output_memory_size = return AudioBus::CalculateMemorySize(default_audio_parameters_);
AudioBus::CalculateMemorySize(default_audio_parameters_);
int frames = default_audio_parameters_.frames_per_buffer();
int input_memory_size =
AudioBus::CalculateMemorySize(input_channels_, frames);
return output_memory_size + input_memory_size;
} }
AudioOutputDeviceTest::AudioOutputDeviceTest() AudioOutputDeviceTest::AudioOutputDeviceTest() {
: synchronized_io_(GetParam()),
input_channels_(synchronized_io_ ? 2 : 0) {
default_audio_parameters_.Reset( default_audio_parameters_.Reset(
AudioParameters::AUDIO_PCM_LINEAR, AudioParameters::AUDIO_PCM_LINEAR,
CHANNEL_LAYOUT_STEREO, 2, input_channels_, CHANNEL_LAYOUT_STEREO, 2, 0, 48000, 16, 1024);
48000, 16, 1024);
audio_output_ipc_ = new MockAudioOutputIPC(); audio_output_ipc_ = new MockAudioOutputIPC();
audio_device_ = new AudioOutputDevice( audio_device_ = new AudioOutputDevice(
...@@ -207,18 +192,11 @@ void AudioOutputDeviceTest::ExpectRenderCallback() { ...@@ -207,18 +192,11 @@ void AudioOutputDeviceTest::ExpectRenderCallback() {
// writing the interleaved audio data into the shared memory section. // writing the interleaved audio data into the shared memory section.
// So, for the sake of this test, we consider the call to Render a sign // So, for the sake of this test, we consider the call to Render a sign
// of success and quit the loop. // of success and quit the loop.
if (synchronized_io_) { const int kNumberOfFramesToProcess = 0;
// For synchronized I/O, we expect RenderIO(). EXPECT_CALL(callback_, Render(_, _))
EXPECT_CALL(callback_, RenderIO(_, _, _)) .WillOnce(DoAll(
.WillOnce(QuitLoop(io_loop_.message_loop_proxy())); QuitLoop(io_loop_.message_loop_proxy()),
} else { Return(kNumberOfFramesToProcess)));
// For output only we expect Render().
const int kNumberOfFramesToProcess = 0;
EXPECT_CALL(callback_, Render(_, _))
.WillOnce(DoAll(
QuitLoop(io_loop_.message_loop_proxy()),
Return(kNumberOfFramesToProcess)));
}
} }
void AudioOutputDeviceTest::WaitUntilRenderCallback() { void AudioOutputDeviceTest::WaitUntilRenderCallback() {
...@@ -280,6 +258,5 @@ TEST_P(AudioOutputDeviceTest, CreateStream) { ...@@ -280,6 +258,5 @@ TEST_P(AudioOutputDeviceTest, CreateStream) {
} }
INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false));
INSTANTIATE_TEST_CASE_P(RenderIO, AudioOutputDeviceTest, Values(true));
} // namespace media. } // namespace media.
...@@ -28,11 +28,6 @@ class AudioRendererSink ...@@ -28,11 +28,6 @@ class AudioRendererSink
// number of frames filled. // number of frames filled.
virtual int Render(AudioBus* dest, int audio_delay_milliseconds) = 0; virtual int Render(AudioBus* dest, int audio_delay_milliseconds) = 0;
// Synchronized audio I/O - see InitializeIO() below.
virtual void RenderIO(AudioBus* source,
AudioBus* dest,
int audio_delay_milliseconds) {}
// Signals an error has occurred. // Signals an error has occurred.
virtual void OnRenderError() = 0; virtual void OnRenderError() = 0;
......
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