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

Unified Diff: media/audio/audio_manager_base.cc

Issue 2784433002: Ensures that audio tasks cannot run after AudioManager is deleted. (Closed)
Patch Set: addressed comments 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_manager_base.cc
diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc
index e149216e02de6e049fe778868a75e805f3e4f877..7ac550f033757c584a5dd543b743de2fdb770685 100644
--- a/media/audio/audio_manager_base.cc
+++ b/media/audio/audio_manager_base.cc
@@ -84,11 +84,9 @@ class AudioManagerBase::CompareByParams {
const DispatcherParams* dispatcher_;
};
-AudioManagerBase::AudioManagerBase(
- scoped_refptr<base::SingleThreadTaskRunner> task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
- AudioLogFactory* audio_log_factory)
- : AudioManager(std::move(task_runner), std::move(worker_task_runner)),
+AudioManagerBase::AudioManagerBase(std::unique_ptr<AudioThread> audio_thread,
+ AudioLogFactory* audio_log_factory)
+ : AudioManager(std::move(audio_thread)),
max_num_output_streams_(kDefaultMaxOutputStreams),
max_num_input_streams_(kDefaultMaxInputStreams),
num_output_streams_(0),
@@ -99,8 +97,6 @@ AudioManagerBase::AudioManagerBase(
audio_log_factory_(audio_log_factory) {}
AudioManagerBase::~AudioManagerBase() {
- DCHECK(GetTaskRunner()->BelongsToCurrentThread());
-
// All the output streams should have been deleted.
CHECK_EQ(0, num_output_streams_);
// All the input streams should have been deleted.
@@ -292,7 +288,7 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
std::unique_ptr<AudioOutputDispatcher> dispatcher;
if (output_params.format() != AudioParameters::AUDIO_FAKE) {
// Using unretained for |debug_recording_manager_| is safe since it
- // outlives the dispatchers (cleared in Shutdown()).
+ // outlives the dispatchers (cleared in ShutdownOnAudioThread()).
dispatcher = base::MakeUnique<AudioOutputResampler>(
this, params, output_params, output_device_id, kCloseDelay,
debug_recording_manager_
@@ -341,7 +337,7 @@ void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) {
delete stream;
}
-void AudioManagerBase::Shutdown() {
+void AudioManagerBase::ShutdownOnAudioThread() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
// Close all output streams.
@@ -359,7 +355,6 @@ void AudioManagerBase::Shutdown() {
AudioInputStream* stream = *iter++;
stream->Close();
}
- CHECK(input_streams_.empty());
o1ka 2017/05/10 15:57:57 Why is it removed?
alokp 2017/05/10 18:04:03 I meant to remove it in another patch. It somehow
#endif // OS_MACOSX
}

Powered by Google App Engine
This is Rietveld 408576698