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

Unified Diff: media/audio/audio_manager.cc

Issue 2934613002: Avoid shutdown crash if audio thread is hung. (Closed)
Patch Set: leaks audio manager Created 3 years, 6 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 | « media/audio/audio_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager.cc
diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc
index 87a2b121e5ca0f73d0e8199f59cc16e25b296013..54eb1bc1562fea40fc527ec25278ae894d4af0ca 100644
--- a/media/audio/audio_manager.cc
+++ b/media/audio/audio_manager.cc
@@ -81,6 +81,11 @@ class AudioManagerHelper : public base::PowerObserver {
base::Unretained(this)));
}
+ bool IsAudioThreadHung() {
+ base::AutoLock lock(hang_lock_);
+ return audio_thread_status_ == THREAD_HUNG;
pfeldman 2017/06/14 22:38:30 We should not sync UI thread with potentially stal
alokp 2017/06/14 23:56:19 This function is only called during shutdown. Are
+ }
+
base::SingleThreadTaskRunner* monitor_task_runner() const {
return monitor_task_runner_.get();
}
@@ -204,6 +209,7 @@ class AudioManagerHelper : public base::PowerObserver {
void HistogramThreadStatus(ThreadStatus status) {
DCHECK(monitor_task_runner_->BelongsToCurrentThread());
+ hang_lock_.AssertAcquired();
audio_thread_status_ = status;
UMA_HISTOGRAM_ENUMERATION("Media.AudioThreadStatus", audio_thread_status_,
THREAD_MAX + 1);
@@ -329,11 +335,16 @@ AudioManager* AudioManager::Get() {
return g_last_created;
}
-void AudioManager::Shutdown() {
+bool AudioManager::Shutdown() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- // TODO(alokp): Suspend hang monitor.
+ // Do not attempt to stop the audio thread if it is hung.
+ // Otherwise the current thread will hang too: crbug.com/729494
+ // TODO(olka, grunell): Will be fixed when audio is its own process.
+ if (GetHelper()->IsAudioThreadHung())
pfeldman 2017/06/14 22:38:31 Are you suggesting that upon stopping the audio th
alokp 2017/06/14 23:56:19 Yes - exactly.
+ return false;
+ // TODO(alokp): Suspend hang monitor.
if (audio_thread_->GetTaskRunner()->BelongsToCurrentThread()) {
ShutdownOnAudioThread();
} else {
@@ -343,6 +354,7 @@ void AudioManager::Shutdown() {
}
audio_thread_->Stop();
shutdown_ = true;
+ return true;
}
} // namespace media
« no previous file with comments | « media/audio/audio_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698