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

Unified Diff: media/audio/audio_input_device.h

Issue 2888383002: Stop source and fire MediaStreamTrack ended event if missing audio input callbacks are detected. (Closed)
Patch Set: Removed dependency on test CL. Created 3 years, 7 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 | « content/renderer/media/local_media_stream_audio_source.cc ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_device.h
diff --git a/media/audio/audio_input_device.h b/media/audio/audio_input_device.h
index b62445701f033a6c4ab2ba9fd305c15ca7fbecf6..3c97ec17be90931a5ae8a1b0103711b4ad3a7383 100644
--- a/media/audio/audio_input_device.h
+++ b/media/audio/audio_input_device.h
@@ -59,6 +59,8 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/shared_memory.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
#include "media/audio/audio_device_thread.h"
#include "media/audio/audio_input_ipc.h"
#include "media/audio/scoped_task_runner_observer.h"
@@ -128,6 +130,19 @@ class MEDIA_EXPORT AudioInputDevice
// If the IO loop dies before we do, we shut down the audio thread from here.
void WillDestroyCurrentMessageLoop() override;
+ // Checks if we have gotten callbacks within a certain time period. If no
+ // callbacks have been received, we report a capture error to the capture
+ // callback. Must be called on IO thread.
+ void CheckIfInputStreamIsAlive();
+
+ // Sets the last callback time |last_callback_time_ms_| to the current time.
+ // SetLastCallbackTimeToNow() posts a task on the IO thread to run
+ // SetLastCallbackTimeToNowOnIOThread() which actually sets the variable. We
+ // don't need high precision so we don't have to care about the delay added
+ // with posting the task.
+ void SetLastCallbackTimeToNow();
+ void SetLastCallbackTimeToNowOnIOThread();
+
AudioParameters audio_parameters_;
CaptureCallback* callback_;
@@ -166,6 +181,22 @@ class MEDIA_EXPORT AudioInputDevice
// callback via Start(). See http://crbug.com/151051 for details.
bool stopping_hack_;
+ // Mechanism for detecting if we don't get callbacks for some period of time.
+ // |check_alive_timer_| runs the check regularly.
+ // |last_callback_time_| stores the time for the last callback.
+ // Both must only be accessed on the IO thread.
+ // TODO(grunell): Change from TimeTicks to Atomic32 and remove the task
+ // posting in SetLastCallbackTimeToNow(). The Atomic32 variable would have to
+ // represent some time in seconds or tenths of seconds to be able to span over
+ // enough time. Atomic64 cannot be used since it's not supported on 32-bit
+ // platforms.
+ base::RepeatingTimer check_alive_timer_;
+ base::TimeTicks last_callback_time_;
+
+ // Flags that missing callbacks has been detected. Used for statistics,
+ // reported when stopping. Must only be accessed on the IO thread.
+ bool missing_callbacks_detected_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice);
};
« no previous file with comments | « content/renderer/media/local_media_stream_audio_source.cc ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698