aboutsummaryrefslogtreecommitdiff
path: root/audio/paaudio.c
AgeCommit message (Collapse)AuthorFilesLines
2023-10-03audio: remove QEMU_AUDIO_* and -audio-help supportPaolo Bonzini1-1/+0
These have been deprecated for a long time, and the introduction of -audio in 7.1.0 has cemented the new way of specifying an audio backend's parameters. However, there is still a need for simple configuration of the audio backend in the desktop case; therefore, if no audiodev is passed to audio_init(), go through a bunch of simple Audiodev* structures and pick the first that can be initialized successfully. The only QEMU_AUDIO_* option that is left in, waiting for a better idea, is QEMU_AUDIO_DRV=none which is used by qtest. Remove all the parsing code, including the concept of "can_be_default" audio drivers: now that audio_prio_list[] is only used in a single place, wav can be excluded directly in that function. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-10-03audio: allow returning an error from the driver initPaolo Bonzini1-2/+5
An error is already printed by audio_driver_init, but we can make it more precise if the driver can return an Error *. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2022-12-13qapi audio: Elide redundant has_FOO in generated CMarkus Armbruster1-6/+6
The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for qapi/audio.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Additionally, helper get_str() loses its @has_dst parameter. Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20221104160712.3005652-8-armbru@redhat.com>
2022-03-22Replace GCC_FMT_ATTR with G_GNUC_PRINTFMarc-André Lureau1-1/+1
One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-03-21Use g_new() & friends where that makes obvious senseMarkus Armbruster1-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>
2022-03-04paaudio: fix samples vs. frames mix-upVolker Rümelin1-10/+4
Now that the mixing buffer size no longer adds to playback latency, fix the samples vs. frames mix-up in the mixing buffer size calculation. This change will go largely unnoticed as long as the user doesn't use a buffer-size smaller than timer-period. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-14-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2022-03-04paaudio: reduce effective playback buffer sizeVolker Rümelin1-9/+24
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>
2022-03-04paaudio: increase default latency to 46msVolker Rümelin1-1/+1
This is a patch to improve the pulseaudio playback experience. Asking pulseaudio for a playback latency of 15ms is quite demanding. Increase this to 46ms. The total playback latency now is 31ms larger. One of the next patches will reduce the total playback latency again by more than 46ms. Here is a quote from the PulseAudio Latency Control documentation: 'For the sake of (...) drop-out safety always make sure to pick the highest latency possible that fulfills your needs.' Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20220301191311.26695-5-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-06-17audio: move code to audio/audio.cVolker Rümelin1-4/+1
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>
2021-06-17paaudio: remove unused stream flagsVolker Rümelin1-4/+1
In current code there are no calls to pa_stream_get_latency() or pa_stream_get_time() to receive latency or time information. Remove the flags PA_STREAM_INTERPOLATE_TIMING and PA_STREAM_AUTO_TIMING_UPDATE which instruct PulseAudio to calculate this information in regular intervals. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20210517194604.2545-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15audio: Suspect code indent for conditional statementsZhang Han1-1/+1
Fix code indent. Signed-off-by: Zhang Han <zhanghan64@huawei.com> Message-id: 20210115012431.79533-1-zhanghan64@huawei.com Message-Id: <20210115012431.79533-7-zhanghan64@huawei.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: send recorded data in smaller chunksVolker Rümelin1-2/+3
Tell PulseAudio to send recorded audio data in smaller chunks than timer_period, so there's a good chance that qemu can read recorded audio data every time it looks for new data. PulseAudio tries to send buffer updates at a fragsize / 2 rate. With fragsize = timer_period / 2 * 3 the update rate is 75% of timer_period. The lower limit for the recording buffer size maxlength is fragsize * 2. 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-19-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: limit minreq to 75% of audio timer_rateVolker Rümelin1-1/+2
Currently with the playback buffer attribute minreq = -1 and flag PA_STREAM_EARLY_REQUESTS PulseAudio uses minreq = tlength / 4. To improve audio playback with larger PulseAudio server side buffers, limit minreq to a maximum of 75% of audio timer_rate. That way there is a good chance qemu receives a stream buffer size update before it tries to write data to the playback stream. 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-18-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: comment bugs in functions qpa_init_*Volker Rümelin1-0/+8
The audio buffer size in audio/paaudio.c is typically larger than expected. Just comment the bugs in qpa_init_in() and qpa_init_out() for now. Fixing these bugs may break glitch free audio playback with fine tuned user audio settings. 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-17-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: remove unneeded codeVolker Rümelin1-8/+2
Commit baea032ec7 "audio/paaudio: fix ignored buffer_length setting" added code to handle buffer_length defaults. This was unnecessary because the audio_buffer_* functions in audio/audio.c already handle this. Remove the unneeded 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-16-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: wait until the playback stream is readyVolker Rümelin1-0/+7
Don't call pa_stream_writable_size() in qpa_get_buffer_out() before the playback stream is ready. This prevents a lot of the following pulseaudio error messages. pulseaudio: pa_stream_writable_size failed pulseaudio: Reason: Bad state To reproduce start qemu with -parallel none -device gus,audiodev=audio0 -audiodev pa,id=audio0 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-15-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: wait for PA_STREAM_READY in qpa_write()Volker Rümelin1-0/+6
Don't call pa_stream_writable_size() in qpa_write() before the playback stream is ready. This prevents a lot of the following pulseaudio error messages. pulseaudio: pa_stream_writable_size failed pulseaudio: Reason: Bad state To reproduce start qemu with -parallel none -device gus,audiodev=audio0 -audiodev pa,id=audio0,out.mixing-engine=off 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-14-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2021-01-15paaudio: avoid to clip samples multiple timesVolker Rümelin1-1/+31
The pulseaudio backend currently converts, clips and copies audio playback samples in the mixing-engine sample buffer multiple times. In qpa_get_buffer_out() the function pa_stream_begin_write() returns a rather large buffer and this allows audio_pcm_hw_run_out() in audio/audio.c to copy all samples in the mixing-engine buffer to the pulse audio buffer. Immediately after copying, qpa_write() notices with a call to pa_stream_writable_size() that pulse audio only needs a smaller part of the copied samples and ignores the rest. This copy and ignore process happens several times for each audio sample. To fix this behaviour, call pa_stream_writable_size() in qpa_get_buffer_out() to limit the number of samples audio_pcm_hw_run_out() will convert. With this change the pulseaudio pcm_ops functions put_buffer_out and write are no longer identical and a separate qpa_put_buffer_out is needed. 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-13-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-02-06audio: proper support for float samples in mixengKővágó, Zoltán1-0/+9
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>
2020-01-31paaudio: remove unused variablesVolker Rümelin1-4/+2
The unused variables were last used before commit 49ddd7e122 "paaudio: port to the new audio backend api". Fixes: 49ddd7e122 Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-Id: <20200123074943.6699-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-01-06paaudio: wait until the recording stream is readyVolker Rümelin1-0/+5
Don't call pa_stream_peek before the recording stream is ready. Information to reproduce the problem. Start and stop Audacity in the guest several times because the problem is racy. libvirt log file: -audiodev pa,id=audio0,server=localhost,out.latency=30000, out.mixing-engine=off,in.mixing-engine=off \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny, resourcecontrol=deny \ -msg timestamp=on : Domain id=4 is tainted: custom-argv char device redirected to /dev/pts/1 (label charserial0) audio: Device pcspk: audiodev default parameter is deprecated, please specify audiodev=audio0 audio: Device hda: audiodev default parameter is deprecated, please specify audiodev=audio0 pulseaudio: pa_stream_peek failed pulseaudio: Reason: Bad state pulseaudio: pa_stream_peek failed pulseaudio: Reason: Bad state Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200104091122.13971-5-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-01-06paaudio: try to drain the recording streamVolker Rümelin1-16/+25
There is no guarantee a single call to pa_stream_peek every timer_period microseconds can read a recording stream faster than the data gets produced at the source. Let qpa_read try to drain the recording stream. To reproduce the problem: Start qemu with -audiodev pa,id=audio0,in.mixing-engine=off On the host connect the qemu recording stream to the monitor of a hardware output device. While the problem can also be seen with a hardware input device, it's obvious with the monitor of a hardware output device. In the guest start audio recording with audacity and notice the slow recording data rate. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200104091122.13971-4-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2020-01-06paaudio: drop recording stream in qpa_fini_inVolker Rümelin1-4/+18
Every call to pa_stream_peek which returns a data length > 0 should have a corresponding pa_stream_drop. A call to qpa_read does not necessarily call pa_stream_drop immediately after a call to pa_stream_peek. Test in qpa_fini_in if a last pa_stream_drop is needed. This prevents following messages in the libvirt log file after a recording stream gets closed and a new one opened. pulseaudio: pa_stream_drop failed pulseaudio: Reason: Bad state pulseaudio: pa_stream_drop failed pulseaudio: Reason: Bad state To reproduce start qemu with -audiodev pa,id=audio0,in.mixing-engine=off and in the guest start and stop Audacity several times. Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Message-id: 20200104091122.13971-3-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-26audio: fix missing breakPaolo Bonzini1-0/+1
Reported by Coverity (CID 1406449). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2019-10-18paaudio: fix channel order for usb-audio 5.1 and 7.1 streamsKővágó, Zoltán1-5/+45
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 2900e462d27bd73277ae083d037c32b1b4451ee2.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18audio: support more than two channels in volume settingKővágó, Zoltán1-8/+12
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>
2019-10-18paaudio: get/put_buffer functionsKővágó, Zoltán1-0/+83
This lets us avoid some buffer copying when using mixeng. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: d03d30138b9b5a9681cc90cbfbfec0a197cac88c.1570996490.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18audio: paaudio: ability to specify stream nameKővágó, Zoltán1-2/+2
This can be used to identify stream in tools like pavucontrol when one creates multiple -audiodevs or runs multiple qemu instances. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Acked-by: Markus Armbruster <armbru@redhat.com> Message-id: 2d6e337c474ac84172d0809e6959c26b21d48120.1568157545.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-10-18audio: paaudio: fix connection and stream nameKővágó, Zoltán1-3/+6
Connection name was previously erroneously set to the server socket path, while connection names were simply "qemu". After this patch, the connection name will be the vm name (falling back to "qemu" if not specified), while stream names will be the audiodev's id. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 3d139426031a400a68d440608ba5e43f0e116cd8.1568157545.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-09-23audio: split ctl_* functions into enable_* and volume_*Kővágó, Zoltán1-83/+56
This way we no longer need vararg functions, improving compile time error detection. Also now it's possible to check actually what commands are supported, without needing to manually update ctl_caps. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 2b08b3773569c5be055d0a0fb2f29ff64e79f0f4.1568927990.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-09-23paaudio: port to the new audio backend apiKővágó, Zoltán1-327/+45
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 21fe8f2cf949039c8c40a0352590c593b104917d.1568927990.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21audio: use size_t where makes senseKővágó, Zoltán1-22/+22
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: c5193e687fc6cc0f60cb3e90fe69ddf2027d0df1.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21audio: remove read and write pcm_opsKővágó, Zoltán1-12/+0
They just called audio_pcm_sw_read/write anyway, so it makes no sense to have them too. (The noaudio's read is the only exception, but it should work with the generic code too.) Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: 92ddc98133bc4b687c6e4608b9321e7b64c0e496.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21paaudio: fix playback glitchesKővágó, Zoltán1-4/+2
Pulseaudio normally assumes that when the server wants it, the client can generate the audio samples and send it right away. Unfortunately this is not the case with QEMU -- it's up to the emulated system when does it generate the samples. Buffering the samples and sending them from a background thread is just a workaround, that doesn't work too well. Instead enable pa's compatibility support and let pa worry about the details. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: aa4e3613122ccbaa62b1feb4e427260731f7477c.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21audio: remove audio_MIN, audio_MAXKővágó, Zoltán1-6/+6
There's already a MIN and MAX macro in include/qemu/osdep.h, use them instead. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 303222477df6f7373217e0df768635fab5855745.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21paaudio: properly disconnect streams in fini_*Kővágó, Zoltán1-2/+23
Currently this needs a workaround due to bug #247 in pulseaudio. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: c81019d550d9c3518185d3d08bd463ae3ccdc392.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21paaudio: do not move stream when sink/source name is specifiedKővágó, Zoltán1-0/+5
Unless we disable stream moving, pulseaudio can easily move the stream on connect, effectively ignoring the source/sink specified by the user. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: c245929463e6e46a48b2875a150815e2ccba11b4.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-08-21paaudio: prepare for multiple audiodevKővágó, Zoltán1-136/+183
Have a pool of refcounted connections per server, so if the user creates multiple audiodevs to the same pa server, it will use a single connection. (It will still create different streams, so the user can manage those streams separately in pulseaudio.) Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: d43218f327c62cdbd16ea0c922612025fbc4805e.1566168923.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-07-03fix microphone lag with PAMartin Schrodt1-1/+1
Several people have reported to have bag microphone lag with the PA backend. While I cannot reproduce the problem here, it seems that their PA somehow decides to buffer the microphone input for way too long, causing this delay. This patch sets an upper limit to the amount of data PA should hold. This fixes the problem reliably on their side, while having no adverse effects on mine. Signed-off-by: Martin Schrodt <martin@schrodt.org> Message-id: 20190615153852.99040-1-martin@schrodt.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-06-12Include qemu/module.h where needed, drop it from qemu-common.hMarkus Armbruster1-1/+2
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20190523143508.25387-4-armbru@redhat.com> [Rebased with conflicts resolved automatically, except for hw/usb/dev-hub.c hw/misc/exynos4210_rng.c hw/misc/bcm2835_rng.c hw/misc/aspeed_scu.c hw/display/virtio-vga.c hw/arm/stm32f205_soc.c; ui/cocoa.m fixed up]
2019-03-18audio/paaudio: fix microphone input being unusableMartin Schrodt1-1/+7
The current code does not specify the metrics of the buffers for the input device. This makes PulseAudio choose very bad defaults, which causes input to be unusable: Audio put in gets out 30 seconds later. This patch fixes that and makes the latency configurable as well. Signed-off-by: Martin Schrodt <martin@schrodt.org> Message-id: 20190315084653.120020-4-martin@schrodt.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-18audio/paaudio: prolong and make latency configurableMartin Schrodt1-6/+6
The latency of a connection to the PulseAudio server is determined by the tlength parameter. This was hardcoded to 10ms, which is a bit too tight on my machine, causing audio on host and guest to malfunction. A setting of 15ms works fine here. To allow tweaking, I also made the setting configurable via the new -audiodev config. This allows to squeeze out better timings in scenarios where the emulation allows it. I also removed setting of the minreq parameter to (seemingly arbitrary) half the latency, since it showed worse audio quality during my tests. Allowing PulseAudio to request smaller chunks helped. Signed-off-by: Martin Schrodt <martin@schrodt.org> Message-id: 20190315084653.120020-3-martin@schrodt.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-18audio/paaudio: fix ignored buffer_length settingMartin Schrodt1-3/+21
Audiodev configuration allows to set the length of the buffered data. The setting was ignored and a constant value used instead. This patch makes the code apply the setting properly, and uses the previous default if nothing is supplied. Signed-off-by: Martin Schrodt <martin@schrodt.org> Message-id: 20190315084653.120020-2-martin@schrodt.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-11paaudio: port to -audiodev configKővágó, Zoltán1-52/+29
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: c74dc9c282075fba6928c40b2deae057fa0d4049.1552083282.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-11audio: -audiodev command line option basic implementationKővágó, Zoltán1-1/+1
Audio drivers now get an Audiodev * as config paramters, instead of the global audio_option structs. There is some code in audio/audio_legacy.c that converts the old environment variables to audiodev options (this way backends do not have to worry about legacy options). It also contains a replacement of -audio-help, which prints out the equivalent -audiodev based config of the currently specified environment variables. Note that backends are not updated and still rely on environment variables. Also note that (due to moving try-poll from global to backend specific option) currently ALSA and OSS will always try poll mode, regardless of environment variables or -audiodev options. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Message-id: e99a7cbdac0d13512743880660b2032024703e4c.1552083282.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-03-11audio: use qapi AudioFormat instead of audfmt_eKővágó, Zoltán1-14/+14
I had to include an enum for audio sampling formats into qapi, but that meant duplicating the audfmt_e enum. This patch replaces audfmt_e and associated values with the qapi generated AudioFormat enum. This patch is mostly a search-and-replace, except for switches where the qapi generated AUDIO_FORMAT_MAX caused problems. Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-id: 01251b2758a1679c66842120b77c0fb46d7d0eaf.1552083282.git.DirtY.iCE.hu@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2019-01-24audio: check for pulseaudio daemon pidfileGerd Hoffmann1-0/+15
Check whenever the pulseaudio daemon pidfile is present before trying to initialize the pulseaudio backend. Just return NULL if that is not the case, so qemu will check the next backend in line. In case the user explicitly configured a non-default pulseaudio server skip the check. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20190124112055.547-5-kraxel@redhat.com
2018-11-12pulseaudio: process audio data in smaller chunksGerd Hoffmann1-2/+2
The rate of pulseaudio absorbing the audio stream is used to control the the rate of the guests audio stream. When the emulated hardware uses small chunks (like intel-hda does) we need small chunks on the audio backend side too, otherwise that feedback loop doesn't work very well. Cc: Max Ehrlich <maxehr@umiacs.umd.edu> Cc: Martin Schrodt <martin@schrodt.org> Buglink: https://bugs.launchpad.net/bugs/1795527 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20181109142032.1628-1-kraxel@redhat.com
2018-03-12audio: add driver registryGerd Hoffmann1-1/+7
Add registry for audio drivers, using the existing audio_driver struct. Make all drivers register themself. The old list of audio_driver struct pointers is now a list of audio driver names, specifying the priority (aka probe order) in case no driver is explicitly asked for. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 20180306074053.22856-2-kraxel@redhat.com
2018-02-06audio: Replace AUDIO_FUNC with __func__Alistair Francis1-28/+28
Apparently we don't use __MSC_VER as a compiler anymore and we always require a C99 compiler (which means we always have __func__) so we don't need a special AUDIO_FUNC macro. We can just replace AUDIO_FUNC with __func__ instead. Checkpatch failures were manually fixed. Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20180203084315.20497-2-armbru@redhat.com>