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

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: Added WebRTC logging in LocalMediaStreamAudioSource::OnCaptureError(). 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
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..a633d4c30ccd439ad9edf455bd9525ed5414ee8e 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,18 @@ 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_|.
+ // SetLastCallbackTime() is called by AudioInputDevice::AudioThreadCallback on
+ // the audio thread and posts a task to SetLastCallbackTimeOnIOThread() which
+ // sets the variable.
+ void SetLastCallbackTime(base::TimeTicks last_callback_time);
+ void SetLastCallbackTimeOnIOThread(base::TimeTicks last_callback_time);
+
AudioParameters audio_parameters_;
CaptureCallback* callback_;
@@ -166,6 +180,13 @@ 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 when started.
+ // |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.
+ base::RepeatingTimer check_alive_timer_;
+ base::TimeTicks last_callback_time_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice);
};

Powered by Google App Engine
This is Rietveld 408576698