mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 13:40:21 +00:00
Added --param low-latency-audio
Currently modifies these values these values: * audio pbuf delay - 32 ms -> 5 ms * ALSA playback - minimal value * ALSA audio buffer (internal in UG module) - 20 ms -> 5 ms * audio mixer, internal audio buffer - 50 ms -> 5 ms
This commit is contained in:
@@ -668,6 +668,10 @@ static void *audio_receiver_thread(void *arg)
|
||||
}
|
||||
struct audio_decoder *dec_state;
|
||||
dec_state = (struct audio_decoder *) calloc(1, sizeof(struct audio_decoder));
|
||||
|
||||
if (get_commandline_param("low-latency-audio")) {
|
||||
pbuf_set_playout_delay(cp->playout_buffer, 0.005);
|
||||
}
|
||||
assert(dec_state != NULL);
|
||||
cp->decoder_state = dec_state;
|
||||
dec_state->enabled = true;
|
||||
|
||||
@@ -449,8 +449,18 @@ static int audio_play_alsa_reconfigure(void *state, struct audio_desc desc)
|
||||
maxval = atoi(maxval_str);
|
||||
}
|
||||
|
||||
rc = snd_pcm_hw_params_set_buffer_time_minmax(s->handle, params, &minval, &mindir,
|
||||
&maxval, &maxdir);
|
||||
if (get_commandline_param("low-latency-audio")) {
|
||||
unsigned int val;
|
||||
int dir;
|
||||
rc = snd_pcm_hw_params_set_buffer_time_first(s->handle, params,
|
||||
&val, &dir);
|
||||
if (rc == 0) {
|
||||
log_msg(LOG_LEVEL_INFO, "[ALSA play.] Buffer len set to: %c%u\n", dir < 0 ? '-' : dir == 0 ? '=' : '+', val);
|
||||
}
|
||||
} else {
|
||||
rc = snd_pcm_hw_params_set_buffer_time_minmax(s->handle, params, &minval, &mindir,
|
||||
&maxval, &maxdir);
|
||||
}
|
||||
if (rc < 0) {
|
||||
log_msg(LOG_LEVEL_WARNING, MOD_NAME "Warning - unable to set buffer to its size: %s\n",
|
||||
snd_strerror(rc));
|
||||
@@ -490,7 +500,7 @@ static int audio_play_alsa_reconfigure(void *state, struct audio_desc desc)
|
||||
jitter_buffer_reset(s->buf);
|
||||
#else
|
||||
audio_buffer_destroy(s->buf);
|
||||
s->buf = audio_buffer_init(s->desc.sample_rate, s->desc.bps, s->desc.ch_count, 20);
|
||||
s->buf = audio_buffer_init(s->desc.sample_rate, s->desc.bps, s->desc.ch_count, get_commandline_param("low-latency-audio") ? 20 : 5);
|
||||
#endif
|
||||
s->timestamp = 0;
|
||||
pthread_create(&s->thread_id, NULL, worker, s);
|
||||
|
||||
@@ -124,7 +124,7 @@ static void mixer_dummy_rtp_callback(struct rtp *session [[gnu::unused]], rtp_ev
|
||||
struct am_participant {
|
||||
am_participant(struct socket_udp_local *l, struct sockaddr_storage *ss, string const & audio_codec) {
|
||||
assert(l != nullptr && ss != nullptr);
|
||||
m_buffer = audio_buffer_init(SAMPLE_RATE, BPS, CHANNELS, 50);
|
||||
m_buffer = audio_buffer_init(SAMPLE_RATE, BPS, CHANNELS, get_commandline_param("low-latency-audio") ? 50 : 5);
|
||||
assert(m_buffer != NULL);
|
||||
struct sockaddr *sa = (struct sockaddr *) ss;
|
||||
assert(ss->ss_family == AF_INET || ss->ss_family == AF_INET6);
|
||||
|
||||
@@ -328,6 +328,9 @@ void print_param_doc()
|
||||
}
|
||||
}
|
||||
|
||||
// some common parameters used within multiple modules
|
||||
ADD_TO_PARAM_DOC(low_latency_audio, "* low-latency-audio\n"
|
||||
" Try to reduce audio latency at the expense of worse reliability\n");
|
||||
ADD_TO_PARAM_DOC(ldgm_device, "* window-title=<title>\n"
|
||||
" Use alternative window title (SDL/GL only)\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user