no concurrent audio threads

dev
Tom Early 2 years ago
parent 47eea6f4fb
commit 17edc30141

@ -841,14 +841,7 @@ void CQnetDVAP::ReadDVAPThread()
if (MODULE_ACKNOWLEDGE && !busy20000) if (MODULE_ACKNOWLEDGE && !busy20000)
{ {
memcpy(dvap_ack_arg.mycall, mycall, 8); memcpy(dvap_ack_arg.mycall, mycall, 8);
try RptrAckThread(&dvap_ack_arg);
{
m_fqueue.emplace(std::async(std::launch::async, &CQnetDVAP::RptrAckThread, this, &dvap_ack_arg));
}
catch (const std::exception &e)
{
printf("Failed to start RptrAckThread(). Exception: %s\n", e.what());
}
} }
} }
} }
@ -957,22 +950,6 @@ void CQnetDVAP::Run()
ackpoint.start(); ackpoint.start();
} }
ReadFromGateway(); ReadFromGateway();
if (! m_fqueue.empty())
{
if (m_fqueue.front().valid())
{
if (std::future_status::ready == m_fqueue.front().wait_for(std::chrono::seconds(0)))
{
m_fqueue.front().get();
m_fqueue.pop();
}
}
else
{
m_fqueue.pop();
}
}
} }
} }

@ -19,7 +19,6 @@
*/ */
#include <future> #include <future>
#include <queue>
#include "UnixDgramSocket.h" #include "UnixDgramSocket.h"
#include "Base.h" #include "Base.h"
@ -53,7 +52,6 @@ private:
CRandom Random; CRandom Random;
// data // data
std::queue<std::future<void>> m_fqueue;
std::future<void> m_readThread; std::future<void> m_readThread;
// unix sockets // unix sockets

@ -612,17 +612,7 @@ void CQnetGateway::ProcessTimeouts()
// printf("Closed echotest audio file:[%s]\n", recd[i].file); // printf("Closed echotest audio file:[%s]\n", recd[i].file);
/* START: echotest thread setup */ /* START: echotest thread setup */
try PlayFileThread(recd[i]);
{
m_fqueue.emplace(std::async(std::launch::async, &CQnetGateway::PlayFileThread, this, std::ref(recd[i])));
}
catch (const std::exception &e)
{
printf("Failed to start echotest thread. Exception: %s\n", e.what());
// when the echotest thread runs, it deletes the file,
// Because the echotest thread did NOT start, we delete the file here
unlink(recd[i].file);
}
/* END: echotest thread setup */ /* END: echotest thread setup */
} }
} }
@ -1678,14 +1668,7 @@ void CQnetGateway::ProcessModem(const ssize_t recvlen, SDSVT &dsvt)
band_txt[i].last_time = 0; band_txt[i].last_time = 0;
band_txt[i].streamID = 0U; // prevent vm timeout band_txt[i].streamID = 0U; // prevent vm timeout
snprintf(vm[i].message, 21, "VOICEMAIL ON MOD %c ", 'A'+i); snprintf(vm[i].message, 21, "VOICEMAIL ON MOD %c ", 'A'+i);
try PlayFileThread(vm[i]);
{
m_fqueue.emplace(std::async(std::launch::async, &CQnetGateway::PlayFileThread, this, std::ref(vm[i])));
}
catch (const std::exception &e)
{
printf("Failed to start voicemail playback. Exception: %s\n", e.what());
}
} }
else else
printf("No voicemail to recall or still recording\n"); printf("No voicemail to recall or still recording\n");
@ -1970,17 +1953,7 @@ void CQnetGateway::ProcessModem(const ssize_t recvlen, SDSVT &dsvt)
// printf("Closed echotest audio file:[%s]\n", recd[i].file); // printf("Closed echotest audio file:[%s]\n", recd[i].file);
/* we are in echotest mode, so play it back */ /* we are in echotest mode, so play it back */
try PlayFileThread(recd[i]);
{
m_fqueue.emplace(std::async(std::launch::async, &CQnetGateway::PlayFileThread, this, std::ref(recd[i])));
}
catch (const std::exception &e)
{
printf("failed to start PlayFileThread. Exception: %s\n", e.what());
// When the echotest thread runs, it deletes the file,
// Because the echotest thread did NOT start, we delete the file here
unlink(recd[i].file);
}
} }
break; break;
} }
@ -2076,22 +2049,6 @@ void CQnetGateway::Run()
while (keep_running) while (keep_running)
{ {
if (! m_fqueue.empty())
{
if (m_fqueue.front().valid())
{
if (std::future_status::ready == m_fqueue.front().wait_for(std::chrono::seconds(0)))
{
m_fqueue.front().get();
m_fqueue.pop();
}
}
else
{
m_fqueue.pop();
}
}
ProcessTimeouts(); ProcessTimeouts();
// wait 20 ms max // wait 20 ms max

@ -19,7 +19,6 @@
#include <set> #include <set>
#include <regex> #include <regex>
#include <future> #include <future>
#include <queue>
#include "IRCDDB.h" #include "IRCDDB.h"
#include "QnetTypeDefs.h" #include "QnetTypeDefs.h"
@ -101,7 +100,6 @@ public:
void Close(); void Close();
private: private:
std::queue<std::future<void>> m_fqueue;
// link type // link type
int link_family[3] = { AF_UNSPEC, AF_UNSPEC, AF_UNSPEC }; int link_family[3] = { AF_UNSPEC, AF_UNSPEC, AF_UNSPEC };
// network type // network type

@ -348,14 +348,7 @@ void CQnetLink::rptr_ack(int i)
{ {
memcpy(mod_and_RADIO_ID[i] + 1, "NOT LINKED", 10); memcpy(mod_and_RADIO_ID[i] + 1, "NOT LINKED", 10);
} }
try RptrAckThread(mod_and_RADIO_ID[i]);
{
m_fqueue.emplace(std::async(std::launch::async, &CQnetLink::RptrAckThread, this, mod_and_RADIO_ID[i]));
}
catch (const std::exception &e)
{
printf("Failed to start RptrAckThread(). Exception: %s\n", e.what());
}
return; return;
} }
@ -2743,23 +2736,6 @@ void CQnetLink::Run()
while (keep_running) while (keep_running)
{ {
if (! m_fqueue.empty())
{
auto &fut = m_fqueue.front();
if (fut.valid())
{
if (std::future_status::ready == fut.wait_for(std::chrono::seconds(0)))
{
fut.get();
m_fqueue.pop();
}
}
else
{
m_fqueue.pop();
}
}
static bool loadG[3] = { false, false, false }; static bool loadG[3] = { false, false, false };
time(&tnow); time(&tnow);
if (keep_running && (tnow - heartbeat) > 0) if (keep_running && (tnow - heartbeat) > 0)
@ -3485,14 +3461,7 @@ void CQnetLink::PlayAudioNotifyThread(char *msg)
memcpy(edata.header.hdr.sfx, "RPTR", 4); memcpy(edata.header.hdr.sfx, "RPTR", 4);
calcPFCS(edata.header.title, 56); calcPFCS(edata.header.title, 56);
try AudioNotifyThread(edata);
{
m_fqueue.emplace(std::async(std::launch::async, &CQnetLink::AudioNotifyThread, this, std::ref(edata)));
}
catch (const std::exception &e)
{
printf ("Failed to start AudioNotifyThread(). Exception: %s\n", e.what());
}
return; return;
} }

@ -23,7 +23,6 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include <set> #include <set>
#include <queue>
#include <future> #include <future>
#include <netinet/in.h> #include <netinet/in.h>
@ -124,8 +123,6 @@ private:
int rf_inactivity_timer[3]; int rf_inactivity_timer[3];
const unsigned char REF_ACK[3] = { 3, 96, 0 }; const unsigned char REF_ACK[3] = { 3, 96, 0 };
std::queue<std::future<void>> m_fqueue;
// the Key in this inbound_list map is the unique IP address of the remote // the Key in this inbound_list map is the unique IP address of the remote
std::map<std::string, SINBOUND *> inbound_list; std::map<std::string, SINBOUND *> inbound_list;

Loading…
Cancel
Save

Powered by TurnKey Linux.