| 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/audio_output_resampler.h" | 5 #include "media/audio/audio_output_resampler.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 "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 OnMoreDataConverter(const AudioParameters& input_params, | 30 OnMoreDataConverter(const AudioParameters& input_params, |
| 31 const AudioParameters& output_params); | 31 const AudioParameters& output_params); |
| 32 virtual ~OnMoreDataConverter(); | 32 virtual ~OnMoreDataConverter(); |
| 33 | 33 |
| 34 // AudioSourceCallback interface. | 34 // AudioSourceCallback interface. |
| 35 virtual int OnMoreData(AudioBus* dest, | 35 virtual int OnMoreData(AudioBus* dest, |
| 36 AudioBuffersState buffers_state) OVERRIDE; | 36 AudioBuffersState buffers_state) OVERRIDE; |
| 37 virtual int OnMoreIOData(AudioBus* source, | 37 virtual int OnMoreIOData(AudioBus* source, |
| 38 AudioBus* dest, | 38 AudioBus* dest, |
| 39 AudioBuffersState buffers_state) OVERRIDE; | 39 AudioBuffersState buffers_state) OVERRIDE; |
| 40 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | 40 virtual void OnError(AudioOutputStream* stream) OVERRIDE; |
| 41 virtual void WaitTillDataReady() OVERRIDE; | 41 virtual void WaitTillDataReady() OVERRIDE; |
| 42 | 42 |
| 43 // Sets |source_callback_|. If this is not a new object, then Stop() must be | 43 // Sets |source_callback_|. If this is not a new object, then Stop() must be |
| 44 // called before Start(). | 44 // called before Start(). |
| 45 void Start(AudioOutputStream::AudioSourceCallback* callback); | 45 void Start(AudioOutputStream::AudioSourceCallback* callback); |
| 46 | 46 |
| 47 // Clears |source_callback_| and flushes the resampler. | 47 // Clears |source_callback_| and flushes the resampler. |
| 48 void Stop(); | 48 void Stop(); |
| 49 | 49 |
| 50 private: | 50 private: |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 378 |
| 379 // Zero any unfilled frames if anything was filled, otherwise we'll just | 379 // Zero any unfilled frames if anything was filled, otherwise we'll just |
| 380 // return a volume of zero and let AudioConverter drop the output. | 380 // return a volume of zero and let AudioConverter drop the output. |
| 381 if (frames > 0 && frames < dest->frames()) | 381 if (frames > 0 && frames < dest->frames()) |
| 382 dest->ZeroFramesPartial(frames, dest->frames() - frames); | 382 dest->ZeroFramesPartial(frames, dest->frames() - frames); |
| 383 | 383 |
| 384 // TODO(dalecurtis): Return the correct volume here. | 384 // TODO(dalecurtis): Return the correct volume here. |
| 385 return frames > 0 ? 1 : 0; | 385 return frames > 0 ? 1 : 0; |
| 386 } | 386 } |
| 387 | 387 |
| 388 void OnMoreDataConverter::OnError(AudioOutputStream* stream, int code) { | 388 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { |
| 389 base::AutoLock auto_lock(source_lock_); | 389 base::AutoLock auto_lock(source_lock_); |
| 390 if (source_callback_) | 390 if (source_callback_) |
| 391 source_callback_->OnError(stream, code); | 391 source_callback_->OnError(stream); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void OnMoreDataConverter::WaitTillDataReady() { | 394 void OnMoreDataConverter::WaitTillDataReady() { |
| 395 base::AutoLock auto_lock(source_lock_); | 395 base::AutoLock auto_lock(source_lock_); |
| 396 if (source_callback_) | 396 if (source_callback_) |
| 397 source_callback_->WaitTillDataReady(); | 397 source_callback_->WaitTillDataReady(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 } // namespace media | 400 } // namespace media |
| OLD | NEW |