mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 13:31:37 +00:00
- apply the ZMusic mutex a bit more finely grained.
It should only guard the critical parts, like calling Stop() but can let Update and IsPlaying method work unhindered otherwise.
This commit is contained in:
parent
f014e9cd8c
commit
0ee0034beb
2 changed files with 7 additions and 5 deletions
|
@ -570,10 +570,12 @@ bool MIDIStreamer::IsPlaying()
|
||||||
{
|
{
|
||||||
if (m_Status != STATE_Stopped && (MIDI == NULL || (EndQueued != 0 && EndQueued < 4)))
|
if (m_Status != STATE_Stopped && (MIDI == NULL || (EndQueued != 0 && EndQueued < 4)))
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(CritSec);
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
if (m_Status != STATE_Stopped && !MIDI->IsOpen())
|
if (m_Status != STATE_Stopped && !MIDI->IsOpen())
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(CritSec);
|
||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
return m_Status != STATE_Stopped;
|
return m_Status != STATE_Stopped;
|
||||||
|
@ -695,7 +697,11 @@ void MIDIStreamer::Callback(void *userdata)
|
||||||
|
|
||||||
void MIDIStreamer::Update()
|
void MIDIStreamer::Update()
|
||||||
{
|
{
|
||||||
if (MIDI != nullptr && !MIDI->Update()) Stop();
|
if (MIDI != nullptr && !MIDI->Update())
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(CritSec);
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -340,28 +340,24 @@ void ZMusic_Start(MusInfo *song, int subsong, bool loop)
|
||||||
void ZMusic_Pause(MusInfo *song)
|
void ZMusic_Pause(MusInfo *song)
|
||||||
{
|
{
|
||||||
if (!song) return;
|
if (!song) return;
|
||||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
|
||||||
song->Pause();
|
song->Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZMusic_Resume(MusInfo *song)
|
void ZMusic_Resume(MusInfo *song)
|
||||||
{
|
{
|
||||||
if (!song) return;
|
if (!song) return;
|
||||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
|
||||||
song->Resume();
|
song->Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZMusic_Update(MusInfo *song)
|
void ZMusic_Update(MusInfo *song)
|
||||||
{
|
{
|
||||||
if (!song) return;
|
if (!song) return;
|
||||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
|
||||||
song->Update();
|
song->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZMusic_IsPlaying(MusInfo *song)
|
bool ZMusic_IsPlaying(MusInfo *song)
|
||||||
{
|
{
|
||||||
if (!song) return false;
|
if (!song) return false;
|
||||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
|
||||||
return song->IsPlaying();
|
return song->IsPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue