kopia lustrzana https://github.com/OpenRTX/OpenRTX
Improved management of CODEC2 thread in M17 mode handler, now activated only when transmitting. Fixes a confict with RTX and MIC input streams causing the rtx thread to hang when PTT was pressed
rodzic
54a89abcd0
commit
3d169484e9
|
@ -104,6 +104,16 @@ private:
|
|||
*/
|
||||
void sendData(const bool lastFrame = false);
|
||||
|
||||
/**
|
||||
* Start CODEC2 thread.
|
||||
*/
|
||||
void startCodec();
|
||||
|
||||
/**
|
||||
* Stop CODEC2 thread.
|
||||
*/
|
||||
void stopCodec();
|
||||
|
||||
bool enterRx; ///< Flag for RX management.
|
||||
M17::M17Modulator modulator; ///< M17 modulator.
|
||||
M17::M17Demodulator demodulator; ///< M17 demodulator.
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#include <M17/M17Interleaver.h>
|
||||
#include <M17/M17Transmitter.h>
|
||||
|
||||
namespace M17
|
||||
{
|
||||
using namespace M17;
|
||||
|
||||
M17Transmitter::M17Transmitter(M17Modulator& modulator) : modulator(modulator),
|
||||
currentLich(0), frameNumber(0)
|
||||
|
@ -123,5 +122,3 @@ void M17Transmitter::send(const payload_t& payload, const bool isLast)
|
|||
|
||||
modulator.send(STREAM_SYNC_WORD, frame, isLast);
|
||||
}
|
||||
|
||||
} /* M17 */
|
||||
|
|
|
@ -108,22 +108,14 @@ OpMode_M17::OpMode_M17() : enterRx(true), m17Tx(modulator)
|
|||
|
||||
OpMode_M17::~OpMode_M17()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OpMode_M17::enable()
|
||||
{
|
||||
// Start CODEC2 thread
|
||||
runCodec = true;
|
||||
newData = false;
|
||||
|
||||
pthread_mutex_init(&codecMtx, NULL);
|
||||
pthread_cond_init(&codecCv, NULL);
|
||||
|
||||
pthread_attr_t codecAttr;
|
||||
pthread_attr_init(&codecAttr);
|
||||
pthread_attr_setstacksize(&codecAttr, 16384);
|
||||
pthread_create(&codecThread, &codecAttr, threadFunc, NULL);
|
||||
|
||||
modulator.init();
|
||||
demodulator.init();
|
||||
enterRx = true;
|
||||
|
@ -131,9 +123,7 @@ void OpMode_M17::enable()
|
|||
|
||||
void OpMode_M17::disable()
|
||||
{
|
||||
// Shut down CODEC2 thread and wait until it effectively stops
|
||||
runCodec = false;
|
||||
pthread_join(codecThread, NULL);
|
||||
stopCodec();
|
||||
pthread_mutex_destroy(&codecMtx);
|
||||
pthread_cond_destroy(&codecCv);
|
||||
|
||||
|
@ -174,6 +164,7 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
|
|||
|
||||
audio_enableMic();
|
||||
radio_enableTx();
|
||||
startCodec();
|
||||
|
||||
std::string source_address(status->source_address);
|
||||
std::string destination_address(status->destination_address);
|
||||
|
@ -196,6 +187,7 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
|
|||
|
||||
audio_disableMic();
|
||||
radio_disableRtx();
|
||||
stopCodec();
|
||||
|
||||
status->opStatus = OFF;
|
||||
enterRx = true;
|
||||
|
@ -236,3 +228,21 @@ void OpMode_M17::sendData(bool lastFrame)
|
|||
std::copy(encodedData.begin(), encodedData.end(), dataFrame.begin());
|
||||
m17Tx.send(dataFrame, lastFrame);
|
||||
}
|
||||
|
||||
void OpMode_M17::startCodec()
|
||||
{
|
||||
runCodec = true;
|
||||
newData = false;
|
||||
|
||||
pthread_attr_t codecAttr;
|
||||
pthread_attr_init(&codecAttr);
|
||||
pthread_attr_setstacksize(&codecAttr, 16384);
|
||||
pthread_create(&codecThread, &codecAttr, threadFunc, NULL);
|
||||
}
|
||||
|
||||
void OpMode_M17::stopCodec()
|
||||
{
|
||||
// Shut down CODEC2 thread and wait until it effectively stops
|
||||
runCodec = false;
|
||||
pthread_join(codecThread, NULL);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue