diff options
author | Fletcher Woodruff <fletcherw@chromium.org> | 2019-08-12 11:46:47 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-28 01:07:56 +0000 |
commit | 7eae7735ee3485605d2ec7ba0685588b7a38b37b (patch) | |
tree | a2055a77649a489624b7b5b4dfbf08607655b9cf /devices/src/pci/ac97.rs | |
parent | 020fbf04c2ac112f34b87306b5fbb75e7a02a81a (diff) | |
download | crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.tar crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.tar.gz crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.tar.bz2 crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.tar.lz crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.tar.xz crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.tar.zst crosvm-7eae7735ee3485605d2ec7ba0685588b7a38b37b.zip |
ac97: switch to ShmStreamSource
Convert playback and capture for the AC97 device to use the zero-copy ShmStreamSource instead of the old StreamSource. In the process, rework start_playback and start_capture unit tests so they rely less on sleep statements. BUG=chromium:968724 BUG=chromium:1006035 TEST="sox -n -r 48000 -b 16 output.raw synth 5 sine 330 && aplay -f dat output.raw" within a VM, check that sine wave is played accurately. Change-Id: Ie9cddbc5285a9505872c9951a8a1da01de70eb88 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1749950 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Diffstat (limited to 'devices/src/pci/ac97.rs')
-rw-r--r-- | devices/src/pci/ac97.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/devices/src/pci/ac97.rs b/devices/src/pci/ac97.rs index eb19b5f..792df24 100644 --- a/devices/src/pci/ac97.rs +++ b/devices/src/pci/ac97.rs @@ -4,7 +4,7 @@ use std::os::unix::io::RawFd; -use audio_streams::StreamSource; +use audio_streams::shm_streams::ShmStreamSource; use resources::{Alloc, MmioType, SystemAllocator}; use sys_util::{error, EventFd, GuestMemory}; @@ -39,7 +39,7 @@ pub struct Ac97Dev { impl Ac97Dev { /// Creates an 'Ac97Dev' that uses the given `GuestMemory` and starts with all registers at /// default values. - pub fn new(mem: GuestMemory, audio_server: Box<dyn StreamSource>) -> Self { + pub fn new(mem: GuestMemory, audio_server: Box<dyn ShmStreamSource>) -> Self { let config_regs = PciConfiguration::new( 0x8086, PCI_DEVICE_ID_INTEL_82801AA_5, @@ -236,13 +236,13 @@ impl PciDevice for Ac97Dev { #[cfg(test)] mod tests { use super::*; - use audio_streams::DummyStreamSource; + use audio_streams::shm_streams::MockShmStreamSource; use sys_util::GuestAddress; #[test] fn create() { let mem = GuestMemory::new(&[(GuestAddress(0u64), 4 * 1024 * 1024)]).unwrap(); - let mut ac97_dev = Ac97Dev::new(mem, Box::new(DummyStreamSource::new())); + let mut ac97_dev = Ac97Dev::new(mem, Box::new(MockShmStreamSource::new())); let mut allocator = SystemAllocator::builder() .add_io_addresses(0x1000_0000, 0x1000_0000) .add_low_mmio_addresses(0x2000_0000, 0x1000_0000) |