Fixed bug in M17 opmode handler causing missing audio output
This commit is contained in:
parent
c9cd620530
commit
6dd0a718e0
|
|
@ -174,38 +174,45 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
|
||||||
bool newData = demodulator.update();
|
bool newData = demodulator.update();
|
||||||
bool lock = demodulator.isLocked();
|
bool lock = demodulator.isLocked();
|
||||||
|
|
||||||
// Reset frame decoder when transitioning from unlocked to locked state and
|
// Reset frame decoder when transitioning from unlocked to locked state.
|
||||||
// setup audio path towards the speaker.
|
|
||||||
if((lock == true) && (locked == false))
|
if((lock == true) && (locked == false))
|
||||||
{
|
{
|
||||||
decoder.reset();
|
decoder.reset();
|
||||||
rxAudioPath = audioPath_request(SOURCE_MCU, SINK_SPK, PRIO_RX);
|
locked = lock;
|
||||||
codec_startDecode(rxAudioPath);
|
}
|
||||||
|
|
||||||
|
if(locked)
|
||||||
|
{
|
||||||
|
// Check RX audio path status, open it if necessary
|
||||||
|
uint8_t pthSts = audioPath_getStatus(rxAudioPath);
|
||||||
|
if(pthSts == PATH_CLOSED)
|
||||||
|
{
|
||||||
|
rxAudioPath = audioPath_request(SOURCE_MCU, SINK_SPK, PRIO_RX);
|
||||||
|
pthSts = audioPath_getStatus(rxAudioPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start codec2 module if not already up
|
||||||
|
if(codec_running() == false)
|
||||||
|
codec_startDecode(rxAudioPath);
|
||||||
|
|
||||||
|
// Process new data
|
||||||
|
if(newData)
|
||||||
|
{
|
||||||
|
auto& frame = demodulator.getFrame();
|
||||||
|
auto type = decoder.decodeFrame(frame);
|
||||||
|
bool lsfOk = decoder.getLsf().valid();
|
||||||
|
|
||||||
|
if((type == M17FrameType::STREAM) && (lsfOk == true) && (pthSts == PATH_OPEN))
|
||||||
|
{
|
||||||
|
M17StreamFrame sf = decoder.getStreamFrame();
|
||||||
|
codec_pushFrame(sf.payload().data(), false);
|
||||||
|
codec_pushFrame(sf.payload().data() + 8, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locked = lock;
|
locked = lock;
|
||||||
|
|
||||||
if(locked && newData)
|
|
||||||
{
|
|
||||||
auto& frame = demodulator.getFrame();
|
|
||||||
auto type = decoder.decodeFrame(frame);
|
|
||||||
bool lsfOk = decoder.getLsf().valid();
|
|
||||||
uint8_t pthSts = audioPath_getStatus(rxAudioPath);
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
if((type == M17FrameType::STREAM) && (lsfOk == true) &&
|
|
||||||
(pthSts == PATH_OPEN))
|
|
||||||
{
|
|
||||||
M17StreamFrame sf = decoder.getStreamFrame();
|
|
||||||
result = codec_pushFrame(sf.payload().data(), false);
|
|
||||||
result = codec_pushFrame(sf.payload().data() + 8, false);
|
|
||||||
|
|
||||||
// Try restarting audio codec if it went down
|
|
||||||
if(result == -EPERM)
|
|
||||||
codec_startDecode(rxAudioPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(platform_getPttStatus())
|
if(platform_getPttStatus())
|
||||||
{
|
{
|
||||||
demodulator.stopBasebandSampling();
|
demodulator.stopBasebandSampling();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue