Skip to content

Commit e16a161

Browse files
committed
another fix
1 parent 356a185 commit e16a161

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/DMD.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ void DMD::SerumThread()
883883
while (true)
884884
{
885885
auto systemNow = std::chrono::system_clock::now();
886-
auto nextWakeTime = systemNow + std::chrono::hours(1); // Default: far in the future
886+
auto nextWakeTime = systemNow + std::chrono::hours(24); // Default: far in the future
887887

888888
if (nextRotation > 0)
889889
{
@@ -901,9 +901,18 @@ void DMD::SerumThread()
901901
// Wait until either:
902902
// - m_dmdFrameReady/m_stopFlag is set (via notify_all), OR
903903
// - The timeout (nextRotation/nextSceneFrame) is reached
904-
m_dmdCV.wait_until(
905-
sl, nextWakeTime, [&]()
906-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
904+
m_dmdCV.wait_until(sl, nextWakeTime,
905+
[&]()
906+
{
907+
uint32_t now = std::chrono::duration_cast<std::chrono::milliseconds>(
908+
std::chrono::system_clock::now().time_since_epoch())
909+
.count();
910+
911+
return m_dmdFrameReady.load(std::memory_order_relaxed) ||
912+
m_stopFlag.load(std::memory_order_relaxed) ||
913+
(nextRotation > 0 && nextRotation <= now) ||
914+
(sceneCurrentFrame < sceneFrameCount && nextSceneFrame <= now);
915+
});
907916
sl.unlock();
908917

909918
if (m_stopFlag.load(std::memory_order_acquire))

0 commit comments

Comments
 (0)