kopia lustrzana https://github.com/OpenRTX/OpenRTX
Adapted voice prompt and M17 code to new codec2 API
rodzic
94fdd1090b
commit
dd118d0a87
|
@ -32,6 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <beeps.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const uint32_t VOICE_PROMPTS_DATA_MAGIC = 0x5056; //'VP'
|
||||
static const uint32_t VOICE_PROMPTS_DATA_VERSION = 0x1000; // v1000 OpenRTX
|
||||
|
@ -404,8 +405,8 @@ void vp_terminate()
|
|||
void vp_stop()
|
||||
{
|
||||
voicePromptActive = false;
|
||||
codec_stop(vpAudioPath);
|
||||
disableSpkOutput();
|
||||
codec_stop();
|
||||
|
||||
// Clear voice prompt sequence data
|
||||
vpCurrentSequence.pos = 0;
|
||||
|
@ -614,7 +615,7 @@ void vp_tick()
|
|||
if(audioPath_getStatus(vpAudioPath) != PATH_OPEN)
|
||||
return;
|
||||
|
||||
if (codec_pushFrame(c2Frame, false) == false)
|
||||
if(codec_pushFrame(c2Frame, false) < 0)
|
||||
return;
|
||||
|
||||
vpCurrentSequence.c2DataIndex += 8;
|
||||
|
@ -632,8 +633,8 @@ void vp_tick()
|
|||
vpCurrentSequence.pos = 0;
|
||||
vpCurrentSequence.c2DataIndex = 0;
|
||||
vpCurrentSequence.c2DataLength = 0;
|
||||
codec_stop(vpAudioPath);
|
||||
disableSpkOutput();
|
||||
codec_stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <interfaces/radio.h>
|
||||
#include <OpMode_M17.hpp>
|
||||
#include <audio_codec.h>
|
||||
#include <errno.h>
|
||||
#include <rtx.h>
|
||||
|
||||
#ifdef PLATFORM_MOD17
|
||||
|
@ -141,9 +142,10 @@ void OpMode_M17::offState(rtxStatus_t *const status)
|
|||
{
|
||||
radio_disableRtx();
|
||||
|
||||
codec_stop(rxAudioPath);
|
||||
codec_stop(txAudioPath);
|
||||
audioPath_release(rxAudioPath);
|
||||
audioPath_release(txAudioPath);
|
||||
codec_stop();
|
||||
|
||||
if(startRx)
|
||||
{
|
||||
|
@ -164,9 +166,6 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
|
|||
demodulator.startBasebandSampling();
|
||||
demodulator.invertPhase(invertRxPhase);
|
||||
|
||||
rxAudioPath = audioPath_request(SOURCE_MCU, SINK_SPK, PRIO_RX);
|
||||
codec_startDecode(rxAudioPath);
|
||||
|
||||
radio_enableRx();
|
||||
|
||||
startRx = false;
|
||||
|
@ -175,10 +174,13 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
|
|||
bool newData = demodulator.update();
|
||||
bool lock = demodulator.isLocked();
|
||||
|
||||
// Reset frame decoder when transitioning from unlocked to locked state
|
||||
// Reset frame decoder when transitioning from unlocked to locked state and
|
||||
// setup audio path towards the speaker.
|
||||
if((lock == true) && (locked == false))
|
||||
{
|
||||
decoder.reset();
|
||||
rxAudioPath = audioPath_request(SOURCE_MCU, SINK_SPK, PRIO_RX);
|
||||
codec_startDecode(rxAudioPath);
|
||||
}
|
||||
|
||||
locked = lock;
|
||||
|
@ -189,13 +191,18 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
|
|||
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();
|
||||
codec_pushFrame(sf.payload().data(), false);
|
||||
codec_pushFrame(sf.payload().data() + 8, false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue