Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 2431608

Browse files
committed
Fix incorrect music position after resuming Activity
1 parent 81c1d45 commit 2431608

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Managers/AudioMan.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@ namespace RTE {
233233
FMOD::Sound *musicSound;
234234
result = (result == FMOD_OK) ? musicChannel->getCurrentSound(&musicSound) : result;
235235

236-
unsigned int musicLength;
236+
unsigned int musicLength = 0;
237237
result = (result == FMOD_OK) ? musicSound->getLength(&musicLength, FMOD_TIMEUNIT_MS) : result;
238238

239-
position = std::clamp(position, 0.0F, static_cast<float>(musicLength)) / 1000.0F;
240-
result = (result == FMOD_OK) ? musicChannel->setPosition(static_cast<unsigned int>(position), FMOD_TIMEUNIT_MS) : result;
239+
result = (result == FMOD_OK) ? musicChannel->setPosition(std::clamp(static_cast<unsigned int>(position * 1000.0F), 0U, musicLength), FMOD_TIMEUNIT_MS) : result;
241240

242241
if (result != FMOD_OK) { g_ConsoleMan.PrintString("ERROR: Could not set music position: " + std::string(FMOD_ErrorString(result))); }
243242
}

0 commit comments

Comments
 (0)