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

Unified Diff: media/audio/audio_input_controller.h

Issue 3148003: Allow unit tests to use a mock audio input controller. (Closed)
Patch Set: Address review comments from Jeremy and Alpha Created 10 years, 4 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
« no previous file with comments | « no previous file | media/audio/audio_input_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_controller.h
diff --git a/media/audio/audio_input_controller.h b/media/audio/audio_input_controller.h
index 27b3a54bf8225563adb6d67eab71351679f55814..a00e2bc50b90878e9e1156d2ecd20d3aba1aea65 100644
--- a/media/audio/audio_input_controller.h
+++ b/media/audio/audio_input_controller.h
@@ -49,6 +49,21 @@ class AudioInputController :
uint32 size) = 0;
};
+ // AudioInputController::Create uses the currently registered Factory to
+ // create the AudioInputController. Factory is intended for testing.
+ class Factory {
+ public:
+ virtual AudioInputController* Create(EventHandler* event_handler,
+ AudioManager::Format format,
+ int channels,
+ int sample_rate,
+ int bits_per_sample,
+ int samples_per_packet) = 0;
+
+ protected:
+ virtual ~Factory() {}
+ };
+
virtual ~AudioInputController();
// Factory method for creating an AudioInputController.
@@ -63,8 +78,15 @@ class AudioInputController :
int bits_per_sample, // Number of bits per sample.
int samples_per_packet); // Size of the hardware buffer.
+ // Sets the factory used by the static method Create. AudioInputController
+ // does not take ownership of |factory|. A value of NULL results in an
+ // AudioInputController being created directly.
+#if defined(UNIT_TEST)
+ static void set_factory(Factory* factory) { factory_ = factory; }
+#endif
+
// Starts recording in this audio input stream.
- void Record();
+ virtual void Record();
// Closes the audio input stream and shutdown the audio input controller
// thread. This method returns only after all operations are completed. This
@@ -72,7 +94,7 @@ class AudioInputController :
//
// It is safe to call this method more than once. Calls after the first one
// will have no effect.
- void Close();
+ virtual void Close();
///////////////////////////////////////////////////////////////////////////
// AudioInputCallback methods.
@@ -80,7 +102,7 @@ class AudioInputController :
virtual void OnClose(AudioInputStream* stream);
virtual void OnError(AudioInputStream* stream, int code);
- private:
+ protected:
// Internal state of the source.
enum State {
kEmpty,
@@ -113,6 +135,8 @@ class AudioInputController :
// The audio input controller thread that this object runs on.
base::Thread thread_;
+ static Factory* factory_;
+
DISALLOW_COPY_AND_ASSIGN(AudioInputController);
};
« no previous file with comments | « no previous file | media/audio/audio_input_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698