Chromium Code Reviews| Index: media/audio/simple_sources.h |
| diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h |
| index 7a2176f6bc28788fca658cfd158f1b737d17ac27..fc0d0ff04bce1f346e62f7edc344a8b995336a39 100644 |
| --- a/media/audio/simple_sources.h |
| +++ b/media/audio/simple_sources.h |
| @@ -5,15 +5,25 @@ |
| #ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
| #define MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
| +#include "base/files/file_path.h" |
| #include "base/synchronization/lock.h" |
| #include "media/audio/audio_io.h" |
| +#include "media/base/audio_converter.h" |
| #include "media/base/seekable_buffer.h" |
| namespace media { |
| +class WavAudioHandler; |
| + |
| +class SimpleSource : public AudioOutputStream::AudioSourceCallback { |
|
DaleCurtis
2015/02/19 19:54:54
Why is this necessary? Open() is only used in the
phoglund_chromium
2015/02/20 14:22:00
All right.
|
| + public: |
| + ~SimpleSource() override {}; |
| + |
| + virtual void Open() {} |
| +}; |
| + |
| // An audio source that produces a pure sinusoidal tone. |
| -class MEDIA_EXPORT SineWaveAudioSource |
| - : public AudioOutputStream::AudioSourceCallback { |
| +class MEDIA_EXPORT SineWaveAudioSource : public SimpleSource { |
| public: |
| // |channels| is the number of audio channels, |freq| is the frequency in |
| // hertz and it has to be less than half of the sampling frequency |
| @@ -44,6 +54,54 @@ class MEDIA_EXPORT SineWaveAudioSource |
| base::Lock time_lock_; |
| }; |
| +class FileSource : public SimpleSource, |
| + public AudioConverter::InputCallback{ |
|
DaleCurtis
2015/02/19 19:54:54
Space after InputCallback
phoglund_chromium
2015/02/20 14:22:00
Done.
|
| + public: |
| + FileSource(const AudioParameters& params, |
| + const base::FilePath& path_to_wav_file); |
| + ~FileSource() override; |
| + |
| + void Open() override; |
| + |
| + // Implementation of AudioSourceCallback. |
| + int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override; |
| + void OnError(AudioOutputStream* stream) override {} |
| + |
| + private: |
| + AudioParameters params_; |
| + base::FilePath path_to_wav_file_; |
| + scoped_ptr<uint8[]> wav_file_data_; |
| + scoped_ptr<media::WavAudioHandler> wav_audio_handler_; |
|
DaleCurtis
2015/02/19 19:54:54
No need for media:: prefix on anything in this .h
phoglund_chromium
2015/02/20 14:22:00
Done.
|
| + scoped_ptr<media::AudioConverter> file_audio_converter_; |
| + int wav_file_read_pos_; |
| + int buffer_size_; |
| + |
| + // Provides audio data from wav_audio_handler_ into the file audio converter. |
| + double ProvideInput(AudioBus* audio_bus, |
| + base::TimeDelta buffer_delay) override; |
| +}; |
| + |
| +class BeepingSource : public SimpleSource { |
| + public: |
| + BeepingSource(const AudioParameters& params); |
| + ~BeepingSource() override; |
| + |
| + // Implementation of AudioSourceCallback. |
| + int OnMoreData(AudioBus* audio_bus, uint32 total_bytes_delay) override; |
| + void OnError(AudioOutputStream* stream) override {} |
|
DaleCurtis
2015/02/19 19:54:54
Inline methods aren't allowed for virtual function
phoglund_chromium
2015/02/20 14:22:00
Done.
phoglund_chromium
2015/02/20 14:22:00
Done.
|
| + |
| + static void BeepOnce(); |
| + private: |
| + scoped_ptr<uint8[]> buffer_; |
| + int buffer_size_; |
| + AudioParameters params_; |
| + base::TimeTicks last_callback_time_; |
| + base::TimeDelta interval_from_last_beep_; |
| + int beep_duration_in_buffers_; |
| + int beep_generated_in_buffers_; |
| + int beep_period_in_frames_; |
| +}; |
| + |
| } // namespace media |
| #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ |