diff options
author | Volker RĂ¼melin <vr_qemu@t-online.de> | 2020-01-23 08:49:39 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-31 08:48:03 +0100 |
commit | fdc8c5f4717f42f4b19b733ada30da2ba92a3ad1 (patch) | |
tree | 96e70e508afb0631a2f107f6e7a21a07eddc53e6 /audio/ossaudio.c | |
parent | 69ac07863205ec281bcd2f2e6571202da0c315f7 (diff) |
audio: fix bug 1858488
The combined generic buffer management code and buffer run out
code in function audio_generic_put_buffer_out has a problematic
behaviour. A few hundred milliseconds after playback starts the
mixing buffer and the generic buffer are nearly full and the
following pattern can be seen.
On first call of audio_pcm_hw_run_out the buffer run code in
audio_generic_put_buffer_out writes some data to the audio
hardware but the generic buffer will fill faster and is full
when audio_pcm_hw_run_out returns. This is because emulated
audio devices can produce playback data at a higher rate than
the audio backend hardware consumes this data.
On next call of audio_pcm_hw_run_out the buffer run code in
audio_generic_put_buffer_out writes some data to the audio
hardware but no audio data is transferred to the generic buffer
because the buffer is already full.
Then the pattern repeats. For the emulated audio device this
looks like the audio timer period has doubled.
This patch splits the combined generic buffer management code
and buffer run out code and calls the buffer run out code after
buffer management code to break this pattern.
The bug report is for the wav audio backend. But the problem is
not limited to this backend. All audio backends which use the
audio_generic_put_buffer_out function show this problem.
Buglink: https://bugs.launchpad.net/qemu/+bug/1858488
Signed-off-by: Volker RĂ¼melin <vr_qemu@t-online.de>
Message-Id: <20200123074943.6699-5-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/ossaudio.c')
-rw-r--r-- | audio/ossaudio.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 94564916fb..576b5b5b20 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -382,6 +382,15 @@ static size_t oss_get_available_bytes(OSSVoiceOut *oss) return audio_ring_dist(cntinfo.ptr, oss->hw.pos_emul, oss->hw.size_emul); } +static void oss_run_buffer_out(HWVoiceOut *hw) +{ + OSSVoiceOut *oss = (OSSVoiceOut *)hw; + + if (!oss->mmapped) { + audio_generic_run_buffer_out(hw); + } +} + static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; @@ -748,6 +757,7 @@ static struct audio_pcm_ops oss_pcm_ops = { .init_out = oss_init_out, .fini_out = oss_fini_out, .write = oss_write, + .run_buffer_out = oss_run_buffer_out, .get_buffer_out = oss_get_buffer_out, .put_buffer_out = oss_put_buffer_out, .enable_out = oss_enable_out, |