| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return handlers_[key]->Play(); | 68 return handlers_[key]->Play(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 base::TimeDelta SoundsManagerImpl::GetDuration(SoundKey key) { | 71 base::TimeDelta SoundsManagerImpl::GetDuration(SoundKey key) { |
| 72 DCHECK(CalledOnValidThread()); | 72 DCHECK(CalledOnValidThread()); |
| 73 if (handlers_.find(key) == handlers_.end() || | 73 if (handlers_.find(key) == handlers_.end() || |
| 74 !handlers_[key]->IsInitialized()) { | 74 !handlers_[key]->IsInitialized()) { |
| 75 return base::TimeDelta(); | 75 return base::TimeDelta(); |
| 76 } | 76 } |
| 77 const WavAudioHandler& wav_audio = handlers_[key]->wav_audio_handler(); | 77 const WavAudioHandler& wav_audio = handlers_[key]->wav_audio_handler(); |
| 78 const int64 size = wav_audio.size(); | 78 return wav_audio.params().GetBufferDuration(); |
| 79 const int64 rate = wav_audio.byte_rate(); | |
| 80 return base::TimeDelta::FromMicroseconds(size * 1000000 / rate); | |
| 81 } | 79 } |
| 82 | 80 |
| 83 // SoundsManagerStub --------------------------------------------------- | 81 // SoundsManagerStub --------------------------------------------------- |
| 84 | 82 |
| 85 class SoundsManagerStub : public SoundsManager { | 83 class SoundsManagerStub : public SoundsManager { |
| 86 public: | 84 public: |
| 87 SoundsManagerStub(); | 85 SoundsManagerStub(); |
| 88 virtual ~SoundsManagerStub(); | 86 virtual ~SoundsManagerStub(); |
| 89 | 87 |
| 90 // SoundsManager implementation: | 88 // SoundsManager implementation: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 g_instance = NULL; | 140 g_instance = NULL; |
| 143 } | 141 } |
| 144 | 142 |
| 145 // static | 143 // static |
| 146 SoundsManager* SoundsManager::Get() { | 144 SoundsManager* SoundsManager::Get() { |
| 147 CHECK(g_instance) << "SoundsManager::Get() is called before Create()"; | 145 CHECK(g_instance) << "SoundsManager::Get() is called before Create()"; |
| 148 return g_instance; | 146 return g_instance; |
| 149 } | 147 } |
| 150 | 148 |
| 151 } // namespace media | 149 } // namespace media |
| OLD | NEW |