Chromium Code Reviews| Index: media/audio/fake_audio_input_stream.h |
| diff --git a/media/audio/fake_audio_input_stream.h b/media/audio/fake_audio_input_stream.h |
| index fafcca330dd809f5efe73effaab9ba4bfc9a949c..2a5dbf658d33c138ba9f786eeef1ff81dccd8522 100644 |
| --- a/media/audio/fake_audio_input_stream.h |
| +++ b/media/audio/fake_audio_input_stream.h |
| @@ -9,24 +9,25 @@ |
| #include <vector> |
| -#include "base/files/file_path.h" |
| +#include "base/callback_forward.h" |
| #include "base/memory/scoped_ptr.h" |
| -#include "base/synchronization/lock.h" |
| -#include "base/threading/thread.h" |
| -#include "base/time/time.h" |
| #include "media/audio/audio_io.h" |
| #include "media/audio/audio_parameters.h" |
| -#include "media/audio/sounds/wav_audio_handler.h" |
| -#include "media/base/audio_converter.h" |
| +#include "media/audio/fake_audio_worker.h" |
| + |
| namespace media { |
| class AudioBus; |
| class AudioManagerBase; |
| +class SimpleSource; |
|
DaleCurtis
2015/02/19 19:54:52
No need for this now, just use AudioOutputStream::
phoglund_chromium
2015/02/20 14:21:59
I think I do need it; the problem is that the call
DaleCurtis
2015/02/20 18:45:05
Ah, it's fine to change the destructor to public f
phoglund_chromium
2015/02/23 09:16:41
Done.
|
| -// This class can either generate a beep sound or play audio from a file. |
| +// This class acts as a fake audio input stream. The default is to generate a |
| +// beeping sound unless --use-file-for-fake-audio-capture=<file> is specified, |
| +// in which case the indicated .wav file will be read and played into the |
| +// stream. |
| class MEDIA_EXPORT FakeAudioInputStream |
| - : public AudioInputStream, AudioConverter::InputCallback { |
| + : public AudioInputStream { |
| public: |
| static AudioInputStream* MakeFakeStream( |
| AudioManagerBase* manager, const AudioParameters& params); |
| @@ -42,12 +43,13 @@ class MEDIA_EXPORT FakeAudioInputStream |
| bool SetAutomaticGainControl(bool enabled) override; |
| bool GetAutomaticGainControl() override; |
| - // Generate one beep sound. This method is called by |
| - // FakeVideoCaptureDevice to test audio/video synchronization. |
| - // This is a static method because FakeVideoCaptureDevice is |
| - // disconnected from an audio device. This means only one instance of |
| - // this class gets to respond, which is okay because we assume there's |
| - // only one stream for this testing purpose. |
| + // Generate one beep sound. This method is called by FakeVideoCaptureDevice to |
| + // test audio/video synchronization. This is a static method because |
| + // FakeVideoCaptureDevice is disconnected from an audio device. This means |
| + // only one instance of this class gets to respond, which is okay because we |
| + // assume there's only one stream for this testing purpose. Furthermore this |
| + // method will do nothing if --use-file-for-fake-audio-capture is specified |
| + // since the input stream will be playing from a file instead of beeping. |
| // TODO(hclam): Make this non-static. To do this we'll need to fix |
| // crbug.com/159053 such that video capture device is aware of audio |
| // input stream. |
| @@ -58,42 +60,16 @@ class MEDIA_EXPORT FakeAudioInputStream |
| const AudioParameters& params); |
| ~FakeAudioInputStream() override; |
| - void DoCallback(); |
| - |
| - // Opens this stream reading from a |wav_filename| rather than beeping. |
| - void OpenInFileMode(const base::FilePath& wav_filename); |
| - |
| - // Returns true if the device is playing from a file; false if we're beeping. |
| - bool PlayingFromFile(); |
| - |
| - void PlayFile(); |
| - void PlayBeep(); |
| + scoped_ptr<SimpleSource> ChooseSource(); |
| + void ReadAudioFromSource(); |
| AudioManagerBase* audio_manager_; |
| AudioInputCallback* callback_; |
| - scoped_ptr<uint8[]> buffer_; |
| - int buffer_size_; |
| + FakeAudioWorker fake_audio_worker_; |
| AudioParameters params_; |
| - const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| - base::TimeTicks last_callback_time_; |
| - base::TimeDelta callback_interval_; |
| - base::TimeDelta interval_from_last_beep_; |
| - int beep_duration_in_buffers_; |
| - int beep_generated_in_buffers_; |
| - int beep_period_in_frames_; |
| + |
| + scoped_ptr<SimpleSource> audio_source_; |
| scoped_ptr<media::AudioBus> audio_bus_; |
| - scoped_ptr<uint8[]> wav_file_data_; |
| - scoped_ptr<media::WavAudioHandler> wav_audio_handler_; |
| - scoped_ptr<media::AudioConverter> file_audio_converter_; |
| - int wav_file_read_pos_; |
| - |
| - // Allows us to run tasks on the FakeAudioInputStream instance which are |
| - // bound by its lifetime. |
| - base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; |
| - |
| - // If running in file mode, this provides audio data from wav_audio_handler_. |
| - double ProvideInput(AudioBus* audio_bus, |
| - base::TimeDelta buffer_delay) override; |
| DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); |
| }; |