Adapt code to the new audio stream API.

pull/180/head
Silvano Seva 2023-05-06 21:41:42 +02:00
rodzic 24208db609
commit 7d90d15a5f
3 zmienionych plików z 21 dodań i 26 usunięć

Wyświetl plik

@ -120,9 +120,8 @@ bool codec_startEncode(const pathId path)
running = true; running = true;
pathInfo_t pathInfo = audioPath_getInfo(path); audioStream = audioStream_start(path, audioBuf, 320, 8000,
audioStream = inputStream_start(pathInfo.source, pathInfo.prio, audioBuf, STREAM_INPUT | BUF_CIRC_DOUBLE);
320, BUF_CIRC_DOUBLE, 8000);
if(audioStream < 0) if(audioStream < 0)
{ {
@ -154,9 +153,8 @@ bool codec_startDecode(const pathId path)
running = true; running = true;
memset(audioBuf, 0x00, 320 * sizeof(stream_sample_t)); memset(audioBuf, 0x00, 320 * sizeof(stream_sample_t));
pathInfo_t pathInfo = audioPath_getInfo(path); audioStream = audioStream_start(path, audioBuf, 320, 8000,
audioStream = outputStream_start(pathInfo.sink, pathInfo.prio, audioBuf, STREAM_OUTPUT | BUF_CIRC_DOUBLE);
320, BUF_CIRC_DOUBLE, 8000);
if(audioStream == -1) if(audioStream == -1)
{ {
@ -299,7 +297,7 @@ static void *encodeFunc(void *arg)
} }
} }
inputStream_stop(audioStream); audioStream_terminate(audioStream);
codec2_destroy(codec2); codec2_destroy(codec2);
return NULL; return NULL;
@ -357,8 +355,7 @@ static void *decodeFunc(void *arg)
} }
// Stop stream and wait until its effective termination // Stop stream and wait until its effective termination
outputStream_stop(audioStream); audioStream_stop(audioStream);
outputStream_sync(audioStream, false);
codec2_destroy(codec2); codec2_destroy(codec2);
return NULL; return NULL;

Wyświetl plik

@ -190,7 +190,7 @@ void M17Demodulator::terminate()
{ {
// Ensure proper termination of baseband sampling // Ensure proper termination of baseband sampling
audioPath_release(basebandPath); audioPath_release(basebandPath);
inputStream_stop(basebandId); audioStream_terminate(basebandId);
// Delete the buffers and deallocate memory. // Delete the buffers and deallocate memory.
baseband_buffer.reset(); baseband_buffer.reset();
@ -205,11 +205,10 @@ void M17Demodulator::terminate()
void M17Demodulator::startBasebandSampling() void M17Demodulator::startBasebandSampling()
{ {
basebandPath = audioPath_request(SOURCE_RTX, SINK_MCU, PRIO_RX); basebandPath = audioPath_request(SOURCE_RTX, SINK_MCU, PRIO_RX);
basebandId = inputStream_start(SOURCE_RTX, PRIO_RX, basebandId = audioStream_start(basebandPath, baseband_buffer.get(),
baseband_buffer.get(), 2 * M17_SAMPLE_BUF_SIZE, M17_RX_SAMPLE_RATE,
2 * M17_SAMPLE_BUF_SIZE, STREAM_INPUT | BUF_CIRC_DOUBLE);
BUF_CIRC_DOUBLE,
M17_RX_SAMPLE_RATE);
// Clean start of the demodulation statistics // Clean start of the demodulation statistics
resetCorrelationStats(); resetCorrelationStats();
resetQuantizationStats(); resetQuantizationStats();
@ -219,7 +218,7 @@ void M17Demodulator::startBasebandSampling()
void M17Demodulator::stopBasebandSampling() void M17Demodulator::stopBasebandSampling()
{ {
inputStream_stop(basebandId); audioStream_terminate(basebandId);
audioPath_release(basebandPath); audioPath_release(basebandPath);
phase = 0; phase = 0;
syncDetected = false; syncDetected = false;

Wyświetl plik

@ -63,7 +63,7 @@ void M17Modulator::terminate()
// Terminate an ongoing stream, if present // Terminate an ongoing stream, if present
if(txRunning) if(txRunning)
{ {
outputStream_terminate(outStream); audioStream_terminate(outStream);
txRunning = false; txRunning = false;
} }
@ -97,9 +97,9 @@ void M17Modulator::start()
return; return;
} }
outStream = outputStream_start(SINK_RTX, PRIO_TX, baseband_buffer.get(), outStream = audioStream_start(outPath, baseband_buffer.get(),
2*M17_FRAME_SAMPLES, BUF_CIRC_DOUBLE, 2*M17_FRAME_SAMPLES, M17_TX_SAMPLE_RATE,
M17_TX_SAMPLE_RATE); STREAM_OUTPUT | BUF_CIRC_DOUBLE);
idleBuffer = outputStream_getIdleBuffer(outStream); idleBuffer = outputStream_getIdleBuffer(outStream);
#else #else
sendBaseband(); sendBaseband();
@ -130,8 +130,7 @@ void M17Modulator::stop()
if(txRunning == false) if(txRunning == false)
return; return;
outputStream_stop(outStream); audioStream_stop(outStream);
outputStream_sync(outStream, false);
txRunning = false; txRunning = false;
idleBuffer = baseband_buffer.get(); idleBuffer = baseband_buffer.get();
audioPath_release(outPath); audioPath_release(outPath);