summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker RĂ¼melin2022-03-01 20:13:08 +0100
committerGerd Hoffmann2022-03-04 11:05:13 +0100
commitc93a593372967b98438ab832b1b6eded12fdee8f (patch)
tree0a6384cb4ef173ad16289f1704361f4d97e3ab53
parentpaaudio: reduce effective playback buffer size (diff)
downloadqemu-c93a593372967b98438ab832b1b6eded12fdee8f.tar.gz
qemu-c93a593372967b98438ab832b1b6eded12fdee8f.tar.xz
qemu-c93a593372967b98438ab832b1b6eded12fdee8f.zip
dsoundaudio: reduce effective playback buffer size
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-12-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
-rw-r--r--audio/dsoundaudio.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index 3dd2c4d4a6..231f3e65b3 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -427,22 +427,18 @@ static void dsound_enable_out(HWVoiceOut *hw, bool enable)
}
}
-static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size)
+static size_t dsound_buffer_get_free(HWVoiceOut *hw)
{
DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;
LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
HRESULT hr;
- DWORD ppos, wpos, act_size;
- size_t req_size;
- int err;
- void *ret;
+ DWORD ppos, wpos;
hr = IDirectSoundBuffer_GetCurrentPosition(
dsb, &ppos, ds->first_time ? &wpos : NULL);
if (FAILED(hr)) {
dsound_logerr(hr, "Could not get playback buffer position\n");
- *size = 0;
- return NULL;
+ return 0;
}
if (ds->first_time) {
@@ -450,13 +446,20 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size)
ds->first_time = false;
}
- req_size = audio_ring_dist(ppos, hw->pos_emul, hw->size_emul);
- req_size = MIN(req_size, hw->size_emul - hw->pos_emul);
+ return audio_ring_dist(ppos, hw->pos_emul, hw->size_emul);
+}
- if (req_size == 0) {
- *size = 0;
- return NULL;
- }
+static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size)
+{
+ DSoundVoiceOut *ds = (DSoundVoiceOut *)hw;
+ LPDIRECTSOUNDBUFFER dsb = ds->dsound_buffer;
+ DWORD act_size;
+ size_t req_size;
+ int err;
+ void *ret;
+
+ req_size = MIN(*size, hw->size_emul - hw->pos_emul);
+ assert(req_size > 0);
err = dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, NULL,
&act_size, NULL, false, ds->s);
@@ -699,6 +702,7 @@ static struct audio_pcm_ops dsound_pcm_ops = {
.init_out = dsound_init_out,
.fini_out = dsound_fini_out,
.write = audio_generic_write,
+ .buffer_get_free = dsound_buffer_get_free,
.get_buffer_out = dsound_get_buffer_out,
.put_buffer_out = dsound_put_buffer_out,
.enable_out = dsound_enable_out,