From 40a814b0b1789b94c483190b3208729b5182e5bd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 9 Oct 2013 21:38:32 +0200 Subject: audio: Lower default wakeup rate to 100 times / second This is more then plenty to keep audio card fifos filles / emptied. This drops host cpu-load for audio playback inside a linux vm from 13% to 9%. Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- audio/audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/audio.c b/audio/audio.c index b3db67979d..fc775110af 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -95,7 +95,7 @@ static struct { } }, - .period = { .hertz = 250 }, + .period = { .hertz = 100 }, .plive = 0, .log_to_monitor = 0, .try_poll_in = 1, -- cgit v1.2.3 From 0e8ae611bda0dfb038da2d865801d8adbd692bad Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 2 Dec 2013 10:49:13 +0100 Subject: audio: adjust pulse to 100Hz wakeup rate Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'audio') diff --git a/audio/paaudio.c b/audio/paaudio.c index 8b69778ad9..90ff24500b 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -547,11 +547,11 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) ss.rate = as->freq; /* - * qemu audio tick runs at 250 Hz (by default), so processing - * data chunks worth 4 ms of sound should be a good fit. + * qemu audio tick runs at 100 Hz (by default), so processing + * data chunks worth 10 ms of sound should be a good fit. */ - ba.tlength = pa_usec_to_bytes (4 * 1000, &ss); - ba.minreq = pa_usec_to_bytes (2 * 1000, &ss); + ba.tlength = pa_usec_to_bytes (10 * 1000, &ss); + ba.minreq = pa_usec_to_bytes (5 * 1000, &ss); ba.maxlength = -1; ba.prebuf = -1; -- cgit v1.2.3 From 795ca114d353e02752a29f64902215bb30c58c21 Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Thu, 2 Jan 2014 09:25:56 -0600 Subject: Add the ability to vary Spice playback and record rates, to facilitate Opus support. Signed-off-by: Jeremy White Signed-off-by: Gerd Hoffmann --- audio/spiceaudio.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'audio') diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 5af436c31d..fceee50adb 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -25,8 +25,17 @@ #include "audio.h" #include "audio_int.h" -#define LINE_IN_SAMPLES 1024 -#define LINE_OUT_SAMPLES 1024 +#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3 +#define LINE_OUT_SAMPLES (480 * 4) +#else +#define LINE_OUT_SAMPLES (256 * 4) +#endif + +#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3 +#define LINE_IN_SAMPLES (480 * 4) +#else +#define LINE_IN_SAMPLES (256 * 4) +#endif typedef struct SpiceRateCtl { int64_t start_ticks; @@ -111,7 +120,11 @@ static int line_out_init (HWVoiceOut *hw, struct audsettings *as) SpiceVoiceOut *out = container_of (hw, SpiceVoiceOut, hw); struct audsettings settings; +#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3 + settings.freq = spice_server_get_best_playback_rate(NULL); +#else settings.freq = SPICE_INTERFACE_PLAYBACK_FREQ; +#endif settings.nchannels = SPICE_INTERFACE_PLAYBACK_CHAN; settings.fmt = AUD_FMT_S16; settings.endianness = AUDIO_HOST_ENDIANNESS; @@ -122,6 +135,9 @@ static int line_out_init (HWVoiceOut *hw, struct audsettings *as) out->sin.base.sif = &playback_sif.base; qemu_spice_add_interface (&out->sin.base); +#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3 + spice_server_set_playback_rate(&out->sin, settings.freq); +#endif return 0; } @@ -232,7 +248,11 @@ static int line_in_init (HWVoiceIn *hw, struct audsettings *as) SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw); struct audsettings settings; +#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3 + settings.freq = spice_server_get_best_record_rate(NULL); +#else settings.freq = SPICE_INTERFACE_RECORD_FREQ; +#endif settings.nchannels = SPICE_INTERFACE_RECORD_CHAN; settings.fmt = AUD_FMT_S16; settings.endianness = AUDIO_HOST_ENDIANNESS; @@ -243,6 +263,9 @@ static int line_in_init (HWVoiceIn *hw, struct audsettings *as) in->sin.base.sif = &record_sif.base; qemu_spice_add_interface (&in->sin.base); +#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3 + spice_server_set_record_rate(&in->sin, settings.freq); +#endif return 0; } -- cgit v1.2.3