From 8e7b7109316e1027548bc91cfcbb4b096b032c24 Mon Sep 17 00:00:00 2001 From: Dorinda Bassey Date: Fri, 7 Feb 2025 09:57:20 +0100 Subject: [PATCH] vhost-device-sound: Add controls field in VirtioSoundConfig This commit introduces a new controls field in VirtioSoundConfig to represent the total number of available control elements. It's based on the recent changes to the virtio-snd header file in QEMU. Fixes this issue: https://gitlab.com/qemu-project/qemu/-/issues/2805 Signed-off-by: Dorinda Bassey --- vhost-device-sound/CHANGELOG.md | 1 + vhost-device-sound/src/device.rs | 1 + vhost-device-sound/src/virtio_sound.rs | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vhost-device-sound/CHANGELOG.md b/vhost-device-sound/CHANGELOG.md index 1394bab..15ce864 100644 --- a/vhost-device-sound/CHANGELOG.md +++ b/vhost-device-sound/CHANGELOG.md @@ -3,6 +3,7 @@ ### Added +- [[#806]](https://github.com/rust-vmm/vhost-device/pull/806) Add controls field in VirtioSoundConfig - [[#746]](https://github.com/rust-vmm/vhost-device/pull/746) Add new sampling rates 12000Hz and 24000Hz ### Changed diff --git a/vhost-device-sound/src/device.rs b/vhost-device-sound/src/device.rs index 3d7db21..f2e3abb 100644 --- a/vhost-device-sound/src/device.rs +++ b/vhost-device-sound/src/device.rs @@ -573,6 +573,7 @@ impl VhostUserSoundBackend { jacks: 0.into(), streams: Le32::from(streams_no as u32), chmaps: 1.into(), + controls: 0.into(), }, exit_event: EventFd::new(EFD_NONBLOCK).map_err(Error::EventFdCreate)?, audio_backend: RwLock::new(audio_backend), diff --git a/vhost-device-sound/src/virtio_sound.rs b/vhost-device-sound/src/virtio_sound.rs index 8ddca68..8801805 100644 --- a/vhost-device-sound/src/virtio_sound.rs +++ b/vhost-device-sound/src/virtio_sound.rs @@ -163,6 +163,8 @@ pub struct VirtioSoundConfig { pub streams: Le32, /// total number of all available channel maps pub chmaps: Le32, + /// total number of all available control elements + pub controls: Le32, } // SAFETY: The layout of the structure is fixed and can be initialized by @@ -350,8 +352,9 @@ mod tests { let val = VirtioSoundConfig::default(); let debug_output = format!("{:?}", val); - let expected_debug = - "VirtioSoundConfig { jacks: Le32(0), streams: Le32(0), chmaps: Le32(0) }".to_string(); + let expected_debug = "VirtioSoundConfig { jacks: Le32(0), streams: Le32(0), chmaps: \ + Le32(0), controls: Le32(0) }" + .to_string(); assert_eq!(debug_output, expected_debug); let val = VirtioSoundHeader::default();