MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / getSoundFileDuration

Method getSoundFileDuration

plugins/sound/SoundManager.cpp:149–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149float SoundManager::getSoundFileDuration(const std::string& vfsPath)
150{
151 auto file = openSoundFile(vfsPath);
152
153 if (!file)
154 {
155 throw std::out_of_range("Could not resolve sound file " + vfsPath);
156 }
157
158 auto extension = string::to_lower_copy(os::getExtension(file->getName()));
159
160 try
161 {
162 if (extension == "wav")
163 {
164 return WavFileLoader::GetDuration(file->getInputStream());
165 }
166 else if (extension == "ogg")
167 {
168 return OggFileLoader::GetDuration(*file);
169 }
170 }
171 catch (const std::runtime_error& ex)
172 {
173 rError() << "Error determining sound file duration " << ex.what() << std::endl;
174 }
175
176 return 0.0f;
177}
178
179void SoundManager::reloadSounds()
180{

Callers 2

loadFileDurationAsyncMethod · 0.80
TEST_FFunction · 0.80

Calls 6

openSoundFileFunction · 0.85
to_lower_copyFunction · 0.85
getExtensionFunction · 0.85
rErrorFunction · 0.85
whatMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected