@samitouri / QOSamiQemu / commits / 727451eadb

audio: require spice >= 0.15

Spice server 0.15.0 was released on 2021-04-16. It is part of all our supported distro (except CentOS 9, which doesn't include it). It has all the new required audio APIs/interfaces. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Link: https://lore.kernel.org/r/20260211-cleanups-v1-5-e63c96572389@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Marc-André Lureau committed Feb 11, 2026 at 14:01 UTC 727451eadb8e16d4437489c7329eac7ad894c3ad
1 file changed -30
audio/spiceaudio.c
-30
@@ -49,17 +49,8 @@ static bool spice_audio_realize(AudioBackend *abe, Audiodev *dev, Error **errp)
49 return audio_spice_parent_class->realize(abe, dev, errp);
50 }
51
52 -#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
52 #define LINE_OUT_SAMPLES (480 * 4)
54 -#else
55 -#define LINE_OUT_SAMPLES (256 * 4)
56 -#endif
57 -
58 -#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
53 #define LINE_IN_SAMPLES (480 * 4)
60 -#else
61 -#define LINE_IN_SAMPLES (256 * 4)
62 -#endif
54
55 typedef struct SpiceVoiceOut {
56 HWVoiceOut hw;
@@ -99,11 +90,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as)
90 SpiceVoiceOut *out = container_of (hw, SpiceVoiceOut, hw);
91 struct audsettings settings;
92
102 -#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
93 settings.freq = spice_server_get_best_playback_rate(NULL);
104 -#else
105 - settings.freq = SPICE_INTERFACE_PLAYBACK_FREQ;
106 -#endif
94 settings.nchannels = SPICE_INTERFACE_PLAYBACK_CHAN;
95 settings.fmt = AUDIO_FORMAT_S16;
96 settings.big_endian = HOST_BIG_ENDIAN;
@@ -114,9 +101,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as)
101
102 out->sin.base.sif = &playback_sif.base;
103 qemu_spice.add_interface(&out->sin.base);
117 -#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
104 spice_server_set_playback_rate(&out->sin, settings.freq);
119 -#endif
105 return 0;
106 }
107
@@ -194,7 +179,6 @@ static void line_out_enable(HWVoiceOut *hw, bool enable)
179 }
180 }
181
197 -#if ((SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && (SPICE_INTERFACE_PLAYBACK_MINOR >= 2))
182 static void line_out_volume(HWVoiceOut *hw, Volume *vol)
183 {
184 SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
@@ -206,7 +190,6 @@ static void line_out_volume(HWVoiceOut *hw, Volume *vol)
190 spice_server_playback_set_volume(&out->sin, 2, svol);
191 spice_server_playback_set_mute(&out->sin, vol->mute);
192 }
209 -#endif
193
194 /* record */
195
@@ -215,11 +198,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as)
198 SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw);
199 struct audsettings settings;
200
218 -#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
201 settings.freq = spice_server_get_best_record_rate(NULL);
220 -#else
221 - settings.freq = SPICE_INTERFACE_RECORD_FREQ;
222 -#endif
202 settings.nchannels = SPICE_INTERFACE_RECORD_CHAN;
203 settings.fmt = AUDIO_FORMAT_S16;
204 settings.big_endian = HOST_BIG_ENDIAN;
@@ -230,9 +209,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as)
209
210 in->sin.base.sif = &record_sif.base;
211 qemu_spice.add_interface(&in->sin.base);
233 -#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
212 spice_server_set_record_rate(&in->sin, settings.freq);
235 -#endif
213 return 0;
214 }
215
@@ -281,7 +258,6 @@ static void line_in_enable(HWVoiceIn *hw, bool enable)
258 }
259 }
260
284 -#if ((SPICE_INTERFACE_RECORD_MAJOR >= 2) && (SPICE_INTERFACE_RECORD_MINOR >= 2))
261 static void line_in_volume(HWVoiceIn *hw, Volume *vol)
262 {
263 SpiceVoiceIn *in = container_of(hw, SpiceVoiceIn, hw);
@@ -293,7 +269,6 @@ static void line_in_volume(HWVoiceIn *hw, Volume *vol)
269 spice_server_record_set_volume(&in->sin, 2, svol);
270 spice_server_record_set_mute(&in->sin, vol->mute);
271 }
296 -#endif
272
273 static void audio_spice_class_init(ObjectClass *klass, const void *data)
274 {
@@ -315,19 +290,14 @@ static void audio_spice_class_init(ObjectClass *klass, const void *data)
290 k->get_buffer_out = line_out_get_buffer;
291 k->put_buffer_out = line_out_put_buffer;
292 k->enable_out = line_out_enable;
318 -#if (SPICE_INTERFACE_PLAYBACK_MAJOR >= 1) && \
319 - (SPICE_INTERFACE_PLAYBACK_MINOR >= 2)
293 k->volume_out = line_out_volume;
321 -#endif
294
295 k->init_in = line_in_init;
296 k->fini_in = line_in_fini;
297 k->read = line_in_read;
298 k->run_buffer_in = audio_generic_run_buffer_in;
299 k->enable_in = line_in_enable;
328 -#if ((SPICE_INTERFACE_RECORD_MAJOR >= 2) && (SPICE_INTERFACE_RECORD_MINOR >= 2))
300 k->volume_in = line_in_volume;
330 -#endif
301 }
302
303 static const TypeInfo audio_types[] = {