[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/35] paaudio: reduce effective playback buffer size
From: |
Gerd Hoffmann |
Subject: |
[PULL 18/35] paaudio: reduce effective playback buffer size |
Date: |
Fri, 4 Mar 2022 15:21:06 +0100 |
From: Volker RĂ¼melin <vr_qemu@t-online.de>
Add the buffer_get_free pcm_ops function to reduce the effective
playback buffer size. All intermediate audio playback buffers
become temporary buffers.
Signed-off-by: Volker RĂ¼melin <vr_qemu@t-online.de>
Message-Id: <20220301191311.26695-11-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
audio/paaudio.c | 47 +++++++++++++++++++++++++++++++----------------
1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/audio/paaudio.c b/audio/paaudio.c
index 9df1e69c086f..d94f858ec761 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -201,39 +201,53 @@ unlock_and_fail:
return 0;
}
+static size_t qpa_buffer_get_free(HWVoiceOut *hw)
+{
+ PAVoiceOut *p = (PAVoiceOut *)hw;
+ PAConnection *c = p->g->conn;
+ size_t l;
+
+ pa_threaded_mainloop_lock(c->mainloop);
+
+ CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
+ "pa_threaded_mainloop_lock failed\n");
+ if (pa_stream_get_state(p->stream) != PA_STREAM_READY) {
+ /* wait for stream to become ready */
+ l = 0;
+ goto unlock;
+ }
+
+ l = pa_stream_writable_size(p->stream);
+ CHECK_SUCCESS_GOTO(c, l != (size_t) -1, unlock_and_fail,
+ "pa_stream_writable_size failed\n");
+
+unlock:
+ pa_threaded_mainloop_unlock(c->mainloop);
+ return l;
+
+unlock_and_fail:
+ pa_threaded_mainloop_unlock(c->mainloop);
+ return 0;
+}
+
static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t *size)
{
- PAVoiceOut *p = (PAVoiceOut *) hw;
+ PAVoiceOut *p = (PAVoiceOut *)hw;
PAConnection *c = p->g->conn;
void *ret;
- size_t l;
int r;
pa_threaded_mainloop_lock(c->mainloop);
CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail,
"pa_threaded_mainloop_lock failed\n");
- if (pa_stream_get_state(p->stream) != PA_STREAM_READY) {
- /* wait for stream to become ready */
- l = 0;
- ret = NULL;
- goto unlock;
- }
-
- l = pa_stream_writable_size(p->stream);
- CHECK_SUCCESS_GOTO(c, l != (size_t) -1, unlock_and_fail,
- "pa_stream_writable_size failed\n");
*size = -1;
r = pa_stream_begin_write(p->stream, &ret, size);
CHECK_SUCCESS_GOTO(c, r >= 0, unlock_and_fail,
"pa_stream_begin_write failed\n");
-unlock:
pa_threaded_mainloop_unlock(c->mainloop);
- if (*size > l) {
- *size = l;
- }
return ret;
unlock_and_fail:
@@ -901,6 +915,7 @@ static struct audio_pcm_ops qpa_pcm_ops = {
.init_out = qpa_init_out,
.fini_out = qpa_fini_out,
.write = qpa_write,
+ .buffer_get_free = qpa_buffer_get_free,
.get_buffer_out = qpa_get_buffer_out,
.put_buffer_out = qpa_put_buffer_out,
.volume_out = qpa_volume_out,
--
2.35.1
- [PULL 09/35] audio: move function audio_pcm_hw_clip_out(), (continued)
- [PULL 09/35] audio: move function audio_pcm_hw_clip_out(), Gerd Hoffmann, 2022/03/04
- [PULL 10/35] audio: add function audio_pcm_hw_conv_in(), Gerd Hoffmann, 2022/03/04
- [PULL 12/35] paaudio: increase default latency to 46ms, Gerd Hoffmann, 2022/03/04
- [PULL 11/35] audio: inline function audio_pcm_sw_get_rpos_in(), Gerd Hoffmann, 2022/03/04
- [PULL 13/35] jackaudio: use more jack audio buffers, Gerd Hoffmann, 2022/03/04
- [PULL 14/35] audio: copy playback stream in sequential order, Gerd Hoffmann, 2022/03/04
- [PULL 15/35] audio: add pcm_ops function table for capture backend, Gerd Hoffmann, 2022/03/04
- [PULL 16/35] Revert "audio: fix wavcapture segfault", Gerd Hoffmann, 2022/03/04
- [PULL 17/35] audio: restore mixing-engine playback buffer size, Gerd Hoffmann, 2022/03/04
- [PULL 19/35] dsoundaudio: reduce effective playback buffer size, Gerd Hoffmann, 2022/03/04
- [PULL 18/35] paaudio: reduce effective playback buffer size,
Gerd Hoffmann <=
- [PULL 21/35] paaudio: fix samples vs. frames mix-up, Gerd Hoffmann, 2022/03/04
- [PULL 25/35] hw/i386: Improve bounds checking in OVMF table parsing, Gerd Hoffmann, 2022/03/04
- [PULL 20/35] ossaudio: reduce effective playback buffer size, Gerd Hoffmann, 2022/03/04
- [PULL 22/35] sdlaudio: fix samples vs. frames mix-up, Gerd Hoffmann, 2022/03/04
- [PULL 23/35] hw/usb/redirect.c: Stop using qemu_oom_check(), Gerd Hoffmann, 2022/03/04
- [PULL 24/35] coreaudio: Notify error in coreaudio_init_out, Gerd Hoffmann, 2022/03/04
- [PULL 29/35] ui/console: fix texture leak when calling surface_gl_create_texture(), Gerd Hoffmann, 2022/03/04
- [PULL 27/35] docs: Add spec of OVMF GUIDed table for SEV guests, Gerd Hoffmann, 2022/03/04
- [PULL 28/35] ui/console: fix crash when using gl context with non-gl listeners, Gerd Hoffmann, 2022/03/04
- [PULL 30/35] ui: do not create a surface when resizing a GL scanout, Gerd Hoffmann, 2022/03/04