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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 class OnMoreDataConverter | 24 class OnMoreDataConverter |
25 : public AudioOutputStream::AudioSourceCallback, | 25 : public AudioOutputStream::AudioSourceCallback, |
26 public AudioConverter::InputCallback { | 26 public AudioConverter::InputCallback { |
27 public: | 27 public: |
28 OnMoreDataConverter(const AudioParameters& input_params, | 28 OnMoreDataConverter(const AudioParameters& input_params, |
29 const AudioParameters& output_params); | 29 const AudioParameters& output_params); |
30 virtual ~OnMoreDataConverter(); | 30 virtual ~OnMoreDataConverter(); |
31 | 31 |
32 // AudioSourceCallback interface. | 32 // AudioSourceCallback interface. |
33 virtual int OnMoreData(AudioBus* dest, | 33 virtual int OnMoreData(AudioBus* dest, |
34 uint32 total_bytes_delay) OVERRIDE; | 34 uint32 total_bytes_delay) override; |
35 virtual void OnError(AudioOutputStream* stream) OVERRIDE; | 35 virtual void OnError(AudioOutputStream* stream) override; |
36 | 36 |
37 // Sets |source_callback_|. If this is not a new object, then Stop() must be | 37 // Sets |source_callback_|. If this is not a new object, then Stop() must be |
38 // called before Start(). | 38 // called before Start(). |
39 void Start(AudioOutputStream::AudioSourceCallback* callback); | 39 void Start(AudioOutputStream::AudioSourceCallback* callback); |
40 | 40 |
41 // Clears |source_callback_| and flushes the resampler. | 41 // Clears |source_callback_| and flushes the resampler. |
42 void Stop(); | 42 void Stop(); |
43 | 43 |
44 bool started() { return source_callback_ != nullptr; } | 44 bool started() { return source_callback_ != nullptr; } |
45 | 45 |
46 private: | 46 private: |
47 // AudioConverter::InputCallback implementation. | 47 // AudioConverter::InputCallback implementation. |
48 virtual double ProvideInput(AudioBus* audio_bus, | 48 virtual double ProvideInput(AudioBus* audio_bus, |
49 base::TimeDelta buffer_delay) OVERRIDE; | 49 base::TimeDelta buffer_delay) override; |
50 | 50 |
51 // Ratio of input bytes to output bytes used to correct playback delay with | 51 // Ratio of input bytes to output bytes used to correct playback delay with |
52 // regard to buffering and resampling. | 52 // regard to buffering and resampling. |
53 const double io_ratio_; | 53 const double io_ratio_; |
54 | 54 |
55 // Source callback. | 55 // Source callback. |
56 AudioOutputStream::AudioSourceCallback* source_callback_; | 56 AudioOutputStream::AudioSourceCallback* source_callback_; |
57 | 57 |
58 // Last |total_bytes_delay| received via OnMoreData(), used to correct | 58 // Last |total_bytes_delay| received via OnMoreData(), used to correct |
59 // playback delay by ProvideInput() and passed on to |source_callback_|. | 59 // playback delay by ProvideInput() and passed on to |source_callback_|. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (frames > 0 && frames < dest->frames()) | 354 if (frames > 0 && frames < dest->frames()) |
355 dest->ZeroFramesPartial(frames, dest->frames() - frames); | 355 dest->ZeroFramesPartial(frames, dest->frames() - frames); |
356 return frames > 0 ? 1 : 0; | 356 return frames > 0 ? 1 : 0; |
357 } | 357 } |
358 | 358 |
359 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { | 359 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { |
360 source_callback_->OnError(stream); | 360 source_callback_->OnError(stream); |
361 } | 361 } |
362 | 362 |
363 } // namespace media | 363 } // namespace media |
OLD | NEW |