Skip to content

Commit fdcc11a

Browse files
authored
libzedmd 0.10.1, libserum v2.4.1 and WPC & Gottlieb fixes (vpinball#95)
1 parent fe59ded commit fdcc11a

File tree

7 files changed

+87
-52
lines changed

7 files changed

+87
-52
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ AltColor = 1
163163
AltColorPath =
164164
# Set to 1 if PUP DMD frame matching should be used, 0 if not.
165165
PUPCapture = 1
166+
# Set to 1 if Serum PUP frame matching should be used, 0 if not.
167+
SerumPUPTriggers = 0
166168
# Overwrite the PUPVideosPath sent by the client and set it to a fixed value.
167169
PUPVideosPath =
168170
# Set to 1 if PUP DMD frame matching should respect the exact colors, 0 if not.

dmdserver.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ AltColor = 1
1111
AltColorPath =
1212
# Set to 1 if PUP DMD frame matching should be used, 0 if not.
1313
PUPCapture = 1
14+
# Set to 1 if Serum PUP frame matching should be used, 0 if not.
15+
SerumPUPTriggers = 0
1416
# Overwrite the PUPVideosPath sent by the client and set it to a fixed value.
1517
PUPVideosPath =
1618
# Set to 1 if PUP DMD frame matching should respect the exact colors, 0 if not.

include/DMDUtil/Config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class DMDUTILAPI Config
4343
const char* GetAltColorPath() const { return m_altColorPath.c_str(); }
4444
bool IsPUPCapture() const { return m_pupCapture; }
4545
void SetPUPCapture(bool pupCapture) { m_pupCapture = pupCapture; }
46+
bool IsSerumPUPTriggers() const { return m_serumPupTriggers; }
47+
void SetSerumPUPTriggers(bool serumPupTriggers) { m_serumPupTriggers = serumPupTriggers; }
4648
void SetPUPVideosPath(const char* path) { m_pupVideosPath = path; }
4749
const char* GetPUPVideosPath() const { return m_pupVideosPath.c_str(); }
4850
bool IsPUPExactColorMatch() const { return m_pupExactColorMatch; }
@@ -122,6 +124,7 @@ class DMDUTILAPI Config
122124
bool m_altColor;
123125
std::string m_altColorPath;
124126
bool m_pupCapture;
127+
bool m_serumPupTriggers;
125128
std::string m_pupVideosPath;
126129
bool m_pupExactColorMatch;
127130
int m_framesTimeout;

include/DMDUtil/DMD.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ class DMDUTILAPI DMD
230230
std::thread* m_pSerumThread;
231231
std::shared_mutex m_dmdSharedMutex;
232232
std::condition_variable_any m_dmdCV;
233-
std::atomic<bool> m_dmdFrameReady;
234233
std::atomic<bool> m_stopFlag;
235234
std::atomic<uint16_t> m_updateBufferQueuePosition;
236235
std::atomic<uint16_t> m_pupSceneId;

platforms/config.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -e
44

5-
LIBZEDMD_SHA=4c8211ac91dfeae3665ebd2530b8d6b9ece8cbc1
6-
LIBSERUM_SHA=9beac4e47d83ea2384316150c5b131c467d1ef8d
5+
LIBZEDMD_SHA=cb969273720234df2f11f2fd7c81fe375f83cfe2
6+
LIBSERUM_SHA=0c2e688dca271b2c3e1dc31fe71fc0276d33ffab
77
LIBPUPDMD_SHA=124f45e5ddd59ceb339591de88fcca72f8c54612
88

99
if [ -z "${BUILD_TYPE}" ]; then

src/Config.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Config::Config()
1919
m_altColor = true;
2020
m_altColorPath.clear();
2121
m_pupCapture = false;
22+
m_serumPupTriggers = false;
2223
m_pupVideosPath.clear();
2324
m_pupExactColorMatch = true;
2425
m_framesTimeout = 0;
@@ -92,6 +93,15 @@ void Config::parseConfigFile(const char* path)
9293
SetPUPCapture(false);
9394
}
9495

96+
try
97+
{
98+
SetSerumPUPTriggers(r.Get<bool>("DMDServer", "SerumPUPTriggers", false));
99+
}
100+
catch (const std::exception&)
101+
{
102+
SetSerumPUPTriggers(false);
103+
}
104+
95105
try
96106
{
97107
SetPUPVideosPath(r.Get<std::string>("DMDServer", "PUPVideosPath", "").c_str());

src/DMD.cpp

Lines changed: 68 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
#include "AlphaNumeric.h"
2626
#include "FrameUtil.h"
2727
#include "Logger.h"
28+
#include "TimeUtils.h"
2829
#include "ZeDMD.h"
2930
#include "komihash/komihash.h"
3031
#include "pupdmd.h"
3132
#include "serum-decode.h"
3233
#include "serum.h"
33-
#include "TimeUtils.h"
3434
#include "sockpp/tcp_connector.h"
3535

3636
namespace DMDUtil
@@ -150,7 +150,6 @@ DMD::DMD()
150150
}
151151
m_updateBufferQueuePosition.store(0, std::memory_order_release);
152152
m_stopFlag.store(false, std::memory_order_release);
153-
m_dmdFrameReady.store(false, std::memory_order_release);
154153
m_updateBuffered = std::make_shared<Update>();
155154

156155
m_pAlphaNumeric = new AlphaNumeric();
@@ -477,7 +476,6 @@ void DMD::QueueUpdate(const std::shared_ptr<Update> dmdUpdate, bool buffered)
477476
memcpy(m_pUpdateBufferQueue[(++updateBufferQueuePosition) % DMDUTIL_FRAME_BUFFER_SIZE], dmdUpdate.get(),
478477
sizeof(Update));
479478
m_updateBufferQueuePosition.store(updateBufferQueuePosition, std::memory_order_release);
480-
m_dmdFrameReady.store(true, std::memory_order_release);
481479

482480
Log(DMDUtil_LogLevel_DEBUG, "Queued Frame: position=%d, mode=%d, depth=%d", updateBufferQueuePosition,
483481
dmdUpdate->mode, dmdUpdate->depth);
@@ -745,18 +743,23 @@ uint16_t DMD::GetNextBufferQueuePosition(uint16_t bufferPosition, const uint16_t
745743
void DMD::DmdFrameThread()
746744
{
747745
char name[DMDUTIL_MAX_NAME_SIZE] = {0};
746+
uint16_t bufferPosition = 0;
748747

749-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
750748
(void)m_stopFlag.load(std::memory_order_acquire);
751749

752750
while (true)
753751
{
754752
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
755-
m_dmdCV.wait(
756-
sl, [&]()
757-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
753+
m_dmdCV.wait(sl,
754+
[&]()
755+
{
756+
return m_stopFlag.load(std::memory_order_relaxed) ||
757+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
758+
});
758759
sl.unlock();
759760

761+
bufferPosition = m_updateBufferQueuePosition.load(std::memory_order_relaxed);
762+
760763
if (strcmp(m_romName, name) != 0)
761764
{
762765
strcpy(name, m_romName);
@@ -767,10 +770,6 @@ void DMD::DmdFrameThread()
767770

768771
std::this_thread::sleep_for(std::chrono::milliseconds(2));
769772

770-
std::unique_lock<std::shared_mutex> ul(m_dmdSharedMutex);
771-
m_dmdFrameReady.store(false, std::memory_order_release);
772-
ul.unlock();
773-
774773
if (m_stopFlag)
775774
{
776775
return;
@@ -790,7 +789,6 @@ void DMD::ZeDMDThread()
790789
uint8_t indexBuffer[256 * 64] = {0};
791790
uint8_t renderBuffer[256 * 64 * 3] = {0};
792791

793-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
794792
(void)m_stopFlag.load(std::memory_order_acquire);
795793

796794
Config* const pConfig = Config::GetInstance();
@@ -799,9 +797,12 @@ void DMD::ZeDMDThread()
799797
while (true)
800798
{
801799
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
802-
m_dmdCV.wait(
803-
sl, [&]()
804-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
800+
m_dmdCV.wait(sl,
801+
[&]()
802+
{
803+
return m_stopFlag.load(std::memory_order_relaxed) ||
804+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
805+
});
805806
sl.unlock();
806807

807808
if (m_stopFlag.load(std::memory_order_acquire))
@@ -933,7 +934,9 @@ void DMD::ZeDMDThread()
933934

934935
void DMD::SerumThread()
935936
{
936-
if (Config::GetInstance()->IsAltColor())
937+
Config* const pConfig = Config::GetInstance();
938+
939+
if (pConfig->IsAltColor())
937940
{
938941
Serum_SetLogCallback(Serum_LogCallback, nullptr);
939942

@@ -945,12 +948,11 @@ void DMD::SerumThread()
945948
Update* lastDmdUpdate = nullptr;
946949
uint8_t flags = 0;
947950

948-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
949951
(void)m_stopFlag.load(std::memory_order_acquire);
950952

951-
Config* const pConfig = Config::GetInstance();
952953
bool showNotColorizedFrames = pConfig->IsShowNotColorizedFrames();
953954
bool dumpNotColorizedFrames = pConfig->IsDumpNotColorizedFrames();
955+
if (pConfig->IsSerumPUPTriggers()) Serum_EnablePupTrigers();
954956

955957
while (true)
956958
{
@@ -979,9 +981,12 @@ void DMD::SerumThread()
979981
if (nextRotation == 0)
980982
{
981983
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
982-
m_dmdCV.wait(
983-
sl, [&]()
984-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
984+
m_dmdCV.wait(sl,
985+
[&]()
986+
{
987+
return m_stopFlag.load(std::memory_order_relaxed) ||
988+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
989+
});
985990
sl.unlock();
986991
}
987992

@@ -1227,7 +1232,6 @@ void DMD::PixelcadeDMDThread()
12271232
uint16_t* rgb565Data = new uint16_t[targetLength];
12281233
memset(rgb565Data, 0, targetLength * sizeof(uint16_t));
12291234

1230-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
12311235
(void)m_stopFlag.load(std::memory_order_acquire);
12321236

12331237
Config* const pConfig = Config::GetInstance();
@@ -1236,9 +1240,12 @@ void DMD::PixelcadeDMDThread()
12361240
while (true)
12371241
{
12381242
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1239-
m_dmdCV.wait(
1240-
sl, [&]()
1241-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
1243+
m_dmdCV.wait(sl,
1244+
[&]()
1245+
{
1246+
return m_stopFlag.load(std::memory_order_relaxed) ||
1247+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
1248+
});
12421249
sl.unlock();
12431250
if (m_stopFlag.load(std::memory_order_acquire))
12441251
{
@@ -1411,15 +1418,17 @@ void DMD::LevelDMDThread()
14111418
uint16_t bufferPosition = 0;
14121419
uint8_t renderBuffer[256 * 64] = {0};
14131420

1414-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
14151421
(void)m_stopFlag.load(std::memory_order_acquire);
14161422

14171423
while (true)
14181424
{
14191425
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1420-
m_dmdCV.wait(
1421-
sl, [&]()
1422-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
1426+
m_dmdCV.wait(sl,
1427+
[&]()
1428+
{
1429+
return m_stopFlag.load(std::memory_order_relaxed) ||
1430+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
1431+
});
14231432
sl.unlock();
14241433
if (m_stopFlag.load(std::memory_order_acquire))
14251434
{
@@ -1461,7 +1470,6 @@ void DMD::RGB24DMDThread()
14611470
uint8_t rgb24Data[256 * 64 * 3] = {0};
14621471
uint8_t rgb24DataScaled[256 * 64 * 3] = {0};
14631472

1464-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
14651473
(void)m_stopFlag.load(std::memory_order_acquire);
14661474

14671475
Config* const pConfig = Config::GetInstance();
@@ -1470,9 +1478,12 @@ void DMD::RGB24DMDThread()
14701478
while (true)
14711479
{
14721480
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1473-
m_dmdCV.wait(
1474-
sl, [&]()
1475-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
1481+
m_dmdCV.wait(sl,
1482+
[&]()
1483+
{
1484+
return m_stopFlag.load(std::memory_order_relaxed) ||
1485+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
1486+
});
14761487
sl.unlock();
14771488
if (m_stopFlag.load(std::memory_order_acquire))
14781489
{
@@ -1622,15 +1633,17 @@ void DMD::ConsoleDMDThread()
16221633
uint16_t bufferPosition = 0;
16231634
uint8_t renderBuffer[256 * 64] = {0};
16241635

1625-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
16261636
(void)m_stopFlag.load(std::memory_order_acquire);
16271637

16281638
while (true)
16291639
{
16301640
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1631-
m_dmdCV.wait(
1632-
sl, [&]()
1633-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
1641+
m_dmdCV.wait(sl,
1642+
[&]()
1643+
{
1644+
return m_stopFlag.load(std::memory_order_relaxed) ||
1645+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
1646+
});
16341647
sl.unlock();
16351648
if (m_stopFlag.load(std::memory_order_acquire))
16361649
{
@@ -1744,7 +1757,6 @@ void DMD::DumpDMDTxtThread()
17441757
FILE* f = nullptr;
17451758
std::unordered_set<uint64_t> seenHashes;
17461759

1747-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
17481760
(void)m_stopFlag.load(std::memory_order_acquire);
17491761

17501762
Config* const pConfig = Config::GetInstance();
@@ -1754,9 +1766,12 @@ void DMD::DumpDMDTxtThread()
17541766
while (true)
17551767
{
17561768
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1757-
m_dmdCV.wait(
1758-
sl, [&]()
1759-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
1769+
m_dmdCV.wait(sl,
1770+
[&]()
1771+
{
1772+
return m_stopFlag.load(std::memory_order_relaxed) ||
1773+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
1774+
});
17601775
sl.unlock();
17611776
if (m_stopFlag.load(std::memory_order_acquire))
17621777
{
@@ -1903,15 +1918,17 @@ void DMD::DumpDMDRawThread()
19031918
std::chrono::steady_clock::time_point start;
19041919
FILE* f = nullptr;
19051920

1906-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
19071921
(void)m_stopFlag.load(std::memory_order_acquire);
19081922

19091923
while (true)
19101924
{
19111925
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1912-
m_dmdCV.wait(
1913-
sl, [&]()
1914-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
1926+
m_dmdCV.wait(sl,
1927+
[&]()
1928+
{
1929+
return m_stopFlag.load(std::memory_order_relaxed) ||
1930+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
1931+
});
19151932
sl.unlock();
19161933
if (m_stopFlag.load(std::memory_order_acquire))
19171934
{
@@ -1978,15 +1995,17 @@ void DMD::PupDMDThread()
19781995
uint8_t palette[192] = {0};
19791996
char name[DMDUTIL_MAX_NAME_SIZE] = {0};
19801997

1981-
(void)m_dmdFrameReady.load(std::memory_order_acquire);
19821998
(void)m_stopFlag.load(std::memory_order_acquire);
19831999

19842000
while (true)
19852001
{
19862002
std::shared_lock<std::shared_mutex> sl(m_dmdSharedMutex);
1987-
m_dmdCV.wait(
1988-
sl, [&]()
1989-
{ return m_dmdFrameReady.load(std::memory_order_relaxed) || m_stopFlag.load(std::memory_order_relaxed); });
2003+
m_dmdCV.wait(sl,
2004+
[&]()
2005+
{
2006+
return m_stopFlag.load(std::memory_order_relaxed) ||
2007+
(m_updateBufferQueuePosition.load(std::memory_order_relaxed) != bufferPosition);
2008+
});
19902009
sl.unlock();
19912010
if (m_stopFlag.load(std::memory_order_acquire))
19922011
{

0 commit comments

Comments
 (0)