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

Side by Side Diff: media/audio/mac/audio_manager_mac.cc

Issue 2503693002: Tracks all open input streams in AudioManagerBase. (Closed)
Patch Set: fixes compile error on windows Created 4 years, 1 month 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
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/mac/audio_manager_mac.h" 5 #include "media/audio/mac/audio_manager_mac.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 FROM_HERE, base::Bind(&AudioManagerMac::InitializeOnAudioThread, 377 FROM_HERE, base::Bind(&AudioManagerMac::InitializeOnAudioThread,
378 base::Unretained(this))); 378 base::Unretained(this)));
379 } 379 }
380 380
381 AudioManagerMac::~AudioManagerMac() { 381 AudioManagerMac::~AudioManagerMac() {
382 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); 382 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
383 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize() 383 // We are now in shutdown mode. This flag disables MaybeChangeBufferSize()
384 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio 384 // and IncreaseIOBufferSizeIfPossible() which both touches native Core Audio
385 // APIs and they can fail and disrupt tests during shutdown. 385 // APIs and they can fail and disrupt tests during shutdown.
386 in_shutdown_ = true; 386 in_shutdown_ = true;
387 // We have seen cases where active input audio is not closed down properly
388 // at browser shutdown. AudioInputController::Close() is called but tasks
389 // in AudioInputController::DoClose() are not executed. Hence, input streams
390 // might remain even at this late state. |low_latency_input_streams_| will be
391 // modified during the call to stream->Close(), so we can't iterate over it
392 // here. Instead iterate over a copy.
393 // TODO(henrika): figure out the real cause why streams are not closed
394 // properly by the AIC for all cases and then remove this loop.
395 auto low_latency_input_streams_copy = low_latency_input_streams_;
396 for (auto* stream : low_latency_input_streams_copy) {
397 LOG(WARNING) << "Closing existing audio input stream at destruction";
398 // Prevents active Core Audio callbacks to use possibly invalid objects
399 // in its OnData() callback.
400 stream->Stop();
401 // Avoids hitting CHECK in dtor of AudioManagerBase.
402 stream->Close();
403 }
404 // Perform same type of cleanup as above but for high-latency input streams.
405 auto basic_input_streams_copy = basic_input_streams_;
406 for (auto* stream : basic_input_streams_copy) {
407 LOG(WARNING)
408 << "Closing existing high-latency audio input stream at destruction";
409 // Prevents active AudioQueue callbacks to use possibly invalid objects
410 // in its OnData() callback.
411 stream->Stop();
412 // Avoids hitting CHECK in dtor of AudioManagerBase.
413 stream->Close();
414 }
415 Shutdown(); 387 Shutdown();
416 } 388 }
417 389
418 bool AudioManagerMac::HasAudioOutputDevices() { 390 bool AudioManagerMac::HasAudioOutputDevices() {
419 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); 391 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice);
420 } 392 }
421 393
422 bool AudioManagerMac::HasAudioInputDevices() { 394 bool AudioManagerMac::HasAudioInputDevices() {
423 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice); 395 return HasAudioHardware(kAudioHardwarePropertyDefaultInputDevice);
424 } 396 }
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 ScopedAudioManagerPtr CreateAudioManager( 1080 ScopedAudioManagerPtr CreateAudioManager(
1109 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 1081 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
1110 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, 1082 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
1111 AudioLogFactory* audio_log_factory) { 1083 AudioLogFactory* audio_log_factory) {
1112 return ScopedAudioManagerPtr( 1084 return ScopedAudioManagerPtr(
1113 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner), 1085 new AudioManagerMac(std::move(task_runner), std::move(worker_task_runner),
1114 audio_log_factory)); 1086 audio_log_factory));
1115 } 1087 }
1116 1088
1117 } // namespace media 1089 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698