device: virtio: snd: Call release_worker in prepare

Since VIRTIO_SND_R_PCM_PREPARE -> VIRTIO_SND_R_PCM_PREPARE is a valid
transition, we need to release the worker if it's already in
VIRTIO_SND_R_PCM_PREPARE state. Or we could trigger

```
Error in handling tx queue: Error in mpsc: send failed because receiver is gone
```

in handle_pcm_queue while sending `desc_chain` to start_pcm_worker
through the `stream_info.sender()`.

BUG=b:202368198
TEST=Run alsa_conformance_test multiple times

Change-Id: I5f8ee370832ee162fdef71d396dfe848d88af7e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317328
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
Chih-Yang Hsia 2021-12-06 22:21:00 +08:00 committed by Commit Bot
parent c6d01914de
commit 049746fb8a

View file

@ -270,6 +270,9 @@ impl<'a> StreamInfo<'a> {
); );
return Err(Error::OperationNotSupported); return Err(Error::OperationNotSupported);
} }
if self.state == VIRTIO_SND_R_PCM_PREPARE {
self.release_worker().await?;
}
let frame_size = self.channels as usize * self.format.sample_bytes(); let frame_size = self.channels as usize * self.format.sample_bytes();
if self.period_bytes % frame_size != 0 { if self.period_bytes % frame_size != 0 {
error!("period_bytes must be divisible by frame size"); error!("period_bytes must be divisible by frame size");