Commit Graph

23 Commits

Author SHA1 Message Date
Gerd Hoffmann 0e8ae611bd audio: adjust pulse to 100Hz wakeup rate
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-12-09 09:19:26 +01:00
Gerd Hoffmann 8f473dd104 fix build with pulseaudio versions older than 0.9.11
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2012-05-04 00:47:09 +04:00
Gerd Hoffmann d6c05bbf29 fix paaudio.c warnings
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2012-04-25 21:04:57 +04:00
Marc-André Lureau 6e7a7f3d9b Allow controlling volume with PulseAudio backend
Signed-off-by: Marc-Andr? Lureau <marcandre.lureau@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2012-04-17 16:57:58 +04:00
Marc-André Lureau ea9ebc2ce6 Do not use pa_simple PulseAudio API
Unfortunately, pa_simple is a limited API which doesn't let us
retrieve the associated pa_stream. It is needed to control the volume
of the stream.

In v4:
- add missing braces

Signed-off-by: Marc-Andr? Lureau <marcandre.lureau@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2012-04-17 16:57:58 +04:00
Anthony Liguori 7267c0947d Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-20 23:01:08 -05:00
Gerd Hoffmann bf1064b587 pulseaudio: tweak config
Zap unused divisor field.
Raise the buffer size default.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2011-01-25 19:56:53 +03:00
Gerd Hoffmann e6d16fa439 pulseaudio: setup buffer attrs
Request reasonable buffer sizes from pulseaudio.  Without this
pa_simple_write() can block quite long and lead to dropouts,
especially with guests which use small audio ring buffers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2011-01-25 19:56:47 +03:00
Gerd Hoffmann 6315633b25 pulseaudio: process 1/4 buffer max at once
Limit the size of data pieces processed by the pulseaudio worker
threads.  Never ever process more than 1/4 of the buffer at once.

Background: The buffer area currently processed by the pulseaudio thread
is blocked, i.e. the main thread (or iothread) can't fill in more data
there.  The buffer processing time is roughly real-time due to the
pa_simple_write() call blocking when the output queue to the pulse
server is full.  Thus processing big chunks at once means blocking
a large part of the buffer for a long time.  This brings high latency
and can lead to dropouts.

When processing the buffer in smaller chunks the rpos handling becomes a
problem though.  The thread reads hw->rpos without knowing whenever
qpa_run_out has already seen the last (small) chunk processed and
updated rpos accordingly.  There is no point in reading hw->rpos though,
pa->rpos can be used instead.  We just need to take care to initialize
pa->rpos before kicking the thread.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2011-01-25 19:56:35 +03:00
Michael Walle 00e076795f audio: split sample conversion and volume mixing
Refactor the volume mixing, so it can be reused for capturing devices.
Additionally, it removes superfluous multiplications with the nominal
volume within the hardware voice code path.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: malc <av1474@comtv.ru>
2011-01-12 18:36:22 +03:00
Wu Fengguang fd5723b385 pulse-audio: fix bug on updating rpos
Fix a rpos coordination bug between qpa_run_out() and qpa_thread_out(),
which shows up as playback noises.

	qpa_run_out()
			qpa_thread_out loop N critical section 1
	qpa_run_out()   qpa_thread_out loop N doing pa_simple_write()
	qpa_run_out()	qpa_thread_out loop N doing pa_simple_write()
			qpa_thread_out loop N critical section 2
			qpa_thread_out loop N+1 critical section 1
	qpa_run_out()	qpa_thread_out loop N+1 doing pa_simple_write()

In the above scheme, "qpa_thread_out loop N+1 critical section 1" will
get the same rpos as the one used by "qpa_thread_out loop N critical
section 1". So it will be reading dead samples from the old rpos.

The rpos can only be updated back to qpa_thread_out when there is a
qpa_run_out() run between two qpa_thread_out loops.

normal sequence:
	qpa_thread_out:
			hw->rpos (X0) => local rpos => pa->rpos (X1)
	qpa_run_out:
			pa->rpos (X1) => hw->rpos (X1)
	qpa_thread_out:
			hw->rpos (X1) => local rpos => pa->rpos (X2)

buggy sequence:
	qpa_thread_out:
			hw->rpos (X0) => local rpos => pa->rpos (X1)
	qpa_thread_out:
			hw->rpos (X0) => local rpos => pa->rpos (X1')

Obviously qpa_run_out() shall be called at least once between any two
qpa_thread_out loops (after pa->rpos is set), in order for the new
qpa_thread_out loop to see the updated rpos.

Setting pa->live to 0 does the trick. The next loop will have to wait
for one qpa_run_out() invocation in order to get a non-zero pa->live
and proceed.

Signed-off-by: malc <av1474@comtv.ru>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
2010-09-29 08:24:14 +04:00
Michael S. Tsirkin 1a4ea1e34d qemu: allow pulseaudio to be the default
We're seeing various issues with the SDL audio backend and want to
switch to the pulseaudio backend. See e.g.

  https://bugzilla.redhat.com/495964
  https://bugzilla.redhat.com/519540
  https://bugzilla.redhat.com/496627

The pulseaudio backend seems to work well, so we should allow it to be
selected as the default.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2009-10-13 18:14:50 +04:00
malc bdff253c8f audio: internal API change
pcm_ops.run_out now takes number of live samples (which will be always
greater than zero) as a second argument, every driver was calling
audio_pcm_hw_get_live_out anyway with exception of fmod which used
audio_pcm_hw_get_live_out2 for no good reason.

Signed-off-by: malc <av1474@comtv.ru>
2009-09-18 14:04:36 +04:00
malc 98f9f48ccb Aesthetics
Reformat to make item borders more visible
Fix cases of stray tabs and vertical misalignments

Signed-off-by: malc <av1474@comtv.ru>
2009-08-11 20:51:24 +04:00
Juan Quintela 1a40d5e235 use C99 initializers for all audio/*
Signed-off-by: Juan Quintela <quintela@redhat.com>
2009-08-11 20:51:24 +04:00
Juan Quintela 1dd3e4d13d use C99 initializers for audio_pcm_ops
Signed-off-by: Juan Quintela <quintela@redhat.com>
2009-08-11 20:51:24 +04:00
Juan Quintela 2700efa323 Use C99 initializers for audio_option
Signed-off-by: Juan Quintela <quintela@redhat.com>
2009-08-11 20:51:23 +04:00
Juan Quintela bee37f32d4 Use proper struct initializers and remove INIT_FIELD() macro
Signed-off-by: Juan Quintela <quintela@redhat.com>
2009-08-11 20:51:23 +04:00
Jean-Christophe Dubois 5d92886792 fix qemu_alloc/qemu_free for audio subsystem
Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
2009-06-19 02:46:14 +04:00
malc 1ea879e558 Make audio violate POSIX less
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5864 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-03 22:48:44 +00:00
blueswir1 35f4b58c7a Prepare for changing audio_pcm_ops dynamically (partially revert r5422)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5435 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-06 18:08:30 +00:00
blueswir1 8869defe62 Make audio_pcm_opsstatic const
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5422 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-05 10:01:05 +00:00
malc b8e59f18de Pulseaudio driver
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4827 c046a42c-6fe2-441c-8c8c-71466251a162
2008-07-02 21:03:08 +00:00