| OLD | NEW |
| 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 "media/audio/virtual_audio_input_stream.h" | 5 #include "media/audio/virtual_audio_input_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 &VirtualAudioInputStream::PumpAudio, base::Unretained(this))); | 59 &VirtualAudioInputStream::PumpAudio, base::Unretained(this))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void VirtualAudioInputStream::Stop() { | 62 void VirtualAudioInputStream::Stop() { |
| 63 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
| 64 fake_worker_.Stop(); | 64 fake_worker_.Stop(); |
| 65 callback_ = NULL; | 65 callback_ = NULL; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void VirtualAudioInputStream::AddOutputStream( | 68 void VirtualAudioInputStream::AddOutputStream( |
| 69 VirtualAudioOutputStream* stream, const AudioParameters& output_params) { | 69 AudioConverter::InputCallback* stream, |
| 70 const AudioParameters& output_params) { |
| 70 DCHECK(thread_checker_.CalledOnValidThread()); | 71 DCHECK(thread_checker_.CalledOnValidThread()); |
| 71 | 72 |
| 72 base::AutoLock scoped_lock(converter_network_lock_); | 73 base::AutoLock scoped_lock(converter_network_lock_); |
| 73 | 74 |
| 74 AudioConvertersMap::iterator converter = converters_.find(output_params); | 75 AudioConvertersMap::iterator converter = converters_.find(output_params); |
| 75 if (converter == converters_.end()) { | 76 if (converter == converters_.end()) { |
| 76 std::pair<AudioConvertersMap::iterator, bool> result = converters_.insert( | 77 std::pair<AudioConvertersMap::iterator, bool> result = converters_.insert( |
| 77 std::make_pair(output_params, new LoopbackAudioConverter( | 78 std::make_pair(output_params, new LoopbackAudioConverter( |
| 78 output_params, params_, false))); | 79 output_params, params_, false))); |
| 79 converter = result.first; | 80 converter = result.first; |
| 80 | 81 |
| 81 // Add to main mixer if we just added a new AudioTransform. | 82 // Add to main mixer if we just added a new AudioTransform. |
| 82 mixer_.AddInput(converter->second); | 83 mixer_.AddInput(converter->second); |
| 83 } | 84 } |
| 84 converter->second->AddInput(stream); | 85 converter->second->AddInput(stream); |
| 85 ++num_attached_output_streams_; | 86 ++num_attached_output_streams_; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void VirtualAudioInputStream::RemoveOutputStream( | 89 void VirtualAudioInputStream::RemoveOutputStream( |
| 89 VirtualAudioOutputStream* stream, const AudioParameters& output_params) { | 90 AudioConverter::InputCallback* stream, |
| 91 const AudioParameters& output_params) { |
| 90 DCHECK(thread_checker_.CalledOnValidThread()); | 92 DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 | 93 |
| 92 base::AutoLock scoped_lock(converter_network_lock_); | 94 base::AutoLock scoped_lock(converter_network_lock_); |
| 93 | 95 |
| 94 DCHECK(converters_.find(output_params) != converters_.end()); | 96 DCHECK(converters_.find(output_params) != converters_.end()); |
| 95 converters_[output_params]->RemoveInput(stream); | 97 converters_[output_params]->RemoveInput(stream); |
| 96 | 98 |
| 97 --num_attached_output_streams_; | 99 --num_attached_output_streams_; |
| 98 DCHECK_LE(0, num_attached_output_streams_); | 100 DCHECK_LE(0, num_attached_output_streams_); |
| 99 } | 101 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 145 |
| 144 bool VirtualAudioInputStream::GetAutomaticGainControl() { | 146 bool VirtualAudioInputStream::GetAutomaticGainControl() { |
| 145 return false; | 147 return false; |
| 146 } | 148 } |
| 147 | 149 |
| 148 bool VirtualAudioInputStream::IsMuted() { | 150 bool VirtualAudioInputStream::IsMuted() { |
| 149 return false; | 151 return false; |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace media | 154 } // namespace media |
| OLD | NEW |