| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sounds/sounds_manager.h" | 5 #include "media/audio/sounds/sounds_manager.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return true; | 82 return true; |
| 83 } | 83 } |
| 84 | 84 |
| 85 base::TimeDelta SoundsManagerImpl::GetDuration(SoundKey key) { | 85 base::TimeDelta SoundsManagerImpl::GetDuration(SoundKey key) { |
| 86 DCHECK(CalledOnValidThread()); | 86 DCHECK(CalledOnValidThread()); |
| 87 linked_ptr<AudioStreamHandler> handler = GetHandler(key); | 87 linked_ptr<AudioStreamHandler> handler = GetHandler(key); |
| 88 if (!handler.get()) | 88 if (!handler.get()) |
| 89 return base::TimeDelta(); | 89 return base::TimeDelta(); |
| 90 if (!handler->IsInitialized()) | 90 if (!handler->IsInitialized()) |
| 91 return base::TimeDelta(); | 91 return base::TimeDelta(); |
| 92 const WavAudioHandler& wav_audio = handler->wav_audio_handler(); | 92 |
| 93 return wav_audio.GetDuration(); | 93 const WavAudioHandler* wav_audio = handler->wav_audio_handler(); |
| 94 DCHECK(wav_audio); |
| 95 return wav_audio->GetDuration(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 linked_ptr<AudioStreamHandler> SoundsManagerImpl::GetHandler(SoundKey key) { | 98 linked_ptr<AudioStreamHandler> SoundsManagerImpl::GetHandler(SoundKey key) { |
| 97 auto key_handler_pair_iter = handlers_.find(key); | 99 auto key_handler_pair_iter = handlers_.find(key); |
| 98 return key_handler_pair_iter == handlers_.end() ? | 100 return key_handler_pair_iter == handlers_.end() ? |
| 99 linked_ptr<AudioStreamHandler>() : key_handler_pair_iter->second; | 101 linked_ptr<AudioStreamHandler>() : key_handler_pair_iter->second; |
| 100 } | 102 } |
| 101 | 103 |
| 102 } // namespace | 104 } // namespace |
| 103 | 105 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 130 | 132 |
| 131 // static | 133 // static |
| 132 void SoundsManager::InitializeForTesting(SoundsManager* manager) { | 134 void SoundsManager::InitializeForTesting(SoundsManager* manager) { |
| 133 CHECK(!g_instance) << "SoundsManager is already initialized."; | 135 CHECK(!g_instance) << "SoundsManager is already initialized."; |
| 134 CHECK(manager); | 136 CHECK(manager); |
| 135 g_instance = manager; | 137 g_instance = manager; |
| 136 g_initialized_for_testing = true; | 138 g_initialized_for_testing = true; |
| 137 } | 139 } |
| 138 | 140 |
| 139 } // namespace media | 141 } // namespace media |
| OLD | NEW |