Limit carrier/idle generation for input with delays

For non-interactive output (writing to an audio file), generate the
idle output carrier for same duration that the input is idle.  Makes
this case generate an output .wav file of just over 1 second duration:

  { echo hello; sleep 1; echo world; } | minimodem --tx -f /tmp/xx.wav 300
This commit is contained in:
Chris Osborn 2016-04-13 12:02:33 -07:00 committed by Kamal Mostafa
parent 84b2406b97
commit 513a11d454
1 changed files with 8 additions and 0 deletions

View File

@ -163,6 +163,14 @@ static void fsk_transmit_stdin(
FD_ZERO(&fdset);
FD_SET(fd, &fdset);
struct timeval tv_idletimeout = { 0, 0 };
if ( !tx_interactive ) {
// When stdin blocks we "emit idle tone", for a duration of
// idle_carrier_usec. If !tx_interactive (i.e. writing to an
// audio file) make the select timeout the same duration.
tv_idletimeout.tv_usec = idle_carrier_usec;
}
if( block_input || select(fd+1, &fdset, NULL, NULL, &tv_idletimeout) )
{
n_read = read(fd, &buf, sizeof(buf));