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

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 2929823002: Making AudioManagerBase::ShutdownOnAudioThread() platform-agnostic (Closed)
Patch Set: moving closing streams to AudioManagerMac Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // TODO(xians) : Have a clearer destruction path for the AudioInputStream. 341 // TODO(xians) : Have a clearer destruction path for the AudioInputStream.
342 CHECK_EQ(1u, input_streams_.erase(stream)); 342 CHECK_EQ(1u, input_streams_.erase(stream));
343 delete stream; 343 delete stream;
344 } 344 }
345 345
346 void AudioManagerBase::ShutdownOnAudioThread() { 346 void AudioManagerBase::ShutdownOnAudioThread() {
347 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 347 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
348 348
349 // Close all output streams. 349 // Close all output streams.
350 output_dispatchers_.clear(); 350 output_dispatchers_.clear();
351
352 #if defined(OS_MACOSX)
353 // On mac, AudioManager runs on the main thread, loop for which stops
354 // processing task queue at this point. So even if tasks to close the
355 // streams are enqueued, they would not run leading to CHECKs getting hit
356 // in the destructor about open streams. Close them explicitly here.
357 // crbug.com/608049.
358 for (auto iter = input_streams_.begin(); iter != input_streams_.end();) {
359 // Note: Closing the stream will invalidate the iterator.
360 // Increment the iterator before closing the stream.
361 AudioInputStream* stream = *iter++;
362 stream->Close();
363 }
364 CHECK(input_streams_.empty());
365 #endif // OS_MACOSX
366 } 351 }
367 352
368 void AudioManagerBase::AddOutputDeviceChangeListener( 353 void AudioManagerBase::AddOutputDeviceChangeListener(
369 AudioDeviceListener* listener) { 354 AudioDeviceListener* listener) {
370 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 355 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
371 output_listeners_.AddObserver(listener); 356 output_listeners_.AddObserver(listener);
372 } 357 }
373 358
374 void AudioManagerBase::RemoveOutputDeviceChangeListener( 359 void AudioManagerBase::RemoveOutputDeviceChangeListener(
375 AudioDeviceListener* listener) { 360 AudioDeviceListener* listener) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 return base::MakeUnique<AudioDebugRecordingManager>(std::move(task_runner)); 468 return base::MakeUnique<AudioDebugRecordingManager>(std::move(task_runner));
484 } 469 }
485 470
486 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input, 471 void AudioManagerBase::SetMaxStreamCountForTesting(int max_input,
487 int max_output) { 472 int max_output) {
488 max_num_output_streams_ = max_output; 473 max_num_output_streams_ = max_output;
489 max_num_input_streams_ = max_input; 474 max_num_input_streams_ = max_input;
490 } 475 }
491 476
492 } // namespace media 477 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698