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

Unified Diff: content/renderer/media/webrtc/processed_local_audio_source.cc

Issue 2888383002: Stop source and fire MediaStreamTrack ended event if missing audio input callbacks are detected. (Closed)
Patch Set: 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/webrtc/processed_local_audio_source.h ('k') | media/audio/pulse/pulse_input.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc/processed_local_audio_source.cc
diff --git a/content/renderer/media/webrtc/processed_local_audio_source.cc b/content/renderer/media/webrtc/processed_local_audio_source.cc
index 75b7d4a4b6c97d9e0ff69b0321d1562b045a15e4..6bad2e442c916dde899f69d87aeb0084a54aed59 100644
--- a/content/renderer/media/webrtc/processed_local_audio_source.cc
+++ b/content/renderer/media/webrtc/processed_local_audio_source.cc
@@ -201,12 +201,23 @@ bool ProcessedLocalAudioSource::EnsureSourceIsStarted() {
// Register this source with the WebRtcAudioDeviceImpl.
rtc_audio_device->AddAudioCapturer(this);
+ // Start detecting no callbacks.
+ base::subtle::Release_Store(&input_callback_is_active_, false);
+ last_callback_time_ = base::TimeTicks::Now();
+ check_alive_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(5),
+ this, &ProcessedLocalAudioSource::CheckIfInputStreamIsAlive);
+ DCHECK(check_alive_timer_.IsRunning());
+
return true;
}
void ProcessedLocalAudioSource::EnsureSourceIsStopped() {
DCHECK(thread_checker_.CalledOnValidThread());
+ check_alive_timer_.Stop();
+ DCHECK(!check_alive_timer_.IsRunning());
+
scoped_refptr<media::AudioCapturerSource> source_to_stop;
{
base::AutoLock auto_lock(source_lock_);
@@ -267,6 +278,10 @@ void ProcessedLocalAudioSource::Capture(const media::AudioBus* audio_bus,
int audio_delay_milliseconds,
double volume,
bool key_pressed) {
+ base::subtle::Release_Store(&input_callback_is_active_, true);
ossu-chromium 2017/05/18 13:38:54 Perhaps just store last_callback_time_ atomically?
Henrik Grunell 2017/05/19 06:00:00 Yeah, this is going away. The CL is not ready for
+ // TODO: Post task.
+ last_callback_time_ = base::TimeTicks::Now();
+
#if defined(OS_WIN) || defined(OS_MACOSX)
DCHECK_LE(volume, 1.0);
#elif (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_OPENBSD)
@@ -373,4 +388,17 @@ int ProcessedLocalAudioSource::GetBufferSize(int sample_rate) const {
return (sample_rate / 100);
}
+void ProcessedLocalAudioSource::CheckIfInputStreamIsAlive() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+// bool active = base::subtle::Acquire_Load(&input_callback_is_active_);
+ base::TimeDelta time_since_last_callback =
+ base::TimeTicks::Now() - last_callback_time_;
+ if (time_since_last_callback > base::TimeDelta::FromSeconds(5)) {
+// if (!active) {
+ LOG(ERROR) << "********** Detected missing callbacks. Stopping.";
+ StopSourceOnError("Detected missing callbacks.");
+ }
+}
+
} // namespace content
« no previous file with comments | « content/renderer/media/webrtc/processed_local_audio_source.h ('k') | media/audio/pulse/pulse_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698