Skip to content

Commit

Permalink
Now using UDP staticCallbackFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Dec 22, 2024
1 parent ce1a1af commit 12b10b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
3 changes: 0 additions & 3 deletions lib-showfile/include/showfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ class ShowFile final: public ShowFileFormat {

void Run() {
ShowFileFormat::ShowFileRun(m_Status == showfile::Status::PLAYING);
#if defined (CONFIG_SHOWFILE_ENABLE_OSC)
m_showFileOSC.Run();
#endif
#if !defined(CONFIG_SHOWFILE_DISABLE_TFTP)
if (m_pShowFileTFTP != nullptr) {
m_pShowFileTFTP->Run();
Expand Down
24 changes: 7 additions & 17 deletions lib-showfile/include/showfileosc.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ShowFileOSC {
assert(s_pThis == nullptr);
s_pThis = this;

m_nHandle = Network::Get()->Begin(m_nPortIncoming);
m_nHandle = Network::Get()->Begin(m_nPortIncoming, staticCallbackFunction);
assert(m_nHandle != -1);

DEBUG_EXIT
Expand All @@ -72,28 +72,18 @@ class ShowFileOSC {
}

void Input(const uint8_t *pBuffer, uint32_t nSize, uint32_t nFromIp, uint16_t nFromPort) {
if (pBuffer != nullptr) {
m_pBuffer = pBuffer;
m_nRemoteIp = nFromIp;
m_nBytesReceived = nSize;
m_nRemotePort = nFromPort;
}
assert(pBuffer != nullptr);

m_pBuffer = pBuffer;
m_nRemoteIp = nFromIp;
m_nBytesReceived = nSize;
m_nRemotePort = nFromPort;

if (memcmp(m_pBuffer, showfileosc::CMD_PATH, showfileosc::PATH_LENGTH) == 0) {
Process();
}
}

void Run() {
m_nBytesReceived = Network::Get()->RecvFrom(m_nHandle, reinterpret_cast<const void **>(&m_pBuffer), &m_nRemoteIp, &m_nRemotePort);

if (__builtin_expect((m_nBytesReceived <= showfileosc::PATH_LENGTH), 1)) {
return;
}

Input(nullptr, 0, 0, 0);
}

void Print() {
puts("OSC Server");
printf(" Path : [%s]\n", showfileosc::CMD_PATH);
Expand Down

0 comments on commit 12b10b3

Please sign in to comment.