mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 05:21:16 +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)))
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(CritSec);
|
||||
Stop();
|
||||
}
|
||||
if (m_Status != STATE_Stopped && !MIDI->IsOpen())
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(CritSec);
|
||||
Stop();
|
||||
}
|
||||
return m_Status != STATE_Stopped;
|
||||
|
@ -695,7 +697,11 @@ void MIDIStreamer::Callback(void *userdata)
|
|||
|
||||
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)
|
||||
{
|
||||
if (!song) return;
|
||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
||||
song->Pause();
|
||||
}
|
||||
|
||||
void ZMusic_Resume(MusInfo *song)
|
||||
{
|
||||
if (!song) return;
|
||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
||||
song->Resume();
|
||||
}
|
||||
|
||||
void ZMusic_Update(MusInfo *song)
|
||||
{
|
||||
if (!song) return;
|
||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
||||
song->Update();
|
||||
}
|
||||
|
||||
bool ZMusic_IsPlaying(MusInfo *song)
|
||||
{
|
||||
if (!song) return false;
|
||||
std::lock_guard<std::mutex> lock(song->CritSec);
|
||||
return song->IsPlaying();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue