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

Unified Diff: media/audio/audio_input_controller.h

Issue 9956169: Improved timer implementation in AudioInputController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 8 years, 8 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 8fd69b0fa6299151822f8bc6ec8c97247ff6cb91..cb41270e246e37a31a8ce06d2f521032b7eb1231 100644
--- a/media/audio/audio_input_controller.h
+++ b/media/audio/audio_input_controller.h
@@ -6,6 +6,7 @@
#define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
#include <string>
+#include "base/atomicops.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -42,24 +43,26 @@
// User AudioInputController EventHandler
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// CrateLowLatency() ==> DoCreate()
-// AudioManager::MakeAudioInputStream()
-// AudioInputStream::Open()
-// .- - - - - - - - - - - - -> OnError()
-// DoResetNoDataTimer (posted on creating tread)
+// AudioManager::MakeAudioInputStream()
+// AudioInputStream::Open()
+// .- - - - - - - - - - - - -> OnError()
+// create the data timer
// .-------------------------> OnCreated()
// kCreated
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Record() ==> DoRecord()
-// AudioInputStream::Start()
+// AudioInputStream::Start()
// .-------------------------> OnRecording()
+// start the data timer
// kRecording
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Close() ==> DoClose()
-// state_ = kClosed
-// AudioInputStream::Stop()
-// AudioInputStream::Close()
-// SyncWriter::Close()
-// Closure::Run() <--------------.
+// delete the data timer
+// state_ = kClosed
+// AudioInputStream::Stop()
+// AudioInputStream::Close()
+// SyncWriter::Close()
+// Closure::Run() <-----------------.
// (closure-task)
//
// The audio thread itself is owned by the AudioManager that the
@@ -198,15 +201,17 @@ class MEDIA_EXPORT AudioInputController
void DoSetVolume(double volume);
void DoSetAutomaticGainControl(bool enabled);
- // Methods which ensures that OnError() is triggered when data recording
- // times out. Both are called on the creating thread.
- void DoReportNoDataError();
- void DoResetNoDataTimer();
+ // Method which ensures that OnError() is triggered when data recording
+ // times out. Called on the audio thread.
+ void DoCheckForNoData();
// Helper method that stops, closes, and NULL:s |*stream_|.
// Signals event when done if the event is not NULL.
void DoStopCloseAndClearStream(base::WaitableEvent* done);
+ void SetDataIsActive(bool enabled);
+ bool GetDataIsActive();
+
// Gives access to the message loop of the creating thread.
scoped_refptr<base::MessageLoopProxy> creator_loop_;
@@ -220,13 +225,19 @@ class MEDIA_EXPORT AudioInputController
// Pointer to the audio input stream object.
AudioInputStream* stream_;
- // |no_data_timer_| is used to call DoReportNoDataError() when we stop
- // receiving OnData() calls without an OnClose() call. This can occur
+ // |no_data_timer_| is used to call OnError() when we stop receiving
+ // OnData() calls without an OnClose() call. This can occur
// when an audio input device is unplugged whilst recording on Windows.
// See http://crbug.com/79936 for details.
- // This member is only touched by the creating thread.
+ // This member is only touched by the audio thread.
scoped_ptr<base::DelayTimer<AudioInputController> > no_data_timer_;
+ // This flag is used to signal that we are receiving OnData() calls, i.e,
+ // that data is active. It can be touched by the audio thread and by the
+ // low-level audio thread which calls OnData(). E.g. on Windows, the
+ // low-level audio thread is called wasapi_capture_thread.
+ base::subtle::Atomic32 data_is_active_;
+
// |state_| is written on the audio thread and is read on the hardware audio
// thread. These operations need to be locked. But lock is not required for
// reading on the audio input controller thread.
« 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