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

Side by Side Diff: content/renderer/media/audio_renderer_mixer_manager.cc

Issue 1580493004: Plumb audio focus support for spitzer clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate_hookup
Patch Set: Fix crash, plumb. Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/audio_renderer_mixer_manager.h" 5 #include "content/renderer/media/audio_renderer_mixer_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 media::AudioRendererSink* sink) { 42 media::AudioRendererSink* sink) {
43 sink_for_testing_ = sink; 43 sink_for_testing_ = sink;
44 } 44 }
45 45
46 media::AudioRendererMixer* AudioRendererMixerManager::GetMixer( 46 media::AudioRendererMixer* AudioRendererMixerManager::GetMixer(
47 int source_render_frame_id, 47 int source_render_frame_id,
48 const media::AudioParameters& params, 48 const media::AudioParameters& params,
49 const std::string& device_id, 49 const std::string& device_id,
50 const url::Origin& security_origin, 50 const url::Origin& security_origin,
51 media::OutputDeviceStatus* device_status) { 51 media::OutputDeviceStatus* device_status) {
52 // Effects are not passed through to output creation, so ensure none are set.
53 DCHECK_EQ(params.effects(), media::AudioParameters::NO_EFFECTS);
54
55 const MixerKey key(source_render_frame_id, params, device_id, 52 const MixerKey key(source_render_frame_id, params, device_id,
56 security_origin); 53 security_origin);
57 base::AutoLock auto_lock(mixers_lock_); 54 base::AutoLock auto_lock(mixers_lock_);
58 55
59 AudioRendererMixerMap::iterator it = mixers_.find(key); 56 AudioRendererMixerMap::iterator it = mixers_.find(key);
60 if (it != mixers_.end()) { 57 if (it != mixers_.end()) {
61 if (device_status) 58 if (device_status)
62 *device_status = media::OUTPUT_DEVICE_STATUS_OK; 59 *device_status = media::OUTPUT_DEVICE_STATUS_OK;
63 60
64 it->second.ref_count++; 61 it->second.ref_count++;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 hardware_params) 98 hardware_params)
102 : params.frames_per_buffer(); 99 : params.frames_per_buffer();
103 100
104 // Create output parameters based on the audio hardware configuration for 101 // Create output parameters based on the audio hardware configuration for
105 // passing on to the output sink. Force to 16-bit output for now since we 102 // passing on to the output sink. Force to 16-bit output for now since we
106 // know that works everywhere; ChromeOS does not support other bit depths. 103 // know that works everywhere; ChromeOS does not support other bit depths.
107 media::AudioParameters output_params( 104 media::AudioParameters output_params(
108 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), 105 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(),
109 sample_rate, 16, buffer_size); 106 sample_rate, 16, buffer_size);
110 107
108 // Pass through any effects requests to the output device.
109 output_params.set_effects(params.effects());
110
111 // If we've created invalid output parameters, simply pass on the input 111 // If we've created invalid output parameters, simply pass on the input
112 // params and let the browser side handle automatic fallback. 112 // params and let the browser side handle automatic fallback.
113 if (!output_params.IsValid()) 113 if (!output_params.IsValid())
114 output_params = params; 114 output_params = params;
115 115
116 media::AudioRendererMixer* mixer = 116 media::AudioRendererMixer* mixer =
117 new media::AudioRendererMixer(output_params, sink); 117 new media::AudioRendererMixer(output_params, sink);
118 AudioRendererMixerReference mixer_reference = { mixer, 1 }; 118 AudioRendererMixerReference mixer_reference = { mixer, 1 };
119 mixers_[key] = mixer_reference; 119 mixers_[key] = mixer_reference;
120 return mixer; 120 return mixer;
(...skipping 23 matching lines...) Expand all
144 int source_render_frame_id, 144 int source_render_frame_id,
145 const media::AudioParameters& params, 145 const media::AudioParameters& params,
146 const std::string& device_id, 146 const std::string& device_id,
147 const url::Origin& security_origin) 147 const url::Origin& security_origin)
148 : source_render_frame_id(source_render_frame_id), 148 : source_render_frame_id(source_render_frame_id),
149 params(params), 149 params(params),
150 device_id(device_id), 150 device_id(device_id),
151 security_origin(security_origin) {} 151 security_origin(security_origin) {}
152 152
153 } // namespace content 153 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698