mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-03 06:24:49 -04:00
initial audio sink file and thread handling rough-in
This commit is contained in:
@@ -106,6 +106,7 @@ DemodulatorInstance::~DemodulatorInstance() {
|
||||
delete demodulatorPreThread;
|
||||
delete demodulatorThread;
|
||||
delete audioThread;
|
||||
delete audioSinkThread;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -181,6 +182,10 @@ void DemodulatorInstance::terminate() {
|
||||
// std::cout << "Terminating demodulator preprocessor thread.." << std::endl;
|
||||
demodulatorPreThread->terminate();
|
||||
|
||||
if (audioSinkThread != nullptr) {
|
||||
audioSinkThread->terminate();
|
||||
}
|
||||
|
||||
//that will actually unblock the currently blocked push().
|
||||
pipeIQInputData->flush();
|
||||
pipeAudioData->flush();
|
||||
@@ -204,6 +209,7 @@ bool DemodulatorInstance::isTerminated() {
|
||||
bool audioTerminated = audioThread->isTerminated();
|
||||
bool demodTerminated = demodulatorThread->isTerminated();
|
||||
bool preDemodTerminated = demodulatorPreThread->isTerminated();
|
||||
bool audioSinkTerminated = (audioSinkThread == nullptr) || audioSinkThread->isTerminated();
|
||||
|
||||
//Cleanup the worker threads, if the threads are indeed terminated.
|
||||
// threads are linked as t_PreDemod ==> t_Demod ==> t_Audio
|
||||
@@ -240,14 +246,27 @@ bool DemodulatorInstance::isTerminated() {
|
||||
if (audioTerminated) {
|
||||
|
||||
if (t_Audio) {
|
||||
#ifdef __APPLE__
|
||||
pthread_join(t_PreDemod, NULL);
|
||||
#else
|
||||
t_Audio->join();
|
||||
|
||||
delete t_Audio;
|
||||
#endif
|
||||
t_Audio = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool terminated = audioTerminated && demodTerminated && preDemodTerminated;
|
||||
if (audioSinkTerminated) {
|
||||
|
||||
if (t_AudioSink != nullptr) {
|
||||
t_AudioSink->join();
|
||||
|
||||
delete t_AudioSink;
|
||||
t_AudioSink = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool terminated = audioTerminated && demodTerminated && preDemodTerminated && audioSinkTerminated;
|
||||
|
||||
return terminated;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ModemDigital.h"
|
||||
#include "ModemAnalog.h"
|
||||
#include "AudioThread.h"
|
||||
#include "AudioSinkThread.h"
|
||||
|
||||
#if ENABLE_DIGITAL_LAB
|
||||
#include "DigitalConsole.h"
|
||||
@@ -139,6 +140,10 @@ private:
|
||||
DemodulatorThread *demodulatorThread;
|
||||
DemodulatorThreadControlCommandQueuePtr threadQueueControl;
|
||||
|
||||
AudioSinkThread *audioSinkThread = nullptr;
|
||||
std::thread *t_AudioSink = nullptr;
|
||||
AudioThreadInputQueuePtr audioSinkInputQueue;
|
||||
|
||||
//protects child thread creation and termination
|
||||
std::recursive_mutex m_thread_control_mutex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user