Skip to content

Commit

Permalink
Adopted GOSoundGroupWorkItem for breaking with Panic on Waiting Grand…
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Samarin committed Oct 9, 2021
1 parent 3f52f28 commit 0351dc8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
19 changes: 14 additions & 5 deletions src/grandorgue/GOSoundGroupWorkItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ void GOSoundGroupWorkItem::Run(GOSoundThread *pThread)
return;
CheckPoint(pThread, "GOSoundGroupWorkItem::Run.10");
{
GOMutexLocker locker(m_Mutex);
GOMutexLocker locker(m_Mutex, false, "GOSoundGroupWorkItem::Run.beforeProcess", pThread);

if (! locker.IsLocked())
return;

if (m_Done == 0)
{
m_Active.Move();
Expand All @@ -113,7 +117,11 @@ void GOSoundGroupWorkItem::Run(GOSoundThread *pThread)
ProcessReleaseList(m_Release, buffer);
CheckPoint(pThread, "GOSoundGroupWorkItem::Run.50");
{
GOMutexLocker locker(m_Mutex);
GOMutexLocker locker(m_Mutex, false, "GOSoundGroupWorkItem::Run.afterProcess", pThread);

if (! locker.IsLocked())
return;

if (m_Done == 1)
{
memcpy(m_Buffer, buffer, m_SamplesPerBuffer * 2 * sizeof(float));
Expand Down Expand Up @@ -152,10 +160,11 @@ void GOSoundGroupWorkItem::Finish(bool stop, GOSoundThread *pThread)

{
CheckPoint(pThread, "GOSoundGroupWorkItem::Finish.30");
GOMutexLocker locker(m_Mutex);
GOMutexLocker locker(m_Mutex, false, "GOSoundGroupWorkItem::Finish", pThread);

CheckPoint(pThread, "GOSoundGroupWorkItem::Finish.40");
if (m_Done != 3)
m_Condition.Wait();
if (locker .IsLocked() && m_Done != 3)
m_Condition.WaitOrStop(pThread);
CheckPoint(pThread, "GOSoundGroupWorkItem::Finish.50");
}
}
1 change: 1 addition & 0 deletions src/grandorgue/GOSoundGroupWorkItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "GOSoundWorkItem.h"
#include "threading/GOCondition.h"
#include "threading/GOMutex.h"
#include "GOSoundThread.h"

class GOSoundEngine;

Expand Down
10 changes: 6 additions & 4 deletions src/grandorgue/GOSoundThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ void GOSoundThread::Entry()
while (next != NULL);
m_CurrentGroup = 0;

GOMutexLocker lock(m_Mutex);
if (ShouldStop() || m_Stop)
break;
m_Condition.Wait();
GOMutexLocker lock(m_Mutex, false, "GOSoundThread::Entry", this);

if (! lock.IsLocked() || ShouldStop() || m_Stop)
break;
if (! m_Condition.WaitOrStop(this))
break;
}
return;
}
Expand Down

0 comments on commit 0351dc8

Please sign in to comment.