Zerofill for AudioDeviceUDP
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.
This commit is contained in:
parent
084b8a5e9f
commit
4d2ebbd5ab
|
|
@ -1,4 +1,4 @@
|
||||||
1.6.1 -- ?? ??? 2020
|
1.6.1 -- ?? ??? 2021
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
* ASYNC_AUDIO_ALSA_ZEROFILL is now enabled by default.
|
* ASYNC_AUDIO_ALSA_ZEROFILL is now enabled by default.
|
||||||
|
|
@ -39,6 +39,11 @@
|
||||||
|
|
||||||
* The Async::Serial class now support all extended baudrates.
|
* 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
|
1.6.0 -- 01 Sep 2019
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdlib>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
@ -190,7 +192,7 @@ int AudioDeviceUDP::samplesToWrite(void) const
|
||||||
|
|
||||||
AudioDeviceUDP::AudioDeviceUDP(const string& dev_name)
|
AudioDeviceUDP::AudioDeviceUDP(const string& dev_name)
|
||||||
: AudioDevice(dev_name), block_size(0), sock(0), read_buf(0),
|
: 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(AudioDeviceUDP_creator_registered);
|
||||||
assert(sampleRate() > 0);
|
assert(sampleRate() > 0);
|
||||||
|
|
@ -202,6 +204,12 @@ AudioDeviceUDP::AudioDeviceUDP(const string& dev_name)
|
||||||
pace_timer->setEnable(false);
|
pace_timer->setEnable(false);
|
||||||
pace_timer->expired.connect(
|
pace_timer->expired.connect(
|
||||||
sigc::hide(mem_fun(*this, &AudioDeviceUDP::audioWriteHandler)));
|
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 */
|
} /* AudioDeviceUDP::AudioDeviceUDP */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -347,8 +355,16 @@ void AudioDeviceUDP::audioWriteHandler(void)
|
||||||
frags_read = getBlocks(buf, 1);
|
frags_read = getBlocks(buf, 1);
|
||||||
if (frags_read == 0)
|
if (frags_read == 0)
|
||||||
{
|
{
|
||||||
pace_timer->setEnable(false);
|
if (zerofill_on_underflow)
|
||||||
return;
|
{
|
||||||
|
frags_read = 1;
|
||||||
|
std::memset(buf, 0, block_size * channels);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pace_timer->setEnable(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the samples to the socket
|
// Write the samples to the socket
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,8 @@ class AudioDeviceUDP : public Async::AudioDevice
|
||||||
IpAddress ip_addr;
|
IpAddress ip_addr;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
Async::Timer *pace_timer;
|
Async::Timer *pace_timer;
|
||||||
|
bool zerofill_on_underflow;
|
||||||
|
|
||||||
void audioReadHandler(const Async::IpAddress &ip, uint16_t port,
|
void audioReadHandler(const Async::IpAddress &ip, uint16_t port,
|
||||||
void *buf, int count);
|
void *buf, int count);
|
||||||
void audioWriteHandler(void);
|
void audioWriteHandler(void);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TH DEVCAL 1 "APRIL 2021" Linux "User Manuals"
|
.TH DEVCAL 1 "AUGUST 2021" Linux "User Manuals"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.
|
.
|
||||||
|
|
@ -245,6 +245,9 @@ during devcal startup when using OSS audio.
|
||||||
ASYNC_AUDIO_ALSA_ZEROFILL
|
ASYNC_AUDIO_ALSA_ZEROFILL
|
||||||
Set this environment variable to 0 to stop the Alsa audio code from writing
|
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.
|
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
|
.SH AUTHOR
|
||||||
.
|
.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TH QTEL "1" "APRIL 2021" Linux "User Manuals"
|
.TH QTEL "1" "AUGUST 2021" Linux "User Manuals"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.
|
.
|
||||||
|
|
@ -61,6 +61,9 @@ during qtel startup when using OSS audio.
|
||||||
ASYNC_AUDIO_ALSA_ZEROFILL
|
ASYNC_AUDIO_ALSA_ZEROFILL
|
||||||
Set this environment variable to 0 to stop the Alsa audio code from writing
|
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.
|
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
|
.SH AUTHOR
|
||||||
.
|
.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TH REMOTETRX 1 "APRIL 2021" Linux "User Manuals"
|
.TH REMOTETRX 1 "AUGUST 2021" Linux "User Manuals"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.
|
.
|
||||||
|
|
@ -86,6 +86,9 @@ during remotetrx server startup when using OSS audio.
|
||||||
ASYNC_AUDIO_ALSA_ZEROFILL
|
ASYNC_AUDIO_ALSA_ZEROFILL
|
||||||
Set this environment variable to 0 to stop the Alsa audio code from writing
|
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.
|
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
|
.TP
|
||||||
HOME
|
HOME
|
||||||
Used to find the per user configuration file.
|
Used to find the per user configuration file.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TH SIGLEVDETCAL 1 "APRIL 2021" Linux "User Manuals"
|
.TH SIGLEVDETCAL 1 "AUGUST 2021" Linux "User Manuals"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.
|
.
|
||||||
|
|
@ -60,6 +60,9 @@ when the remotetrx server starts.
|
||||||
ASYNC_AUDIO_ALSA_ZEROFILL
|
ASYNC_AUDIO_ALSA_ZEROFILL
|
||||||
Set this environment variable to 0 to stop the Alsa audio code from writing
|
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.
|
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
|
.SH AUTHOR
|
||||||
.
|
.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TH SVXLINK 1 "APRIL 2021" Linux "User Manuals"
|
.TH SVXLINK 1 "AUGUST 2021" Linux "User Manuals"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.
|
.
|
||||||
|
|
@ -65,6 +65,9 @@ during startup of the SvxLink server when using OSS audio.
|
||||||
ASYNC_AUDIO_ALSA_ZEROFILL
|
ASYNC_AUDIO_ALSA_ZEROFILL
|
||||||
Set this environment variable to 0 to stop the Alsa audio code from writing
|
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.
|
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
|
.TP
|
||||||
HOME
|
HOME
|
||||||
Used to find the per user configuration file.
|
Used to find the per user configuration file.
|
||||||
|
|
|
||||||
|
|
@ -18,3 +18,6 @@ PIDFILE=/run/remotetrx.pid
|
||||||
|
|
||||||
# Disable Alsa zerofill if set to 0 (see manual page)
|
# Disable Alsa zerofill if set to 0 (see manual page)
|
||||||
#ASYNC_AUDIO_ALSA_ZEROFILL=1
|
#ASYNC_AUDIO_ALSA_ZEROFILL=1
|
||||||
|
|
||||||
|
# Enable UDP zerofill if set to 1 (see manual page)
|
||||||
|
#ASYNC_AUDIO_UDP_ZEROFILL=0
|
||||||
|
|
|
||||||
|
|
@ -18,3 +18,6 @@ PIDFILE=/run/svxlink.pid
|
||||||
|
|
||||||
# Disable Alsa zerofill if set to 0 (see manual page)
|
# Disable Alsa zerofill if set to 0 (see manual page)
|
||||||
#ASYNC_AUDIO_ALSA_ZEROFILL=1
|
#ASYNC_AUDIO_ALSA_ZEROFILL=1
|
||||||
|
|
||||||
|
# Enable UDP zerofill if set to 1 (see manual page)
|
||||||
|
#ASYNC_AUDIO_UDP_ZEROFILL=0
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ QTEL=1.2.4.99.5
|
||||||
LIBECHOLIB=1.3.3.99.0
|
LIBECHOLIB=1.3.3.99.0
|
||||||
|
|
||||||
# Version for the Async library
|
# Version for the Async library
|
||||||
LIBASYNC=1.6.99.15
|
LIBASYNC=1.6.99.16
|
||||||
|
|
||||||
# SvxLink versions
|
# SvxLink versions
|
||||||
SVXLINK=1.7.99.52
|
SVXLINK=1.7.99.52
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue