OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/audio/fake_audio_output_stream.h" | 10 #include "media/audio/fake_audio_output_stream.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 active_streams_[stream] = scoped_refptr<AlsaPcmOutputStream>(stream); | 52 active_streams_[stream] = scoped_refptr<AlsaPcmOutputStream>(stream); |
53 return stream; | 53 return stream; |
54 } | 54 } |
55 | 55 |
56 AudioManagerLinux::AudioManagerLinux() | 56 AudioManagerLinux::AudioManagerLinux() |
57 : audio_thread_("AudioThread"), | 57 : audio_thread_("AudioThread"), |
58 initialized_(false) { | 58 initialized_(false) { |
59 } | 59 } |
60 | 60 |
61 AudioManagerLinux::~AudioManagerLinux() { | 61 AudioManagerLinux::~AudioManagerLinux() { |
| 62 // Make sure we stop the thread first. If we let the default destructor to |
| 63 // destruct the members, we may destroy audio streams before stopping the |
| 64 // thread, resulting an unexpected behavior. |
| 65 // This way we make sure activities of the audio streams are all stopped |
| 66 // before we destroy them. |
| 67 audio_thread_.Stop(); |
62 active_streams_.clear(); | 68 active_streams_.clear(); |
63 } | 69 } |
64 | 70 |
65 void AudioManagerLinux::Init() { | 71 void AudioManagerLinux::Init() { |
66 initialized_ = audio_thread_.Start(); | 72 initialized_ = audio_thread_.Start(); |
67 wrapper_.reset(new AlsaWrapper()); | 73 wrapper_.reset(new AlsaWrapper()); |
68 } | 74 } |
69 | 75 |
70 void AudioManagerLinux::MuteAll() { | 76 void AudioManagerLinux::MuteAll() { |
71 NOTIMPLEMENTED(); | 77 NOTIMPLEMENTED(); |
(...skipping 17 matching lines...) Expand all Loading... |
89 } | 95 } |
90 | 96 |
91 AudioManager* AudioManager::GetAudioManager() { | 97 AudioManager* AudioManager::GetAudioManager() { |
92 if (!g_audio_manager) { | 98 if (!g_audio_manager) { |
93 g_audio_manager = new AudioManagerLinux(); | 99 g_audio_manager = new AudioManagerLinux(); |
94 g_audio_manager->Init(); | 100 g_audio_manager->Init(); |
95 base::AtExitManager::RegisterCallback(&DestroyAudioManagerLinux, NULL); | 101 base::AtExitManager::RegisterCallback(&DestroyAudioManagerLinux, NULL); |
96 } | 102 } |
97 return g_audio_manager; | 103 return g_audio_manager; |
98 } | 104 } |
OLD | NEW |