Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Unified Diff: content/renderer/media/audio_renderer_mixer_manager.cc

Issue 1809093003: Moving SwitchOutputDevice out of OutputDevice interface, eliminating OutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace RestartableAudioRendererSink with SwitchableAudioRendererSink in webmediaplayer_impl unit t… Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/audio_renderer_mixer_manager.cc
diff --git a/content/renderer/media/audio_renderer_mixer_manager.cc b/content/renderer/media/audio_renderer_mixer_manager.cc
index 309eaa848f707362555ca6b1ba2202a54c3e022b..2cc91f819e3560637dca06a58f180706ffe7b3a0 100644
--- a/content/renderer/media/audio_renderer_mixer_manager.cc
+++ b/content/renderer/media/audio_renderer_mixer_manager.cc
@@ -17,8 +17,7 @@
namespace content {
-AudioRendererMixerManager::AudioRendererMixerManager()
- : sink_for_testing_(nullptr) {}
+AudioRendererMixerManager::AudioRendererMixerManager() {}
AudioRendererMixerManager::~AudioRendererMixerManager() {
// References to AudioRendererMixers may be owned by garbage collected
@@ -35,17 +34,12 @@ media::AudioRendererMixerInput* AudioRendererMixerManager::CreateInput(
source_render_frame_id),
base::Bind(&AudioRendererMixerManager::RemoveMixer,
base::Unretained(this), source_render_frame_id),
- base::Bind(&AudioRendererMixerManager::GetHardwareOutputParams,
+ base::Bind(&AudioRendererMixerManager::GetOutputDevice,
source_render_frame_id, 0), // Session id is 0.
device_id,
security_origin);
}
-void AudioRendererMixerManager::SetAudioRendererSinkForTesting(
- media::AudioRendererSink* sink) {
- sink_for_testing_ = sink;
-}
-
media::AudioRendererMixer* AudioRendererMixerManager::GetMixer(
int source_render_frame_id,
const media::AudioParameters& params,
@@ -69,14 +63,13 @@ media::AudioRendererMixer* AudioRendererMixerManager::GetMixer(
}
scoped_refptr<media::AudioRendererSink> sink =
- sink_for_testing_
- ? sink_for_testing_
- : AudioDeviceFactory::NewOutputDevice(source_render_frame_id, 0,
- device_id, security_origin)
- .get();
+ AudioDeviceFactory::NewAudioRendererMixerSink(source_render_frame_id, 0,
+ device_id, security_origin);
+ media::OutputDevice* device = sink->GetOutputDevice();
media::OutputDeviceStatus new_device_status =
- sink->GetOutputDevice()->GetDeviceStatus();
+ device ? device->GetDeviceStatus()
+ : media::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL;
if (device_status)
*device_status = new_device_status;
if (new_device_status != media::OUTPUT_DEVICE_STATUS_OK) {
@@ -91,8 +84,7 @@ media::AudioRendererMixer* AudioRendererMixerManager::GetMixer(
media::AudioHardwareConfig::GetHighLatencyBufferSize(sample_rate, 0);
#if !defined(OS_CHROMEOS)
- media::AudioParameters hardware_params =
- sink->GetOutputDevice()->GetOutputParameters();
+ media::AudioParameters hardware_params = device->GetOutputParameters();
// If we have valid, non-fake hardware parameters, use them. Otherwise, pass
// on the input params and let the browser side handle automatic fallback.
@@ -140,28 +132,20 @@ void AudioRendererMixerManager::RemoveMixer(
}
// static
-media::AudioParameters AudioRendererMixerManager::GetHardwareOutputParams(
+media::OutputDevice* AudioRendererMixerManager::GetOutputDevice(
Guido Urdaneta 2016/03/17 17:38:24 Why have this method at all. The implementation su
o1ka 2016/03/18 10:45:40 It's a part of a future CL which leaked in; removi
int render_frame_id,
int session_id,
const std::string& device_id,
const url::Origin& security_origin) {
- media::AudioParameters params; // Invalid parameters to return by default.
-
// TODO(olka): First try to lookup an existing device (cached or belonging
- // to some mixer) and reuse it. http://crbug.com/586161
-
- // AudioOutputDevice is the only interface we have to communicate with output
- // device via IPC. So, that's how we get the parameters when there is no
- // AudioOutputDevice:
- scoped_refptr<media::AudioOutputDevice> device =
- AudioDeviceFactory::NewOutputDevice(render_frame_id, session_id,
- device_id, security_origin);
+ // to some mixer) and reuse it. If non exists - create new and cache it.
+ // http://crbug.com/586161;
- if (device->GetDeviceStatus() == media::OUTPUT_DEVICE_STATUS_OK)
- params = device->GetOutputParameters();
+ // We can't get here until we start using mixer inputs as sinks for
+ // non-mediaelement sources.
+ NOTREACHED();
- device->Stop(); // TODO(olka): temporary cash for future reuse.
- return params;
+ return nullptr;
}
AudioRendererMixerManager::MixerKey::MixerKey(

Powered by Google App Engine
This is Rietveld 408576698