| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/linux/audio_manager_linux.h" | 5 #include "media/audio/linux/audio_manager_linux.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "media/audio/audio_output_dispatcher.h" |
| 9 #include "media/audio/fake_audio_input_stream.h" | 10 #include "media/audio/fake_audio_input_stream.h" |
| 10 #include "media/audio/fake_audio_output_stream.h" | 11 #include "media/audio/fake_audio_output_stream.h" |
| 11 #include "media/audio/linux/alsa_input.h" | 12 #include "media/audio/linux/alsa_input.h" |
| 12 #include "media/audio/linux/alsa_output.h" | 13 #include "media/audio/linux/alsa_output.h" |
| 13 #include "media/audio/linux/alsa_wrapper.h" | 14 #include "media/audio/linux/alsa_wrapper.h" |
| 14 #include "media/base/limits.h" | 15 #include "media/base/limits.h" |
| 15 #include "media/base/media_switches.h" | 16 #include "media/base/media_switches.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 AudioManagerLinux::AudioManagerLinux() { | 88 AudioManagerLinux::AudioManagerLinux() { |
| 88 } | 89 } |
| 89 | 90 |
| 90 AudioManagerLinux::~AudioManagerLinux() { | 91 AudioManagerLinux::~AudioManagerLinux() { |
| 91 // Make sure we stop the thread first. If we let the default destructor to | 92 // Make sure we stop the thread first. If we let the default destructor to |
| 92 // destruct the members, we may destroy audio streams before stopping the | 93 // destruct the members, we may destroy audio streams before stopping the |
| 93 // thread, resulting an unexpected behavior. | 94 // thread, resulting an unexpected behavior. |
| 94 // This way we make sure activities of the audio streams are all stopped | 95 // This way we make sure activities of the audio streams are all stopped |
| 95 // before we destroy them. | 96 // before we destroy them. |
| 96 audio_thread_.Stop(); | 97 audio_thread_.Stop(); |
| 98 |
| 99 // Free output dispatchers first, so that they closes all streams that |
| 100 // are still open. |
| 101 output_dispatchers_.clear(); |
| 102 |
| 97 active_streams_.clear(); | 103 active_streams_.clear(); |
| 98 } | 104 } |
| 99 | 105 |
| 100 void AudioManagerLinux::Init() { | 106 void AudioManagerLinux::Init() { |
| 101 AudioManagerBase::Init(); | 107 AudioManagerBase::Init(); |
| 102 wrapper_.reset(new AlsaWrapper()); | 108 wrapper_.reset(new AlsaWrapper()); |
| 103 } | 109 } |
| 104 | 110 |
| 105 void AudioManagerLinux::MuteAll() { | 111 void AudioManagerLinux::MuteAll() { |
| 106 NOTIMPLEMENTED(); | 112 NOTIMPLEMENTED(); |
| 107 } | 113 } |
| 108 | 114 |
| 109 void AudioManagerLinux::UnMuteAll() { | 115 void AudioManagerLinux::UnMuteAll() { |
| 110 NOTIMPLEMENTED(); | 116 NOTIMPLEMENTED(); |
| 111 } | 117 } |
| 112 | 118 |
| 113 void AudioManagerLinux::ReleaseOutputStream(AlsaPcmOutputStream* stream) { | 119 void AudioManagerLinux::ReleaseOutputStream(AlsaPcmOutputStream* stream) { |
| 114 if (stream) { | 120 if (stream) { |
| 115 AutoLock l(lock_); | 121 AutoLock l(lock_); |
| 116 active_streams_.erase(stream); | 122 active_streams_.erase(stream); |
| 117 } | 123 } |
| 118 } | 124 } |
| 119 | 125 |
| 120 // static | 126 // static |
| 121 AudioManager* AudioManager::CreateAudioManager() { | 127 AudioManager* AudioManager::CreateAudioManager() { |
| 122 return new AudioManagerLinux(); | 128 return new AudioManagerLinux(); |
| 123 } | 129 } |
| OLD | NEW |