crosvm/devices/src
Chih-Yang Hsia 7c97b2e7d3 devices: virtio: snd: Change start_pcm_worker to be polled by streams
Improvements:
- Once a {playback, capture} stream is initiated.
  We should start write (read) audio in each callback period or
  the underlaying audio server will underrun (overrun).
  (Even in the WorkerStatus::Pause state).

- Change the polling loop logic to

  wait for next buffer
  -> check status
  -> try_next desc_chain or exit
  -> transfer data or exit

  And make start_pcm_worker act like real audio hw device, which
  consumes data in every fixed period.

- Right before leaving from WorkerStatus::Quit, we still need to
  transfer data to/from the running stream to prevent
  underrun or overrun.

Changes:
- changes in start_pcm_worker:
  - extract read_data, write_data utils
  - implement From<Result<()>, Error> for virtio_snd_pcm_status
  - poll next_{capture, playback}_buffer
  - if status == WorkerStatus::Pause, still need to transfer data to
    prevent underrun or overrun
  - split Output and Input stream logic
- use copy_from or copy_to instead to io::copy
- remove Condvar usage
- changes in audio_streams
  - add copy_from in AudioBuffer and AsyncPlaybackBuffer
  - add copy_to in AudioBuffer and AsyncCaptureBuffer

BUG=b:210197743
TEST=alsa_conformance_test and make sure there is no
     `ERR cras_server[1818]: Error reading msg from client: rc: -104` or
     `ERR cras_server[1818]: fetch err: -32 for 6490001`
     errors.

Change-Id: I004969040881cb2d46b54589e3e7e634ea67d152
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3341135
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-15 11:28:55 +00:00
..
irqchip
pci pci_root: Emulate PCIE base address register in host bridge 2021-12-08 12:30:30 +00:00
platform
register_space
usb
utils
virtio devices: virtio: snd: Change start_pcm_worker to be polled by streams 2021-12-15 11:28:55 +00:00
acpi.rs acpi: expose PCI reset register in ACPI 2021-12-08 06:33:00 +00:00
bat.rs
bus.rs
cmos.rs
direct_io.rs crosvm: use BusRange in DirectIoOption. 2021-12-08 00:22:43 +00:00
direct_irq.rs
i8042.rs
lib.rs
pit.rs
pl030.rs
proxy.rs
serial.rs
serial_device.rs
vfio.rs devices: vfio: Add methods to read/write region at specified address 2021-12-08 16:19:48 +00:00