Skip to content

Commit

Permalink
Write as much as we can get away with to the input pipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Sep 3, 2024
1 parent 563526a commit d6f0fd3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/pipeline/ExternVocoderStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,13 @@ void ExternVocoderStep::threadEntry_()
while (!isExiting_ && !stdoutRead->eof && !stderrRead->eof)
{
// Write data to STDIN if available
if (codec2_fifo_used(inputSampleFifo_) >= NUM_SAMPLES_TO_READ_WRITE)
int used = codec2_fifo_used(inputSampleFifo_);
if (used > 0)
{
short val[NUM_SAMPLES_TO_READ_WRITE];
codec2_fifo_read(inputSampleFifo_, val, NUM_SAMPLES_TO_READ_WRITE);
WriteFile(receiveStdinHandle_, val, BYTES_TO_READ_WRITE, NULL, NULL);
used = std::min(used, 2048); // 4K max buffer size
short val[used];
codec2_fifo_read(inputSampleFifo_, val, used);
WriteFile(receiveStdinHandle_, val, used * sizeof(short), NULL, NULL);
}
else
{
Expand Down

0 comments on commit d6f0fd3

Please sign in to comment.