mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
Fix two sound looping bugs.
The first one caused the music to stop randomly on scene changes, reproducible by changing maps with different music while holding 'G' button to speed up time. For some reason this caused the music to stop playing during the crossfade. Wasn't able to find the root cause, so I added a little hack to kick the music back on track if it stops unexpectedly. The second one was a simple string case issue; mostly noticable because of map background sounds not playing in loop mode. (this is possibly a regression from an earlier patch, not sure)
This commit is contained in:
parent
ac6ca117aa
commit
66d3b90473
2 changed files with 26 additions and 39 deletions
|
@ -90,6 +90,7 @@ namespace SoundCore
|
|||
|
||||
bool stopMusicOnFadeOut=false;
|
||||
bool wasPlayingVoice=false;
|
||||
bool playingMusicOnce=false;
|
||||
|
||||
typedef std::list<FadeCh> FadeChs;
|
||||
FadeChs fadeChs;
|
||||
|
@ -466,7 +467,7 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on)
|
|||
std::string SoundManager::getVolumeString()
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "sfxFader: " << this->sfxFader << " sfxVol: " << this->sfxVol << std::endl;
|
||||
os << "sfxFader: " << this->sfxFader << " sfxVol: " << this->sfxVol << " [" << lastMusic << "]" << std::endl;
|
||||
os << "musVol: " << musVol.y << " voxVol: " << voxVol.y << std::endl;
|
||||
|
||||
float musicChannelVol = -1;
|
||||
|
@ -657,21 +658,17 @@ void SoundManager::update(float dt)
|
|||
|
||||
if (musicChannel)
|
||||
{
|
||||
bool _isplaying = false;
|
||||
result = musicChannel->isPlaying(&_isplaying);
|
||||
checkError();
|
||||
if (!_isplaying)
|
||||
if (!isPlayingMusic())
|
||||
{
|
||||
result = musicChannel->stop();
|
||||
checkError();
|
||||
musicChannel = 0;
|
||||
|
||||
if (musicStream)
|
||||
if(!playingMusicOnce && lastMusic.size())
|
||||
{
|
||||
result = musicStream->release();
|
||||
checkError();
|
||||
musicStream = 0;
|
||||
}
|
||||
debugLog("music not playing, but it should be - force restart");
|
||||
playMusic(lastMusic, SLT_LOOP, SFT_IN, 1, SCT_NORMAL); // FIXME: make sure this works with playMusicOnce()
|
||||
}
|
||||
else
|
||||
{
|
||||
stopMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -685,17 +682,7 @@ void SoundManager::update(float dt)
|
|||
|
||||
if (musVol.y <= 0 && stopMusicOnFadeOut)
|
||||
{
|
||||
result = musicChannel->stop();
|
||||
checkError();
|
||||
musicChannel = 0;
|
||||
|
||||
if (musicStream)
|
||||
{
|
||||
result = musicStream->release();
|
||||
checkError();
|
||||
musicStream = 0;
|
||||
}
|
||||
|
||||
stopMusic();
|
||||
stopMusicOnFadeOut = false;
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +778,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
|||
case SFT_CROSS:
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (musicChannel2)
|
||||
{
|
||||
musicChannel2->stop();
|
||||
|
@ -1342,9 +1328,11 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
case SLT_OFF:
|
||||
case SLT_NONE:
|
||||
mode |= FMOD_LOOP_OFF;
|
||||
playingMusicOnce = true;
|
||||
break;
|
||||
default:
|
||||
mode |= FMOD_LOOP_NORMAL;
|
||||
playingMusicOnce = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1388,18 +1376,20 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
|
||||
result = musicChannel->setPaused(false); // This is where the sound really starts.
|
||||
checkError();
|
||||
debugLog("music play: " + fn);
|
||||
}
|
||||
else
|
||||
{
|
||||
debugLog("Failed to create music stream: " + fn);
|
||||
}
|
||||
#endif
|
||||
|
||||
debugLog("playmusic end");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SoundManager::stopMusic()
|
||||
{
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (musicChannel)
|
||||
{
|
||||
|
@ -1414,7 +1404,7 @@ void SoundManager::stopMusic()
|
|||
musicChannel = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
playingMusicOnce = false;
|
||||
lastMusic = "";
|
||||
}
|
||||
|
||||
|
@ -1518,6 +1508,12 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
|
|||
|
||||
std::string f = filename, name;
|
||||
|
||||
// HACK: proper sound looping
|
||||
bool loop = false;
|
||||
stringToLower(f);
|
||||
if (f.find("loop")!=std::string::npos)
|
||||
loop = true;
|
||||
|
||||
// WARNING: local sounds should go here!
|
||||
|
||||
debugLog(filename);
|
||||
|
@ -1540,13 +1536,6 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
|
|||
f = core->adjustFilenameCase(f);
|
||||
}
|
||||
|
||||
bool loop = false;
|
||||
|
||||
if (filename.find("loop")!=std::string::npos)
|
||||
{
|
||||
loop = true;
|
||||
}
|
||||
|
||||
int loc = f.find_last_of('/');
|
||||
int loc2 = f.rfind('.');
|
||||
if (loc != std::string::npos && loc2 != std::string::npos)
|
||||
|
|
|
@ -213,8 +213,6 @@ public:
|
|||
|
||||
void update(float dt);
|
||||
|
||||
std::string currentMusic;
|
||||
|
||||
bool enabled;
|
||||
|
||||
bool checkError();
|
||||
|
|
Loading…
Reference in a new issue