mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-30 17:49:08 +00:00
sound/pipewire: destroy pipewire streams not destroyed
The PCM command transition prepare->prepare or set_param->prepare is allowed by the specification. Pipewire, however, creates multiple streams which are not destroyed when this type of transition happens. By using this PR, we can ensure that when the prepare function in the pipewire backend is called multiple times without the release function, only one pipewire stream is created. Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
This commit is contained in:
parent
629c731e48
commit
6581834c77
@ -36,7 +36,7 @@ use spa::{
|
||||
|
||||
use super::AudioBackend;
|
||||
use crate::{
|
||||
stream::PCMState,
|
||||
stream::{Error as StreamError, PCMState},
|
||||
virtio_sound::{
|
||||
VirtioSndPcmSetParams, VIRTIO_SND_PCM_FMT_A_LAW, VIRTIO_SND_PCM_FMT_FLOAT,
|
||||
VIRTIO_SND_PCM_FMT_FLOAT64, VIRTIO_SND_PCM_FMT_MU_LAW, VIRTIO_SND_PCM_FMT_S16,
|
||||
@ -208,6 +208,14 @@ impl AudioBackend for PwBackend {
|
||||
|
||||
let params = &stream_params[stream_id as usize].params;
|
||||
|
||||
if let Some(stream) = stream_hash.remove(&stream_id) {
|
||||
stream_listener.remove(&stream_id);
|
||||
if let Err(err) = stream.disconnect() {
|
||||
log::error!("Stream {} disconnect {}", stream_id, err);
|
||||
return Err(Error::Stream(StreamError::CouldNotDisconnectStream));
|
||||
}
|
||||
}
|
||||
|
||||
let mut pos: [u32; 64] = [SPA_AUDIO_CHANNEL_UNKNOWN; 64];
|
||||
|
||||
match params.channels {
|
||||
|
||||
@ -21,6 +21,8 @@ pub enum Error {
|
||||
DescriptorReadFailed,
|
||||
#[error("Descriptor write failed")]
|
||||
DescriptorWriteFailed,
|
||||
#[error("Could not disconnect stream")]
|
||||
CouldNotDisconnectStream,
|
||||
}
|
||||
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user