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

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

Issue 11889041: Fix VirtualAudioInputStream callback timing issues. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 7 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 | 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 "content/renderer/media/renderer_audio_output_device.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const media::AudioParameters& params) { 45 const media::AudioParameters& params) {
46 const MixerKey key(source_render_view_id, params); 46 const MixerKey key(source_render_view_id, params);
47 base::AutoLock auto_lock(mixers_lock_); 47 base::AutoLock auto_lock(mixers_lock_);
48 48
49 AudioRendererMixerMap::iterator it = mixers_.find(key); 49 AudioRendererMixerMap::iterator it = mixers_.find(key);
50 if (it != mixers_.end()) { 50 if (it != mixers_.end()) {
51 it->second.ref_count++; 51 it->second.ref_count++;
52 return it->second.mixer; 52 return it->second.mixer;
53 } 53 }
54 54
55 int buffer_size = hardware_buffer_size_;
56 #if defined(OS_WIN) || defined(OS_MACOSX)
miu 2013/01/15 23:28:35 Remove #if, since this would seem to apply to all
justinlin 2013/01/15 23:52:45 Renderer side mixing is only turned on for OSX/Win
miu 2013/01/16 03:43:03 It's a flag for multiple platforms, enabled by def
justinlin 2013/01/16 20:15:23 I added a TODO to do this if we don't get to rende
57 // Force at least a 1024 buffer size until we have renderer-side device
58 // changes. WebRTC audio mirroring will use the input device's buffer size to
DaleCurtis 2013/01/15 23:30:03 WebRTC doesn't use this code?
justinlin 2013/01/15 23:52:45 Done. We'd typically use audio mirroring with webr
59 // drive mirroring, so we need the output device's buffer size to be big
60 // enough to avoid garbled audio.
61 buffer_size = std::max(hardware_buffer_size_, 1024);
62 #endif
63
55 // Create output parameters based on the audio hardware configuration for 64 // Create output parameters based on the audio hardware configuration for
56 // passing on to the output sink. Force to 16-bit output for now since we 65 // passing on to the output sink. Force to 16-bit output for now since we
57 // know that works well for WebAudio and WebRTC. 66 // know that works well for WebAudio and WebRTC.
58 media::AudioParameters output_params( 67 media::AudioParameters output_params(
59 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), 68 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(),
60 hardware_sample_rate_, 16, hardware_buffer_size_); 69 hardware_sample_rate_, 16, buffer_size);
61 70
62 // If we've created invalid output parameters, simply pass on the input params 71 // If we've created invalid output parameters, simply pass on the input params
63 // and let the browser side handle automatic fallback. 72 // and let the browser side handle automatic fallback.
64 if (!output_params.IsValid()) 73 if (!output_params.IsValid())
65 output_params = params; 74 output_params = params;
66 75
67 media::AudioRendererMixer* mixer; 76 media::AudioRendererMixer* mixer;
68 if (sink_for_testing_) { 77 if (sink_for_testing_) {
69 mixer = new media::AudioRendererMixer( 78 mixer = new media::AudioRendererMixer(
70 params, output_params, sink_for_testing_); 79 params, output_params, sink_for_testing_);
(...skipping 20 matching lines...) Expand all
91 100
92 // Only remove the mixer if AudioRendererMixerManager is the last owner. 101 // Only remove the mixer if AudioRendererMixerManager is the last owner.
93 it->second.ref_count--; 102 it->second.ref_count--;
94 if (it->second.ref_count == 0) { 103 if (it->second.ref_count == 0) {
95 delete it->second.mixer; 104 delete it->second.mixer;
96 mixers_.erase(it); 105 mixers_.erase(it);
97 } 106 }
98 } 107 }
99 108
100 } // namespace content 109 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/audio/virtual_audio_input_stream.h » ('j') | media/audio/virtual_audio_input_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698