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 15, 2021
1 parent 751b794 commit fe6b957
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 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
7 changes: 5 additions & 2 deletions src/grandorgue/GOSoundThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ void GOSoundThread::Entry()
if (shouldStop)
break;

GOMutexLocker lock(m_Mutex);
GOMutexLocker lock(m_Mutex, false, "GOSoundThread::Entry", this);

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

0 comments on commit fe6b957

Please sign in to comment.