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