Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // AudioOutputResampler is a browser-side resampler which ensures audio data is | |
| 6 // always output at the configured hardware parameters. | |
|
scherkus (not reviewing)
2012/09/07 13:30:17
move to class def instead of top of file
DaleCurtis
2012/09/10 12:06:24
Done.
| |
| 7 | |
| 8 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_ | |
| 9 #define MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_ | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/synchronization/lock.h" | |
| 14 #include "base/time.h" | |
| 15 #include "media/audio/audio_io.h" | |
| 16 #include "media/audio/audio_manager.h" | |
| 17 #include "media/audio/audio_output_dispatcher.h" | |
| 18 #include "media/audio/audio_parameters.h" | |
| 19 | |
| 20 namespace media { | |
| 21 class AudioFifo; | |
|
scherkus (not reviewing)
2012/09/07 13:30:17
nit: blank line before
DaleCurtis
2012/09/10 12:06:24
Done.
| |
| 22 class MultiChannelResampler; | |
| 23 | |
| 24 class MEDIA_EXPORT AudioOutputResampler | |
| 25 : public AudioOutputDispatcher, | |
| 26 public AudioOutputStream::AudioSourceCallback { | |
| 27 public: | |
| 28 AudioOutputResampler(AudioManager* audio_manager, | |
| 29 const AudioParameters& params, | |
| 30 const base::TimeDelta& close_delay); | |
| 31 | |
| 32 // AudioOutputDispatcher interface. | |
| 33 virtual bool OpenStream() OVERRIDE; | |
| 34 virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback, | |
| 35 AudioOutputProxy* stream_proxy) OVERRIDE; | |
| 36 virtual void StopStream(AudioOutputProxy* stream_proxy) OVERRIDE; | |
| 37 virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy, | |
| 38 double volume) OVERRIDE; | |
| 39 virtual void CloseStream(AudioOutputProxy* stream_proxy) OVERRIDE; | |
| 40 virtual void Shutdown() OVERRIDE; | |
| 41 | |
| 42 // AudioSourceCallback interface. | |
| 43 virtual int OnMoreData(AudioBus* audio_bus, | |
| 44 AudioBuffersState buffers_state) OVERRIDE; | |
| 45 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | |
| 46 virtual void WaitTillDataReady() OVERRIDE; | |
| 47 | |
| 48 private: | |
| 49 friend class base::RefCountedThreadSafe<AudioOutputResampler>; | |
| 50 virtual ~AudioOutputResampler(); | |
| 51 | |
| 52 // ProvideInput() will be called by MultiChannelResampler when more data is | |
| 53 // necessary. | |
| 54 void ProvideInput(AudioBus* audio_bus); | |
| 55 | |
| 56 // Handles resampling. | |
| 57 scoped_ptr<MultiChannelResampler> resampler_; | |
| 58 | |
| 59 // Dispatcher to proxy all AudioOutputDispatcher calls too. | |
| 60 scoped_refptr<AudioOutputDispatcher> dispatcher_; | |
| 61 | |
| 62 // Source callback and associated lock. | |
| 63 base::Lock source_lock_; | |
| 64 AudioOutputStream::AudioSourceCallback* source_callback_; | |
| 65 | |
| 66 AudioBuffersState current_buffers_state_; | |
| 67 int outstanding_audio_bytes_; | |
| 68 int current_filled_audio_bytes_; | |
| 69 | |
| 70 scoped_ptr<AudioBus> temp_bus_; | |
| 71 scoped_ptr<AudioFifo> audio_fifo_; | |
| 72 | |
| 73 double io_ratio_; | |
| 74 int output_bytes_per_frame_; | |
| 75 int input_bytes_per_frame_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(AudioOutputResampler); | |
| 78 }; | |
| 79 | |
| 80 } // namespace media | |
| 81 | |
| 82 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_ | |
| OLD | NEW |