| 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_output_stream.h" | 5 #include "media/audio/virtual_audio_output_stream.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/audio/virtual_audio_input_stream.h" | 10 #include "media/audio/virtual_audio_input_stream.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 bool VirtualAudioOutputStream::Open() { | 31 bool VirtualAudioOutputStream::Open() { |
| 32 DCHECK(thread_checker_.CalledOnValidThread()); | 32 DCHECK(thread_checker_.CalledOnValidThread()); |
| 33 return true; | 33 return true; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void VirtualAudioOutputStream::Start(AudioSourceCallback* callback) { | 36 void VirtualAudioOutputStream::Start(AudioSourceCallback* callback) { |
| 37 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
| 38 DCHECK(!callback_); | 38 DCHECK(!callback_); |
| 39 callback_ = callback; | 39 callback_ = callback; |
| 40 target_input_stream_->AddOutputStream(this, params_); | 40 target_input_stream_->AddInputProvider(this, params_); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void VirtualAudioOutputStream::Stop() { | 43 void VirtualAudioOutputStream::Stop() { |
| 44 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
| 45 if (callback_) { | 45 if (callback_) { |
| 46 target_input_stream_->RemoveOutputStream(this, params_); | 46 target_input_stream_->RemoveInputProvider(this, params_); |
| 47 callback_ = NULL; | 47 callback_ = NULL; |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 void VirtualAudioOutputStream::Close() { | 51 void VirtualAudioOutputStream::Close() { |
| 52 DCHECK(thread_checker_.CalledOnValidThread()); | 52 DCHECK(thread_checker_.CalledOnValidThread()); |
| 53 | 53 |
| 54 Stop(); | 54 Stop(); |
| 55 | 55 |
| 56 // If a non-null AfterCloseCallback was provided to the constructor, invoke it | 56 // If a non-null AfterCloseCallback was provided to the constructor, invoke it |
| (...skipping 28 matching lines...) Expand all Loading... |
| 85 base::TimeDelta::FromSeconds(1); | 85 base::TimeDelta::FromSeconds(1); |
| 86 const int frames = callback_->OnMoreData( | 86 const int frames = callback_->OnMoreData( |
| 87 audio_bus, static_cast<uint32_t>(upstream_delay_in_bytes), 0); | 87 audio_bus, static_cast<uint32_t>(upstream_delay_in_bytes), 0); |
| 88 if (frames < audio_bus->frames()) | 88 if (frames < audio_bus->frames()) |
| 89 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); | 89 audio_bus->ZeroFramesPartial(frames, audio_bus->frames() - frames); |
| 90 | 90 |
| 91 return frames > 0 ? volume_ : 0; | 91 return frames > 0 ? volume_ : 0; |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace media | 94 } // namespace media |
| OLD | NEW |