summaryrefslogtreecommitdiffstats
path: root/audio/audio.c
Commit message (Collapse)AuthorAgeFilesLines
* introduce -audio as a replacement for -soundhwPaolo Bonzini2022-05-141-1/+7
| | | | | | | | | | | | | | -audio is used like "-audio pa,model=sb16". It is almost as simple as -soundhw, but it reuses the -audiodev parsing machinery and attaches an audiodev to the newly-created device. The main 'feature' is that it knows about adding the codec device for model=intel-hda, and adding the audiodev to the codec device. In the future, it could be extended to support default models or builtin devices, just like -nic, or even a default backend. For now, keep it simple. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* include: move qemu_get_vm_name() to sysemu.hMarc-André Lureau2022-04-061-1/+1
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220323155743.1585078-26-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Use g_new() & friends where that makes obvious senseMarkus Armbruster2022-03-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Patch created mechanically with: $ spatch --in-place --sp-file scripts/coccinelle/use-g_new-etc.cocci \ --macro-file scripts/cocci-macro-file.h FILES... Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20220315144156.1595462-4-armbru@redhat.com> Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
* audio: Log context for audio bugAkihiko Odaki2022-03-151-13/+12Star
| | | | | | | | | | Without this change audio_bug aborts when the bug condition is met, which discards following useful logs. Call abort after such logs. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220306063202.27331-1-akihiko.odaki@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
* audio: restore mixing-engine playback buffer sizeVolker Rümelin2022-03-041-17/+52
| | | | | | | | | | | | | | | | | | | | | Commit ff095e5231 "audio: api for mixeng code free backends" introduced another FIFO for the audio subsystem with exactly the same size as the mixing-engine FIFO. Most audio backends use this generic FIFO. The generic FIFO used together with the mixing-engine FIFO doubles the audio FIFO size, because that's just two independent FIFOs connected together in series. For audio playback this nearly doubles the playback latency. This patch restores the effective mixing-engine playback buffer size to a pre v4.2.0 size by only accepting the amount of samples for the mixing-engine queue which the downstream queue accepts. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com> Message-Id: <20220301191311.26695-10-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* Revert "audio: fix wavcapture segfault"Volker Rümelin2022-03-041-2/+2
| | | | | | | | | | | This reverts commit cbaf25d1f59ee13fc7542a06ea70784f2e000c04. Since previous commit every audio backend has a pcm_ops function table. It's no longer necessary to test if the table is available. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-9-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: add pcm_ops function table for capture backendVolker Rümelin2022-03-041-0/+2
| | | | | | | | | | Add a pcm_ops function table for the capture backend. This avoids additional code in the next patches to test if the pcm_ops table is available. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-8-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: copy playback stream in sequential orderVolker Rümelin2022-03-041-15/+9Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the code to copy the playback stream in sequential order. The advantage can be seen in the next patches where the stream copy operation effectively becomes a write through operation. The following diagram shows the average buffer fill level and the stream copy sequence. ### represents a timer_period sized chunk. The rest of the buffer sizes are not to scale. With current code: |--------| |#####111| |---#####| sw->buf mix_buf backend buffer 1. clip |--------| |---#####| |111##222| sw->buf mix_buf backend buffer 2. write to audio device 333 -> |--------| |---#####| |---111##| -> 222 sw->buf mix_buf backend buffer 3a. sw device write |-----333| |---#####| |---111##| sw->buf mix_buf backend buffer 3b. resample and mix |--------| |333#####| |---111##| sw->buf mix_buf backend buffer With this patch: 111 -> |--------| |---#####| |---#####| sw->buf mix_buf backend buffer 1a: sw device write |-----111| |---#####| |---#####| sw->buf mix_buf backend buffer 1b. resample and mix |--------| |111##222| |---#####| sw->buf mix_buf backend buffer 2. clip |--------| |---111##| |222##333| sw->buf mix_buf backend buffer 3. write to audio device |--------| |---111##| |---222##| -> 333 sw->buf mix_buf backend buffer The effective total playback buffer size is reduced by timer_period. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-7-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: inline function audio_pcm_sw_get_rpos_in()Volker Rümelin2022-03-041-18/+5Star
| | | | | | | | | | Simplify code by inlining function audio_pcm_sw_get_rpos_in() at the only call site and remove the duplicated audio_bug() test. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-4-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: add function audio_pcm_hw_conv_in()Volker Rümelin2022-03-041-6/+19
| | | | | | | | | | | | Add a function audio_pcm_hw_conv_in() similar to the existing counterpart function audio_pcm_hw_clip_out(). This function reduces the number of calls to the pcm_ops functions get_buffer_in() and put_buffer_in(). That's one less call to get_buffer_in() and put_buffer_in() every time the conv_buffer wraps around. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: move function audio_pcm_hw_clip_out()Volker Rümelin2022-03-041-19/+19
| | | | | | | | | | Move the function audio_pcm_hw_clip_out() into the correct section 'Hard voice (playback)'. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: replace open-coded buffer arithmeticVolker Rümelin2022-03-041-18/+7Star
| | | | | | | | | | | Replace open-coded buffer arithmetic with the new function audio_ring_posb(). That's the position in backward direction of a given point at a given distance. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com> Message-Id: <20220301191311.26695-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: add "dbus" audio backendMarc-André Lureau2021-12-211-0/+1
| | | | | | | | | | | | Add a new -audio backend that accepts D-Bus clients/listeners to handle playback & recording, to be exported via the -display dbus. Example usage: -audiodev dbus,in.mixing-engine=off,out.mixing-engine=off,id=dbus -display dbus,audiodev=dbus Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: Never send migration sectionDr. David Alan Gilbert2021-08-101-0/+10
| | | | | | | | | | | | | | | | | The audio migration vmstate is empty, and always has been; we can't just remove it though because an old qemu might send it us. Changes with -audiodev now mean it's sometimes created when it didn't used to be, and can confuse migration to old qemu. Change it so that vmstate_audio is never sent; if it's received it should still be accepted, and old qemu's shouldn't be too upset if it's missing. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Tested-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20210809170956.78536-1-dgilbert@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: Fix format specifications of debug logsAkihiko Odaki2021-06-171-3/+3
| | | | | | | Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> Message-id: 20210616141411.53892-1-akihiko.odaki@gmail.com Message-Id: <20210616141411.53892-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: move code to audio/audio.cVolker Rümelin2021-06-171-0/+9
| | | | | | | | | | | Move the code to generate the pa_context_new() application name argument to a function in audio/audio.c. The new function audio_application_name() will also be used in the jackaudio backend. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20210517194604.2545-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* sysemu: Let VMChangeStateHandler take boolean 'running' argumentPhilippe Mathieu-Daudé2021-03-091-1/+1
| | | | | | | | | | | The 'running' argument from VMChangeStateHandler does not require other value than 0 / 1. Make it a plain boolean. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Acked-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20210111152020.1422021-3-philmd@redhat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* audio: Add braces for statements/fix braces' positionZhang Han2021-01-151-14/+12Star
| | | | | | | | | | | Fix problems about braces: -braces are necessary for all arms of if/for/while statements -else should follow close brace '}' Signed-off-by: Zhang Han <zhanghan64@huawei.com> Message-id: 20210115012431.79533-1-zhanghan64@huawei.com Message-Id: <20210115012431.79533-2-zhanghan64@huawei.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: remove remaining unused plive codeVolker Rümelin2021-01-151-16/+1Star
| | | | | | | | | Commit 73ad33ef7b "audio: remove plive" forgot to remove this code. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de Message-Id: <20210110100239.27588-12-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: break generic buffer dependency on mixing-engineVolker Rümelin2021-01-151-7/+4Star
| | | | | | | | | | Break the unnecessary dependency of the generic buffer management code on mixing-engine. This is required for the next patch. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de Message-Id: <20210110100239.27588-10-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: split pcm_ops function get_buffer_inVolker Rümelin2021-01-151-4/+14
| | | | | | | | | | | | | Split off pcm_ops function run_buffer_in from get_buffer_in and call run_buffer_in before get_buffer_in. The next patch only needs the generic buffer management part from audio_generic_get_buffer_in(). Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de Message-Id: <20210110100239.27588-8-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* sdlaudio: add -audiodev sdl,out.buffer-count optionVolker Rümelin2021-01-151-1/+1
| | | | | | | | | | | | | | | | | | | Currently there is a crackling noise with SDL2 audio playback. Commit bcf19777df: "audio/sdlaudio: Allow audio playback with SDL2" already mentioned the crackling noise. Add an out.buffer-count option to give users a chance to select sane settings for glitch free audio playback. The idea was taken from the coreaudio backend. The in.buffer-count option will be used with one of the next patches. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Acked-by: Markus Armbruster <armbru@redhat.com> Message-id: 9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de Message-Id: <20210110100239.27588-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: add sanity checkGerd Hoffmann2020-12-151-1/+3
| | | | | | | | | | | Check whenever we actually found the spiceaudio driver before flipping the can_be_default field. Fixes: f0c4555edfdd ("audio: remove qemu_spice_audio_init()") Buglink: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=977301 Reported-by: dann frazier <dann.frazier@canonical.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20201215081151.20095-1-kraxel@redhat.com>
* audio: Simplify audio_bug() removing old codePhilippe Mathieu-Daudé2020-12-151-18/+1Star
| | | | | | | | | | | | This code (introduced in commit 1d14ffa97ea, Oct 2005) is likely unused since years. Time to remove it. If the condition is true, simply call abort(). Suggested-by: Gerd Hoffmann <gerd@kraxel.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201210223506.263709-1-philmd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: remove unused function audio_is_cleaning_up()Volker Rümelin2020-12-151-8/+0Star
| | | | | | | | | | The previous commit removed the last call site of audio_is_cleaning_up(). Remove the now unused function. Tested-by: Howard Spoelstra <hsp.cat7@gmail.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20201213130528.5863-4-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: remove qemu_spice_audio_init()Gerd Hoffmann2020-09-231-0/+16
| | | | | | | | | | Handle the spice special case in audio_init instead. With the qemu_spice_audio_init() symbol dependency being gone we can build spiceaudio as module. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200916084117.21828-2-kraxel@redhat.com
* audio: run downstream playback queue unconditionallyVolker Rümelin2020-09-231-0/+3
| | | | | | | | | | Run the downstream playback queue even if there are no samples in the mixing engine buffer. The downstream queue may still have queued samples. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-7-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: align audio_generic_write with audio_pcm_hw_run_outVolker Rümelin2020-09-231-5/+27
| | | | | | | | | | | | | | | The function audio_generic_write should work exactly like audio_pcm_hw_run_out. It's a very similar function working on a different buffer. This patch significantly reduces the number of drop-outs with the DirectSound backend. To hear the difference start qemu with -audiodev dsound,id=audio0,out.mixing-engine=off and play a song in the guest with and without this patch. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-6-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: remove unnecessary calls to put_buffer_inVolker Rümelin2020-09-231-2/+0Star
| | | | | | | | | | | | | | This patch removes unnecessary calls to the pcm_ops function put_buffer_in(). No audio backend needs this call if the returned length of pcm_ops function get_buffer_in() is zero. For the DirectSound backend this prevents a call to dsound_unlock_in() without a preceding call to dsound_lock_in(). While Windows doesn't complain it seems wrong anyway. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-5-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: align audio_generic_read with audio_pcm_hw_run_inVolker Rümelin2020-09-231-4/+15
| | | | | | | | | | The function audio_generic_read should work exactly like audio_pcm_hw_run_in. It's a very similar function working on a different buffer. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-4-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/spiceaudio: always rate limit playback streamVolker Rümelin2020-09-231-1/+2
| | | | | | | | | | | | | The playback rate with the spiceaudio backend is currently too fast if there's no spice client connected or the spice client can't play audio. Rate limit the audio playback stream in all cases. To calculate the rate correctly the limiter has to know the maximum buffer size. Fixes: 8c198ff065 ("spiceaudio: port to the new audio backend api") Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-3-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/audio: fix video playback slowdown with spiceaudioVolker Rümelin2020-09-231-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | This patch allows the audio backends get_buffer_out() functions to drop audio data and mitigates a bug reported on the qemu-devel mailing list. https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03832.html The new rules for the variables buf and size returned by get_buffer_out() are: size == 0: Downstream playback buffer is full. Retry later. size > 0, buf != NULL: Copy size bytes to buf for playback. size > 0, buf == NULL: Drop size bytes. The audio playback rate with spiceaudio for the no audio case is too fast, but that's what we had before commit fb35c2cec5 "audio/dsound: fix invalid parameters error". The complete fix comes with the next patch. Reported-by: Qi Zhou <atmgnd@outlook.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-2-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* qemu/: fix some comment spelling errorszhaolichang2020-09-171-1/+1
| | | | | | | | | | | I found that there are many spelling errors in the comments of qemu, so I used the spellcheck tool to check the spelling errors and finally found some spelling errors in the folder. Signed-off-by: zhaolichang <zhaolichang@huawei.com> Reviewed-by: Alex Bennee <alex.bennee@linaro.org> Message-Id: <20200917075029.313-2-zhaolichang@huawei.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* audio: fix wavcapture segfaultBruce Rogers2020-05-261-2/+2
| | | | | | | | | | | | | | | Commit 571a8c522e caused the HMP wavcapture command to segfault when processing audio data in audio_pcm_sw_write(), where a NULL sw->hw->pcm_ops is dereferenced. This fix checks that the pointer is valid before dereferincing it. A similar fix is also made in the parallel function audio_pcm_sw_read(). Fixes: 571a8c522e (audio: split ctl_* functions into enable_* and volume_*) Signed-off-by: Bruce Rogers <brogers@suse.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20200521172931.121903-1-brogers@suse.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: add JACK client audiodevGeoffrey McRae2020-05-251-0/+1
| | | | | | | | | This commit adds a new audiodev backend to allow QEMU to use JACK as both an audio sink and source. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-Id: <20200512101603.E3DB73A038E@moya.office.hostfission.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* dsoundaudio: dsound_get_buffer_in should honor *sizeVolker Rümelin2020-04-061-7/+5Star
| | | | | | | | | | | | | This patch prevents an underflow of variable samples in function audio_pcm_hw_run_in(). See commit 599eac4e5a "audio: audio_generic_get_buffer_in should honor *size". This time the while loop in audio_pcm_hw_run_in() will terminate nevertheless, because it seems the recording stream in Windows is always rate limited. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200405075017.9901-3-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: proper support for float samples in mixengKővágó, Zoltán2020-02-061-18/+38
| | | | | | | | | | | | | | | This adds proper support for float samples in mixeng by adding a new audio format for it. Limitations: only native endianness is supported. None of the virtual sound cards support float samples (it looks like most of them only support 8 and 16 bit, only hda supports 32 bit), it is only used for the audio backends (i.e. host side). Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-id: 8a8b0b5698401b78d3c4c8ec90aef83b95babb06.1580672076.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/dsound: fix invalid parameters errorKővágó, Zoltán2020-02-061-4/+2Star
| | | | | | | | | | | | Windows (unlike wine) bails out when IDirectSoundBuffer8::Lock is called with zero length. Also, hw->pos_emul handling was incorrect when calling this function for the first time. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Reported-by: KJ Liew <liewkj@yahoo.com> Tested-by: Howard Spoelstra <hsp.cat7@gmail.com> Message-id: fe9744216d9d421a2dbb09bcf5fa0dbd18f77ac5.1580684275.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: audio_generic_get_buffer_in should honor *sizeVolker Rümelin2020-01-311-1/+2
| | | | | | | | | | | | | | The function generic_get_buffer_in currently ignores the *size parameter and may return a buffer larger than *size. As a result the variable samples in function audio_pcm_hw_run_in may underflow. The while loop then most likely will never termiate. Buglink: http://bugs.debian.org/948658 Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20200123074943.6699-9-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: fix bug 1858488Volker Rümelin2020-01-311-31/+27Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* audio: prevent SIGSEGV in AUD_get_buffer_size_outVolker Rümelin2020-01-311-2/+2
| | | | | | | | | | | | | | | With audiodev parameter out.mixing-engine=off hw->mix_buf is NULL. This leads to a segmentation fault in AUD_get_buffer_size_out. This patch reverts a small part of dc88e38fa7 "audio: unify input and output mixeng buffer management". To reproduce the problem start qemu with -soundhw adlib -audiodev pa,id=audio0,out.mixing-engine=off Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20200123074943.6699-4-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: fix audio_generic_readVolker Rümelin2020-01-311-5/+5
| | | | | | | | | | | It seems the function audio_generic_read started as a copy of function audio_generic_write and some necessary changes were forgotten. Fix the mixed up source and destination pointers and rename misnamed variables. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20200123074943.6699-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: fix audio_generic_writeVolker Rümelin2020-01-311-1/+1
| | | | | | | | | The pcm_ops function put_buffer_out expects the returned pointer of function get_buffer_out as argument. Fix this. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20200123074943.6699-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/audio: Add missing fall through commentPhilippe Mathieu-Daudé2020-01-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | When building with GCC9 using CFLAG -Wimplicit-fallthrough=2 we get: audio/audio.c: In function ‘audio_pcm_init_info’: audio/audio.c:306:14: error: this statement may fall through [-Werror=implicit-fallthrough=] 306 | sign = 1; | ~~~~~^~~ audio/audio.c:307:5: note: here 307 | case AUDIO_FORMAT_U8: | ^~~~ cc1: all warnings being treated as errors Similarly to e46349414, add the missing fall through comment to hint GCC. Fixes: 2b9cce8c8c Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Aleksandar Markovic <amarkovic@wavecomp.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20191218192526.13845-2-philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* audio: fix integer overflowVolker Rümelin2020-01-061-1/+1
| | | | | | | | | | | | Tell the compiler to do a 32bit * 32bit -> 64bit multiplication because period_ticks is a 64bit variable. The overflow occurs for audio timer periods larger than 4294967us. Fixes: be1092afa0 "audio: fix audio timer rate conversion bug" Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 8893a235-66a8-8fbe-7d95-862e29da90b1@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: fix audio recordingVolker Rümelin2019-11-201-0/+1
| | | | | | | | | | | | | | With current code audio recording with all audio backends except PulseAudio and DirectSound is broken. The generic audio recording buffer management forgot to update the current read position after a read. Fixes: ff095e5231 "audio: api for mixeng code free backends" Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Reviewed-by: Zoltán Kővágó <DirtY.iCE.hu@gmail.com> Message-id: 2fc947cf-7b42-de68-3f11-cbcf1c096be9@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: basic support for multichannel audioKővágó, Zoltán2019-10-181-1/+1
| | | | | | | | | Which currently only means removing some checks. Old code won't require more than two channels, but new code will need it. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 7e53be1f97e939ed3bb729ef39e76b775643118a.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: replace shift in audio_pcm_info with bytes_per_frameKővágó, Zoltán2019-10-181-37/+37
| | | | | | | | | | | The bit shifting trick worked because the number of bytes per frame was always a power-of-two (since QEMU only supports mono, stereo and 8, 16 and 32 bit samples). But if we want to add support for surround sound, this no longer holds true. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 1351fd9bcce0ff20d81850c5292722194329de02.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: support more than two channels in volume settingKővágó, Zoltán2019-10-181-8/+22
| | | | | | Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 5d3dd2ee3baaa62805e79c3901abb7415ae32461.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: make mixeng optionalKővágó, Zoltán2019-10-181-6/+64
| | | | | | | | Implementation of the previously added mixing-engine option. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: c05bc258889ed289e8ee1bdbcc5e84174ec221e7.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>