| Index: media/audio/simple_sources.h
|
| diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h
|
| index 7a2176f6bc28788fca658cfd158f1b737d17ac27..ab09b1999f3700fa0464de39bd8a1cd48587f6a1 100644
|
| --- a/media/audio/simple_sources.h
|
| +++ b/media/audio/simple_sources.h
|
| @@ -5,21 +5,30 @@
|
| #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 {
|
|
|
| -// An audio source that produces a pure sinusoidal tone.
|
| -class MEDIA_EXPORT SineWaveAudioSource
|
| +class WavAudioHandler;
|
| +
|
| +class MEDIA_EXPORT SimpleSource
|
| : public AudioOutputStream::AudioSourceCallback {
|
| public:
|
| + ~SimpleSource() override {};
|
| +};
|
| +
|
| +// An audio source that produces a pure sinusoidal tone.
|
| +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
|
| // |sample_freq| or else you will get aliasing.
|
| SineWaveAudioSource(int channels, double freq, double sample_freq);
|
| - ~SineWaveAudioSource() override {}
|
| + ~SineWaveAudioSource() override;
|
|
|
| // Return up to |cap| samples of data via OnMoreData(). Use Reset() to
|
| // allow more data to be served.
|
| @@ -44,6 +53,54 @@ class MEDIA_EXPORT SineWaveAudioSource
|
| base::Lock time_lock_;
|
| };
|
|
|
| +class FileSource : public SimpleSource,
|
| + public AudioConverter::InputCallback {
|
| + public:
|
| + FileSource(const AudioParameters& params,
|
| + const base::FilePath& path_to_wav_file);
|
| + ~FileSource() 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<WavAudioHandler> wav_audio_handler_;
|
| + scoped_ptr<AudioConverter> file_audio_converter_;
|
| + int wav_file_read_pos_;
|
| +
|
| + // Provides audio data from wav_audio_handler_ into the file audio converter.
|
| + double ProvideInput(AudioBus* audio_bus,
|
| + base::TimeDelta buffer_delay) override;
|
| +
|
| + // Loads the wav file on the first OnMoreData invocation.
|
| + void LoadWavFile(const base::FilePath& path_to_wav_file);
|
| +};
|
| +
|
| +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;
|
| +
|
| + 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_
|
|
|