Index: media/audio/simple_sources.h |
diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h |
index 7a2176f6bc28788fca658cfd158f1b737d17ac27..606cebee630fdbbeed356f16412e28bbe48e91e9 100644 |
--- a/media/audio/simple_sources.h |
+++ b/media/audio/simple_sources.h |
@@ -5,12 +5,16 @@ |
#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; |
+ |
// An audio source that produces a pure sinusoidal tone. |
class MEDIA_EXPORT SineWaveAudioSource |
: public AudioOutputStream::AudioSourceCallback { |
@@ -19,7 +23,7 @@ class MEDIA_EXPORT SineWaveAudioSource |
// 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 +48,54 @@ class MEDIA_EXPORT SineWaveAudioSource |
base::Lock time_lock_; |
}; |
+class FileSource : public AudioOutputStream::AudioSourceCallback, |
+ 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 AudioOutputStream::AudioSourceCallback { |
+ 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: |
+ int buffer_size_; |
+ scoped_ptr<uint8[]> buffer_; |
+ 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_ |