Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: media/audio/fake_audio_input_stream.h

Issue 922663002: Moved the fake input stream's processing onto the audio worker thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moving browser test updates to a separate patch (this one is big enough) Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8691faf5d4ebe4106d0e60f571a255d71dc7d116 100644
--- a/media/audio/fake_audio_input_stream.h
+++ b/media/audio/fake_audio_input_stream.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
@@ -16,17 +17,20 @@
#include "base/time/time.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_parameters.h"
+#include "media/audio/fake_audio_provider.h"
#include "media/audio/sounds/wav_audio_handler.h"
-#include "media/base/audio_converter.h"
namespace media {
class AudioBus;
class AudioManagerBase;
-// 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);
@@ -47,7 +51,9 @@ class MEDIA_EXPORT FakeAudioInputStream
// 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.
+ // 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 +64,11 @@ 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();
+ void OnMoreInputData(AudioBus* audio_bus, int buffer_size);
AudioManagerBase* audio_manager_;
AudioInputCallback* callback_;
- scoped_ptr<uint8[]> buffer_;
- int buffer_size_;
- 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<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;
+ FakeAudioProvider fake_audio_provider_;
DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream);
};

Powered by Google App Engine
This is Rietveld 408576698