summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* 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-152-9/+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>
* coreaudio: always stop audio playback on shut downVolker Rümelin2020-12-151-20/+16Star
| | | | | | | | | | | | | | | | | | | | | | | | | Always stop audio playback and remove the playback callback when QEMU exits. On shut down the function coreaudio_fini_out() destroys the coreaudio mutex but fails to stop audio playback and to remove the audio playback callback, because function audio_is_cleaning_up() always returns true when called from coreaudio_fini_out(). Now there is a time window from pthread_mutex_destroy() to program exit where Core Audio may call the audio playback callback which tries to lock the destroyed coreaudio mutex. This leads to the following error. coreaudio: Could not lock voice for audioDeviceIOProc Reason: Invalid argument This bug was reported on the qemu-discuss mailing list. https://lists.nongnu.org/archive/html/qemu-discuss/2020-10/msg00018.html Tested-by: Howard Spoelstra <hsp.cat7@gmail.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20201213130528.5863-3-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* coreaudio: don't start playback in init routineVolker Rümelin2020-12-151-11/+0Star
| | | | | | | | | | | Every emulated audio device has a way to enable audio playback. Don't start playback until the guest enables the audio device to keep the Core Audio device run state in sync with hw->enabled. Tested-by: Howard Spoelstra <hsp.cat7@gmail.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20201213130528.5863-2-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* coreaudio: rename misnamed variable fake_asVolker Rümelin2020-12-151-3/+3
| | | | | | | | | | | | While the variable once was used to fake audio settings, since commit ed2a4a7941 "audio: proper support for float samples in mixeng" this is no longer true. Rename the variable to obt_as. This is the same naming scheme as in audio/sdlaudio.c Tested-by: Howard Spoelstra <hsp.cat7@gmail.com> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20201213130528.5863-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: fix use after free segfaultGeoffrey McRae2020-11-131-13/+37
| | | | | | | | | | | | This change registers a bottom handler to close the JACK client connection when a server shutdown signal is received. Without this libjack2 attempts to "clean up" old clients and causes a use after free segfault. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Message-Id: <20201108063351.35804-2-geoff@hostfission.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* spice: move add_interface() to QemuSpiceOps.Gerd Hoffmann2020-10-211-2/+2
| | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20201019075224.14803-6-kraxel@redhat.com
* meson: add spice_headers dependency.Gerd Hoffmann2020-10-151-1/+1
| | | | | | | | | Used for files which (with CONFIG_SPICE=y) depend on spice header files to pick up some enum, but which do not depend on on the actual spice shared library. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20201014121120.13482-6-kraxel@redhat.com
* monitor: Use getter/setter functions for cur_monKevin Wolf2020-10-091-4/+4
| | | | | | | | | | | | | cur_mon really needs to be coroutine-local as soon as we move monitor command handlers to coroutines and let them yield. As a first step, just remove all direct accesses to cur_mon so that we can implement this in the getter function later. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20201005155855.256490-4-kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
* Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into ↵Peter Maydell2020-09-241-9/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | staging Pull request This includes the atomic_ -> qatomic_ rename that touches many files and is prone to conflicts. # gpg: Signature made Wed 23 Sep 2020 17:08:43 BST # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: qemu/atomic.h: rename atomic_ to qatomic_ tests: add test-fdmon-epoll fdmon-poll: reset npfd when upgrading to fdmon-epoll gitmodules: add qemu.org vbootrom submodule gitmodules: switch to qemu.org meson mirror gitmodules: switch to qemu.org qboot mirror docs/system: clarify deprecation schedule virtio-crypto: don't modify elem->in/out_sg virtio-blk: undo destructive iov_discard_*() operations util/iov: add iov_discard_undo() virtio: add vhost-user-fs-ccw device libvhost-user: handle endianness as mandated by the spec MAINTAINERS: add Stefan Hajnoczi as block/nvme.c maintainer Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * qemu/atomic.h: rename atomic_ to qatomic_Stefan Hajnoczi2020-09-231-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang's C11 atomic_fetch_*() functions only take a C11 atomic type pointer argument. QEMU uses direct types (int, etc) and this causes a compiler error when a QEMU code calls these functions in a source file that also included <stdatomic.h> via a system header file: $ CC=clang CXX=clang++ ./configure ... && make ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid) Avoid using atomic_*() names in QEMU's atomic.h since that namespace is used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h and <stdatomic.h> can co-exist. I checked /usr/include on my machine and searched GitHub for existing "qatomic_" users but there seem to be none. This patch was generated using: $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \ sort -u >/tmp/changed_identifiers $ for identifier in $(</tmp/changed_identifiers); do sed -i "s%\<$identifier\>%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
* | audio: build spiceaudio as moduleGerd Hoffmann2020-09-231-2/+2
| | | | | | | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200916084117.21828-3-kraxel@redhat.com
* | audio: remove qemu_spice_audio_init()Gerd Hoffmann2020-09-232-5/+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-232-7/+6Star
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | audio: handle buf == NULL in put_buffer_out()Volker Rümelin2020-09-231-5/+8
|/ | | | | | | | | | | | | | | With the next patch all audio backends put_buffer_out() functions have to handle the buf == NULL case, provided the get_buffer_out() function may return buf = NULL and size > 0. It turns out that all audio backends get_buffer_out() functions either can't return buf = NULL or return buf = NULL and size = 0 at the same time. The only exception is the spiceaudio backend where size may be uninitialized. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200920171729.15861-1-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>
* trace-events: Delete unused trace pointsMarkus Armbruster2020-09-091-3/+0Star
| | | | | | | | Tracked down with the help of scripts/cleanup-trace-events.pl. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-id: 20200806141334.3646302-4-armbru@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* meson: convert audio directory to MesonPaolo Bonzini2020-08-212-35/+30Star
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* trace: switch position of headers to what Meson requiresPaolo Bonzini2020-08-211-0/+1
| | | | | | | | | | | | | | | | | Meson doesn't enjoy the same flexibility we have with Make in choosing the include path. In particular the tracing headers are using $(build_root)/$(<D). In order to keep the include directives unchanged, the simplest solution is to generate headers with patterns like "trace/trace-audio.h" and place forwarding headers in the source tree such that for example "audio/trace.h" includes "trace/trace-audio.h". This patch is too ugly to be applied to the Makefiles now. It's only a way to separate the changes to the tracing header files from the Meson rewrite of the tracing logic. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* ossaudio: fix out of bounds writeVolker Rümelin2020-07-131-0/+1
| | | | | | | | | | | | | | | | | | In function oss_read() a read error currently does not exit the read loop. With no data to read the variable pos will quickly underflow and a subsequent successful read overwrites memory outside the buffer. This patch adds the missing break statement to the error path of the function. To reproduce start qemu with -audiodev oss,id=audio0 and in the guest start audio recording. After some time this will trigger an exception. Fixes: 3ba4066d08 "ossaudio: port to the new audio backend api" Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200707180836.5435-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* qapi: Make visitor functions taking Error ** return bool, not voidMarkus Armbruster2020-07-101-5/+10
| | | | | | | | | | See recent commit "error: Document Error API usage rules" for rationale. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-18-armbru@redhat.com>
* audio/jack: simplify the re-init code pathGeoffrey McRae2020-06-171-6/+6
| | | | | | | | | | Instead of checking for the audodev state in each code path, centralize the check into the initialize function itself to make it safe to call it at any time. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-id: 20200613040518.38172-7-geoff@hostfission.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: honour the enable state of the audio deviceGeoffrey McRae2020-06-171-8/+21
| | | | | | | | | | | | | | | | | When the guest closes the audio device we must start dropping input samples from JACK and zeroing the output buffer samples. Failure to do so causes sound artifacts during operations such as guest OS reboot, and causes a hang of the input pipeline breaking it until QEMU is restated. Closing and reconnecting to JACK was tested during these enable/disable calls which works well for Linux guests, however Windows re-opens the audio hardware repeatedly even when doing simple tasks like playing a system sounds. As such it was decided it is better to feed silence to JACK while the device is disabled. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-id: 20200613040518.38172-6-geoff@hostfission.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: do not remove ports when finishingGeoffrey McRae2020-06-171-3/+0Star
| | | | | | | | | | | | | This fixes a hang when there is a communications issue with the JACK server. Simply closing the connection is enough to completely clean up and as such we do not need to remove the ports first. As JACK uses a socket based protocol that relies on the `select` call, if there is a communication breakdown with the server the client library waits forever for a response to the unregister request. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-id: 20200613040518.38172-5-geoff@hostfission.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: remove invalid set of input support boolGeoffrey McRae2020-06-171-3/+0Star
| | | | | | | | | | | | | Initial code for JACK did not support audio input and as such this boolean was set to let QEMU know, however JACK ended up including input support making this invalid. Further investigation shows it was invalid to set it in the first instance anyway due to a failure on my part understand properly what this was for when the audodev was initially developed. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-id: 20200613040518.38172-4-geoff@hostfission.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: remove unused stopped stateGeoffrey McRae2020-06-171-4/+0Star
| | | | | | Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-id: 20200613040518.38172-3-geoff@hostfission.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: fix invalid minimum buffer size checkGeoffrey McRae2020-06-171-11/+11
| | | | | | | | | | | JACK does not provide us with the configured buffer size until after activiation which was overriding this minimum value. JACK itself doesn't have this minimum limitation, but the QEMU virtual hardware and as such it must be enforced, failure to do so results in audio discontinuities. Signed-off-by: Geoffrey McRae <geoff@hostfission.com> Message-id: 20200613040518.38172-2-geoff@hostfission.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: Let capture_callback handler use const buffer argumentPhilippe Mathieu-Daudé2020-05-262-2/+2
| | | | | | | | | The buffer is the captured input to pass to backends. As we should not modify it, mark the argument const. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20200505132603.8575-3-f4bug@amsat.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: Let audio_sample_to_uint64() use const samples argumentPhilippe Mathieu-Daudé2020-05-262-3/+3
| | | | | | | | | The samples are the input to convert to u64. As we should not modify them, mark the argument const. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20200505132603.8575-2-f4bug@amsat.org> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* 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/mixeng: fix clang 10+ warningVolker Rümelin2020-05-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code in CONV_NATURAL_FLOAT() and CLIP_NATURAL_FLOAT() seems to use the constant 2^31-0.5 to convert float to integer and back. But the float type lacks the required precision and the constant used for the conversion is 2^31. This is equiva- lent to a [-1.f, 1.f] <-> [INT32_MIN, INT32_MAX + 1] mapping. This patch explicitly writes down the used constant. The compiler generated code doesn't change. The constant 2^31 has an exact float representation and the clang 10 compiler stops complaining about an implicit int to float conversion with a changed value. A few notes: - The conversion of 1.f to INT32_MAX + 1 doesn't overflow. The type of the destination variable is int64_t. - At a later stage one of the clip_* functions in audio/mixeng_template.h limits INT32_MAX + 1 to the integer range. - The clip_natural_float_* functions in audio/mixeng.c convert INT32_MAX and INT32_MAX + 1 to 1.f. Buglink: https://bugs.launchpad.net/bugs/1878627 Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200523201712.23908-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/jack: add JACK client audiodevGeoffrey McRae2020-05-254-0/+675
| | | | | | | | | 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-062-8/+6Star
| | | | | | | | | | | | | 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>
* dsoundaudio: fix "Could not lock capture buffer" warningVolker Rümelin2020-04-061-0/+5
| | | | | | | | | | | | | | IDirectSoundCaptureBuffer_Lock() fails on Windows when called with len = 0. Return early from dsound_get_buffer_in() in this case. To reproduce the warning start a linux guest. In the guest start Audacity and you will see a lot of "Could not lock capture buffer" warnings. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200405075017.9901-2-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* dsoundaudio: fix never-ending playback loopVolker Rümelin2020-04-061-1/+1
| | | | | | | | | | | | | | | | | | | Currently the DirectSound backend fails to stop audio playback in dsound_enable_out(). To detect a lost buffer condition dsound_get_status_out() incorrectly uses the error code DSERR_BUFFERLOST instead of flag DSBSTATUS_BUFFERLOST as a mask and returns with an error. As a result dsound_enable_out() returns early and doesn't stop playback. To reproduce the bug start qemu on a Windows host with -soundhw pcspk -audiodev dsound,id=audio0. On the guest FreeDOS 1.2 command line enter beep. The image Day 1 - F-Bird from the QEMU Advent Calendar 2018 shows the bug as well. Buglink: https://bugs.launchpad.net/qemu/+bug/1699628 Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200405075017.9901-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: fix saturation nonlinearity in clip_* functionsVolker Rümelin2020-03-161-3/+2Star
| | | | | | | | | The current positive limit for the saturation nonlinearity is only correct if the type of the result has 8 bits or less. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200308193321.20668-5-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: change mixing engine float range to [-1.f, 1.f]Volker Rümelin2020-03-162-11/+10Star
| | | | | | | | | | | | | | | | Currently the internal float range of the mixing engine is [-.5f, .5f]. PulseAudio, SDL2 and libasound use a [-1.f, 1.f] range. This means with float samples the audio playback volume is 6dB too low and audio recording signals will be clipped in most cases. To avoid another scaling factor in the conv_natural_float_* and clip_natural_float_* functions with FLOAT_MIXENG defined this patch changes the mixing engine float range to [-1.f, 1.f]. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200308193321.20668-4-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: consistency changesVolker Rümelin2020-03-161-1/+1
| | | | | | | | | | Change the clip_natural_float_from_mono() function in audio/mixeng.c to be consistent with the clip_*_from_mono() functions in audio/mixeng_template.h. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200308193321.20668-3-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio: change naming scheme of FLOAT_CONV macrosVolker Rümelin2020-03-161-11/+11
| | | | | | | | | This patch changes the naming scheme of the FLOAT_CONV_TO and FLOAT_CONV_FROM macros to the scheme used in mixeng_template.h. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200308193321.20668-2-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/alsaaudio: Remove superfluous semicolonsPhilippe Mathieu-Daudé2020-02-181-2/+2
| | | | | | | | | | Fixes: 286a5d201e4 Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <20200218094402.26625-3-philmd@redhat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
* audio: proper support for float samples in mixengKővágó, Zoltán2020-02-069-78/+179
| | | | | | | | | | | | | | | 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>
* coreaudio: fix coreaudio playbackVolker Rümelin2020-02-064-23/+69
| | | | | | | | | | | | | | | | | | | | There are reports that since commit 2ceb8240fa "coreaudio: port to the new audio backend api" audio playback with CoreAudio is broken. This patch reverts some parts the commit. Because of changes in the audio subsystem the audio clip function in v4.1.0 of coreaudio.c had to be moved to mixeng.c and the generic buffer management code needed a hint about the size of the float type. This patch is based on a patch from Zoltán Kővágó found at https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02142.html. Fixes: 2ceb8240fa "coreaudio: port to the new audio backend api" Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200202140641.4737-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* audio/dsound: fix invalid parameters errorKővágó, Zoltán2020-02-063-8/+26
| | | | | | | | | | | | 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>