diff --git a/crates/sound/src/vhu_sound.rs b/crates/sound/src/vhu_sound.rs index 8e9dbb5..b8a7bbf 100644 --- a/crates/sound/src/vhu_sound.rs +++ b/crates/sound/src/vhu_sound.rs @@ -89,30 +89,18 @@ struct VirtioSoundHeader { // reading its content from byte array. unsafe impl ByteValued for VirtioSoundHeader {} -trait VhostUserSoundThread { - fn queue_mask(&self) -> u64; - fn set_event_idx(&mut self, enabled: bool); - fn update_memory(&mut self, mem: GuestMemoryAtomic) -> IoResult<()>; - fn handle_event(&self, device_event: u16, vrings: &[VringRwLock]) -> IoResult; -} -struct VhostUserSoundSingleThread { +struct VhostUserSoundThread { mem: Option>, event_idx: bool, } -impl VhostUserSoundSingleThread { +impl VhostUserSoundThread { pub fn new() -> Result { - Ok(VhostUserSoundSingleThread { + Ok(VhostUserSoundThread { event_idx: false, mem: None, }) } -} - -impl VhostUserSoundThread for VhostUserSoundSingleThread { - fn queue_mask(&self) -> u64 { - 0xffff_ffff - } fn set_event_idx(&mut self, enabled: bool) { self.event_idx = enabled; @@ -139,7 +127,7 @@ impl VhostUserSoundThread for VhostUserSoundSingleThread { } pub(crate) struct VhostUserSoundBackend { - thread: RwLock>, + thread: RwLock, config: VirtioSoundConfig, queues_per_thread: Vec, pub(crate) exit_event: EventFd, @@ -148,10 +136,10 @@ pub(crate) struct VhostUserSoundBackend { impl VhostUserSoundBackend { pub fn new(_config: SoundConfig) -> Result { let queues_per_thread = vec![0b1111]; - let thread = Box::new(VhostUserSoundSingleThread::new()?); + let thread = RwLock::new(VhostUserSoundThread::new()?); Ok(Self { - thread: RwLock::new(thread), + thread, config: VirtioSoundConfig { jacks: 0.into(), streams: 1.into(),