new std::map for tmp storage of 2nd half of C2_1600 audio

main
Tom Early 4 years ago
parent 6a927d0eff
commit 2d1d2a9852

@ -142,9 +142,6 @@ void CController::IncrementDStarVocoder()
void CController::ReadReflector() void CController::ReadReflector()
{ {
// local audio storage
static int16_t audio[160];
while (keep_running) { while (keep_running) {
STCPacket tcpack; STCPacket tcpack;
//wait up to 40 ms to read something on the unix port //wait up to 40 ms to read something on the unix port
@ -179,7 +176,7 @@ void CController::ReadReflector()
if (packet->IsSecond()) { if (packet->IsSecond()) {
if (packet->GetCodecIn() == ECodecType::c2_1600) { if (packet->GetCodecIn() == ECodecType::c2_1600) {
//copy the audio from local storage //copy the audio from local storage
memcpy(packet->GetAudio(), audio, 320); memcpy(packet->GetAudio(), audio_store[packet->GetModule()], 320);
} else /* codec_in is ECodecType::c2_3200 */ { } else /* codec_in is ECodecType::c2_3200 */ {
//decode the second 8 data bytes //decode the second 8 data bytes
//move the 160 audio samples to the packet //move the 160 audio samples to the packet
@ -193,8 +190,8 @@ void CController::ReadReflector()
//decode it //decode it
c2_16.codec2_decode(tmp, packet->GetM17Data()); // 8 bytes input produces 320 audio points c2_16.codec2_decode(tmp, packet->GetM17Data()); // 8 bytes input produces 320 audio points
//move the first and second half //move the first and second half
memcpy(packet->GetAudio(), tmp, 160*sizeof(int16_t)); memcpy(packet->GetAudio(), tmp, 320);
memcpy(audio, tmp+160, 160*sizeof(int16_t)); memcpy(audio_store[packet->GetModule()], tmp+160, 320);
} else /* codec_in is ECodecType::c2_3200 */ { } else /* codec_in is ECodecType::c2_3200 */ {
c2_32.codec2_decode(packet->GetAudio(), packet->GetM17Data()); c2_32.codec2_decode(packet->GetAudio(), packet->GetM17Data());
} }

@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <vector> #include <vector>
#include <map>
#include <set> #include <set>
#include <memory> #include <memory>
#include <atomic> #include <atomic>
@ -42,6 +43,7 @@ protected:
std::atomic<bool> keep_running; std::atomic<bool> keep_running;
std::future<void> reflectorThread, ambeThread; std::future<void> reflectorThread, ambeThread;
std::vector<std::shared_ptr<CDV3003>> dmr_device, dstar_device; std::vector<std::shared_ptr<CDV3003>> dmr_device, dstar_device;
std::map<char, int16_t[160]> audio_store;
CUnixDgramReader reader; CUnixDgramReader reader;
CUnixDgramWriter writer; CUnixDgramWriter writer;
CCodec2 c2_16{false}; CCodec2 c2_16{false};

Loading…
Cancel
Save

Powered by TurnKey Linux.