Commit 704e9c2a authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Attempt to fix lag when playing dtmfs

parent c9e33c76
......@@ -459,7 +459,7 @@ static void ms_qsa_write_process(MSFilter *f) {
params.mode = SND_PCM_MODE_BLOCK;
params.start_mode = SND_PCM_START_FULL;
params.stop_mode = SND_PCM_STOP_STOP;
params.buf.block.frag_size = pi.max_fragment_size;
params.buf.block.frag_size = pi.fragment_size;
params.buf.block.frags_min = 1;
params.buf.block.frags_max = -1;
params.format.interleave = 1;
......@@ -520,27 +520,29 @@ static void ms_qsa_write_process(MSFilter *f) {
goto setup_failure;
}
if (FD_ISSET(d->fd, &fdset) > 0) {
if (ms_bufferizer_get_avail(d->bufferizer) >= d->buffer_size) {
ms_bufferizer_read(d->bufferizer, d->buffer, d->buffer_size);
written = snd_pcm_plugin_write(d->handle, d->buffer, d->buffer_size);
if (written < d->buffer_size) {
ms_warning("%s: snd_pcm_plugin_write(%d) failed: %d", __FUNCTION__, d->buffer_size, errno);
memset(&status, 0, sizeof(status));
status.channel = SND_PCM_CHANNEL_PLAYBACK;
err = snd_pcm_plugin_status(d->handle, &status);
int size = ms_bufferizer_get_avail(d->bufferizer);
if (size > d->buffer_size) {
size = d->buffer_size;
}
ms_bufferizer_read(d->bufferizer, d->buffer, size);
written = snd_pcm_plugin_write(d->handle, d->buffer, size);
if (written < d->buffer_size) {
ms_warning("%s: snd_pcm_plugin_write(%d) failed: %d", __FUNCTION__, size, errno);
memset(&status, 0, sizeof(status));
status.channel = SND_PCM_CHANNEL_PLAYBACK;
err = snd_pcm_plugin_status(d->handle, &status);
if (err != 0) {
ms_error("%s: snd_pcm_plugin_status() failed: %s", __FUNCTION__, snd_strerror(err));
goto setup_failure;
}
if ((status.status == SND_PCM_STATUS_READY) || (status.status == SND_PCM_STATUS_UNDERRUN)) {
err = snd_pcm_plugin_prepare(d->handle, SND_PCM_CHANNEL_PLAYBACK);
if (err != 0) {
ms_error("%s: snd_pcm_plugin_status() failed: %s", __FUNCTION__, snd_strerror(err));
ms_error("%s: snd_pcm_plugin_prepare() failed: %s", __FUNCTION__, snd_strerror(err));
goto setup_failure;
}
if ((status.status == SND_PCM_STATUS_READY) || (status.status == SND_PCM_STATUS_UNDERRUN)) {
err = snd_pcm_plugin_prepare(d->handle, SND_PCM_CHANNEL_PLAYBACK);
if (err != 0) {
ms_error("%s: snd_pcm_plugin_prepare() failed: %s", __FUNCTION__, snd_strerror(err));
goto setup_failure;
}
}
if (written < 0) written = 0;
}
if (written < 0) written = 0;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment