Audio/Music: Fix Stop not resetting playing offset if music was already stopped

Also prevented a useless seek at destruction
This commit is contained in:
Lynix 2016-11-24 20:17:30 +01:00
parent e7ddcaf876
commit 057de1544b
2 changed files with 13 additions and 8 deletions

View File

@ -73,6 +73,7 @@ namespace Nz
bool FillAndQueueBuffer(unsigned int buffer);
void MusicThread();
void StopThread();
static MusicLoader::LoaderList s_loaders;
};

View File

@ -91,7 +91,7 @@ namespace Nz
{
if (m_impl)
{
Stop();
StopThread();
delete m_impl;
m_impl = nullptr;
@ -339,13 +339,8 @@ namespace Nz
{
NazaraAssert(m_impl, "Music not created");
if (m_impl->streaming)
{
m_impl->streaming = false;
m_impl->thread.Join();
SetPlayingOffset(0);
}
StopThread();
SetPlayingOffset(0);
}
bool Music::FillAndQueueBuffer(unsigned int buffer)
@ -444,5 +439,14 @@ namespace Nz
alDeleteBuffers(NAZARA_AUDIO_STREAMED_BUFFER_COUNT, buffers);
}
void Music::StopThread()
{
if (m_impl->streaming)
{
m_impl->streaming = false;
m_impl->thread.Join();
}
}
MusicLoader::LoaderList Music::s_loaders;
}