diff --git a/src/async/ChangeLog b/src/async/ChangeLog index a60c44eb..9c114106 100644 --- a/src/async/ChangeLog +++ b/src/async/ChangeLog @@ -1,4 +1,4 @@ - 1.6.1 -- ?? ??? 2020 + 1.6.1 -- ?? ??? 2021 ---------------------- * ASYNC_AUDIO_ALSA_ZEROFILL is now enabled by default. @@ -39,6 +39,11 @@ * The Async::Serial class now support all extended baudrates. +* AudioDeviceUDP can now write zeros to the UDP connection on underflow. That + is, when the "audio device" is open but there is no audio to write zeros + will be written instead. Enable this behavior by setting the environment + variable ASYNC_AUDIO_UDP_ZEROFILL=1. + 1.6.0 -- 01 Sep 2019 diff --git a/src/async/audio/AsyncAudioDeviceUDP.cpp b/src/async/audio/AsyncAudioDeviceUDP.cpp index 133e8a19..14a1f8c9 100644 --- a/src/async/audio/AsyncAudioDeviceUDP.cpp +++ b/src/async/audio/AsyncAudioDeviceUDP.cpp @@ -40,6 +40,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include +#include +#include #include #include @@ -190,7 +192,7 @@ int AudioDeviceUDP::samplesToWrite(void) const AudioDeviceUDP::AudioDeviceUDP(const string& dev_name) : AudioDevice(dev_name), block_size(0), sock(0), read_buf(0), - read_buf_pos(0), port(0) + read_buf_pos(0), port(0), zerofill_on_underflow(false) { assert(AudioDeviceUDP_creator_registered); assert(sampleRate() > 0); @@ -202,6 +204,12 @@ AudioDeviceUDP::AudioDeviceUDP(const string& dev_name) pace_timer->setEnable(false); pace_timer->expired.connect( sigc::hide(mem_fun(*this, &AudioDeviceUDP::audioWriteHandler))); + + char *zerofill_str = std::getenv("ASYNC_AUDIO_UDP_ZEROFILL"); + if (zerofill_str != 0) + { + std::istringstream(zerofill_str) >> zerofill_on_underflow; + } } /* AudioDeviceUDP::AudioDeviceUDP */ @@ -347,8 +355,16 @@ void AudioDeviceUDP::audioWriteHandler(void) frags_read = getBlocks(buf, 1); if (frags_read == 0) { - pace_timer->setEnable(false); - return; + if (zerofill_on_underflow) + { + frags_read = 1; + std::memset(buf, 0, block_size * channels); + } + else + { + pace_timer->setEnable(false); + return; + } } // Write the samples to the socket diff --git a/src/async/audio/AsyncAudioDeviceUDP.h b/src/async/audio/AsyncAudioDeviceUDP.h index a552f859..2d58af17 100644 --- a/src/async/audio/AsyncAudioDeviceUDP.h +++ b/src/async/audio/AsyncAudioDeviceUDP.h @@ -199,7 +199,8 @@ class AudioDeviceUDP : public Async::AudioDevice IpAddress ip_addr; uint16_t port; Async::Timer *pace_timer; - + bool zerofill_on_underflow; + void audioReadHandler(const Async::IpAddress &ip, uint16_t port, void *buf, int count); void audioWriteHandler(void); diff --git a/src/doc/man/devcal.1 b/src/doc/man/devcal.1 index 696a3625..6d9c35aa 100644 --- a/src/doc/man/devcal.1 +++ b/src/doc/man/devcal.1 @@ -1,4 +1,4 @@ -.TH DEVCAL 1 "APRIL 2021" Linux "User Manuals" +.TH DEVCAL 1 "AUGUST 2021" Linux "User Manuals" . .SH NAME . @@ -245,6 +245,9 @@ during devcal startup when using OSS audio. ASYNC_AUDIO_ALSA_ZEROFILL Set this environment variable to 0 to stop the Alsa audio code from writing zeros to the audio device when there is no audio to write available. +ASYNC_AUDIO_UDP_ZEROFILL +Set this environment variable to 1 to enable the UDP audio code to write zeros +to the UDP connection when there is no audio to write available. . .SH AUTHOR . diff --git a/src/doc/man/qtel.1 b/src/doc/man/qtel.1 index 3e07744d..6222d2b4 100644 --- a/src/doc/man/qtel.1 +++ b/src/doc/man/qtel.1 @@ -1,4 +1,4 @@ -.TH QTEL "1" "APRIL 2021" Linux "User Manuals" +.TH QTEL "1" "AUGUST 2021" Linux "User Manuals" . .SH NAME . @@ -61,6 +61,9 @@ during qtel startup when using OSS audio. ASYNC_AUDIO_ALSA_ZEROFILL Set this environment variable to 0 to stop the Alsa audio code from writing zeros to the audio device when there is no audio to write available. +ASYNC_AUDIO_UDP_ZEROFILL +Set this environment variable to 1 to enable the UDP audio code to write zeros +to the UDP connection when there is no audio to write available. . .SH AUTHOR . diff --git a/src/doc/man/remotetrx.1 b/src/doc/man/remotetrx.1 index 6cc18a41..b2bf4100 100644 --- a/src/doc/man/remotetrx.1 +++ b/src/doc/man/remotetrx.1 @@ -1,4 +1,4 @@ -.TH REMOTETRX 1 "APRIL 2021" Linux "User Manuals" +.TH REMOTETRX 1 "AUGUST 2021" Linux "User Manuals" . .SH NAME . @@ -86,6 +86,9 @@ during remotetrx server startup when using OSS audio. ASYNC_AUDIO_ALSA_ZEROFILL Set this environment variable to 0 to stop the Alsa audio code from writing zeros to the audio device when there is no audio to write available. +ASYNC_AUDIO_UDP_ZEROFILL +Set this environment variable to 1 to enable the UDP audio code to write zeros +to the UDP connection when there is no audio to write available. .TP HOME Used to find the per user configuration file. diff --git a/src/doc/man/siglevdetcal.1 b/src/doc/man/siglevdetcal.1 index 541e15f1..935901b8 100644 --- a/src/doc/man/siglevdetcal.1 +++ b/src/doc/man/siglevdetcal.1 @@ -1,4 +1,4 @@ -.TH SIGLEVDETCAL 1 "APRIL 2021" Linux "User Manuals" +.TH SIGLEVDETCAL 1 "AUGUST 2021" Linux "User Manuals" . .SH NAME . @@ -60,6 +60,9 @@ when the remotetrx server starts. ASYNC_AUDIO_ALSA_ZEROFILL Set this environment variable to 0 to stop the Alsa audio code from writing zeros to the audio device when there is no audio to write available. +ASYNC_AUDIO_UDP_ZEROFILL +Set this environment variable to 1 to enable the UDP audio code to write zeros +to the UDP connection when there is no audio to write available. . .SH AUTHOR . diff --git a/src/doc/man/svxlink.1 b/src/doc/man/svxlink.1 index f12d555d..a743a95e 100644 --- a/src/doc/man/svxlink.1 +++ b/src/doc/man/svxlink.1 @@ -1,4 +1,4 @@ -.TH SVXLINK 1 "APRIL 2021" Linux "User Manuals" +.TH SVXLINK 1 "AUGUST 2021" Linux "User Manuals" . .SH NAME . @@ -65,6 +65,9 @@ during startup of the SvxLink server when using OSS audio. ASYNC_AUDIO_ALSA_ZEROFILL Set this environment variable to 0 to stop the Alsa audio code from writing zeros to the audio device when there is no audio to write available. +ASYNC_AUDIO_UDP_ZEROFILL +Set this environment variable to 1 to enable the UDP audio code to write zeros +to the UDP connection when there is no audio to write available. .TP HOME Used to find the per user configuration file. diff --git a/src/svxlink/systemd/remotetrx.default.in b/src/svxlink/systemd/remotetrx.default.in index 4717dbcd..01125a0c 100644 --- a/src/svxlink/systemd/remotetrx.default.in +++ b/src/svxlink/systemd/remotetrx.default.in @@ -18,3 +18,6 @@ PIDFILE=/run/remotetrx.pid # Disable Alsa zerofill if set to 0 (see manual page) #ASYNC_AUDIO_ALSA_ZEROFILL=1 + +# Enable UDP zerofill if set to 1 (see manual page) +#ASYNC_AUDIO_UDP_ZEROFILL=0 diff --git a/src/svxlink/systemd/svxlink.default.in b/src/svxlink/systemd/svxlink.default.in index 2bab1cb1..692d7a99 100644 --- a/src/svxlink/systemd/svxlink.default.in +++ b/src/svxlink/systemd/svxlink.default.in @@ -18,3 +18,6 @@ PIDFILE=/run/svxlink.pid # Disable Alsa zerofill if set to 0 (see manual page) #ASYNC_AUDIO_ALSA_ZEROFILL=1 + +# Enable UDP zerofill if set to 1 (see manual page) +#ASYNC_AUDIO_UDP_ZEROFILL=0 diff --git a/src/versions b/src/versions index 5056a079..d8e04d74 100644 --- a/src/versions +++ b/src/versions @@ -8,7 +8,7 @@ QTEL=1.2.4.99.5 LIBECHOLIB=1.3.3.99.0 # Version for the Async library -LIBASYNC=1.6.99.15 +LIBASYNC=1.6.99.16 # SvxLink versions SVXLINK=1.7.99.52