sound/alsa: Release buffers even on RELEASE err

If a PCM_RELEASE control request comes from the guest and the state
transition is invalid by spec standards, release the buffers anyway.
This doesn't change the current behavior.

When dealing with an unrelated vhost-user issue, the state transitions
became invalid because of unexpected errors in the virto-snd driver.
Making this change made the issue obvious while debugging. Plus, the
spec does not state rejecting a PCM lifecycle control request if the
transition is not possible. (The possible state transitions are
non-normative statements.)

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
Manos Pitsidianakis 2023-10-04 11:52:33 +03:00 committed by Alex Bennée
parent 3921238555
commit 33c977cc0f

View File

@ -425,15 +425,13 @@ impl AlsaBackend {
msg.code = VIRTIO_SND_S_BAD_MSG;
continue;
};
let release_result = streams.write().unwrap()[stream_id].state.release();
if let Err(err) = release_result {
if let Err(err) = streams.write().unwrap()[stream_id].state.release() {
log::error!("Stream {} release {}", stream_id, err);
msg.code = VIRTIO_SND_S_BAD_MSG;
} else {
senders[stream_id].send(false).unwrap();
let mut streams = streams.write().unwrap();
std::mem::take(&mut streams[stream_id].buffers);
}
senders[stream_id].send(false).unwrap();
let mut streams = streams.write().unwrap();
std::mem::take(&mut streams[stream_id].buffers);
}
AlsaAction::SetParameters(stream_id, mut msg) => {
if stream_id >= streams_no {