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

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

Issue 12383016: Merge AssociateStreamWithProducer message into CreateStream message for both audio output and input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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 | Annotate | Revision Log
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "content/renderer/media/audio_device_factory.h" 9 #include "content/renderer/media/audio_device_factory.h"
10 #include "content/renderer/media/renderer_audio_output_device.h" 10 #include "media/audio/audio_output_device.h"
11 #include "media/base/audio_hardware_config.h" 11 #include "media/base/audio_hardware_config.h"
12 #include "media/base/audio_renderer_mixer.h" 12 #include "media/base/audio_renderer_mixer.h"
13 #include "media/base/audio_renderer_mixer_input.h" 13 #include "media/base/audio_renderer_mixer_input.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 AudioRendererMixerManager::AudioRendererMixerManager( 17 AudioRendererMixerManager::AudioRendererMixerManager(
18 media::AudioHardwareConfig* hardware_config) 18 media::AudioHardwareConfig* hardware_config)
19 : hardware_config_(hardware_config), 19 : hardware_config_(hardware_config),
20 sink_for_testing_(NULL) { 20 sink_for_testing_(NULL) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // If we've created invalid output parameters, simply pass on the input params 70 // If we've created invalid output parameters, simply pass on the input params
71 // and let the browser side handle automatic fallback. 71 // and let the browser side handle automatic fallback.
72 if (!output_params.IsValid()) 72 if (!output_params.IsValid())
73 output_params = params; 73 output_params = params;
74 74
75 media::AudioRendererMixer* mixer; 75 media::AudioRendererMixer* mixer;
76 if (sink_for_testing_) { 76 if (sink_for_testing_) {
77 mixer = new media::AudioRendererMixer( 77 mixer = new media::AudioRendererMixer(
78 params, output_params, sink_for_testing_); 78 params, output_params, sink_for_testing_);
79 } else { 79 } else {
80 scoped_refptr<RendererAudioOutputDevice> device = 80 mixer = new media::AudioRendererMixer(
81 AudioDeviceFactory::NewOutputDevice(); 81 params, output_params, AudioDeviceFactory::NewOutputDevice(
82 device->SetSourceRenderView(source_render_view_id); 82 source_render_view_id));
83 mixer = new media::AudioRendererMixer(params, output_params, device);
84 } 83 }
85 84
86 AudioRendererMixerReference mixer_reference = { mixer, 1 }; 85 AudioRendererMixerReference mixer_reference = { mixer, 1 };
87 mixers_[key] = mixer_reference; 86 mixers_[key] = mixer_reference;
88 return mixer; 87 return mixer;
89 } 88 }
90 89
91 void AudioRendererMixerManager::RemoveMixer( 90 void AudioRendererMixerManager::RemoveMixer(
92 int source_render_view_id, 91 int source_render_view_id,
93 const media::AudioParameters& params) { 92 const media::AudioParameters& params) {
94 const MixerKey key(source_render_view_id, params); 93 const MixerKey key(source_render_view_id, params);
95 base::AutoLock auto_lock(mixers_lock_); 94 base::AutoLock auto_lock(mixers_lock_);
96 95
97 AudioRendererMixerMap::iterator it = mixers_.find(key); 96 AudioRendererMixerMap::iterator it = mixers_.find(key);
98 DCHECK(it != mixers_.end()); 97 DCHECK(it != mixers_.end());
99 98
100 // Only remove the mixer if AudioRendererMixerManager is the last owner. 99 // Only remove the mixer if AudioRendererMixerManager is the last owner.
101 it->second.ref_count--; 100 it->second.ref_count--;
102 if (it->second.ref_count == 0) { 101 if (it->second.ref_count == 0) {
103 delete it->second.mixer; 102 delete it->second.mixer;
104 mixers_.erase(it); 103 mixers_.erase(it);
105 } 104 }
106 } 105 }
107 106
108 } // namespace content 107 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/audio_message_filter_unittest.cc ('k') | content/renderer/media/media_stream_dependency_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698