mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Fix that Sounds can't restart
Sounds now restart when e.g. scrolling up/down repeatedly.
This commit is contained in:
parent
a2c990bd26
commit
517ccbefb5
|
@ -82,8 +82,18 @@ void Sound::play()
|
||||||
if(mSampleData == NULL)
|
if(mSampleData == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//flag our sample as playing
|
if (playing)
|
||||||
playing = true;
|
{
|
||||||
|
//replay from start. rewind the sample to the beginning
|
||||||
|
SDL_LockAudio();
|
||||||
|
mSamplePos = 0;
|
||||||
|
SDL_UnlockAudio();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//flag our sample as playing
|
||||||
|
playing = true;
|
||||||
|
}
|
||||||
//tell the AudioManager to start playing samples
|
//tell the AudioManager to start playing samples
|
||||||
AudioManager::play();
|
AudioManager::play();
|
||||||
}
|
}
|
||||||
|
@ -96,8 +106,10 @@ bool Sound::isPlaying() const
|
||||||
void Sound::stop()
|
void Sound::stop()
|
||||||
{
|
{
|
||||||
//flag our sample as playing and rewind its position
|
//flag our sample as playing and rewind its position
|
||||||
|
SDL_LockAudio();
|
||||||
playing = false;
|
playing = false;
|
||||||
mSamplePos = 0;
|
mSamplePos = 0;
|
||||||
|
SDL_UnlockAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint8 * Sound::getData() const
|
const Uint8 * Sound::getData() const
|
||||||
|
|
Loading…
Reference in a new issue