Commit graph

9 commits

Author SHA1 Message Date
Dennis Kempin
fd68b42b6d audio_streams: Add async interface to remove dependency on cros_async
The API allows audio_streams to be used by crosvm and libcras while
their implementations of cros_async may diverge in the future.

BUG=b:223624364
TEST=./tools/presubmit and emerge tests

Cq-Depend: chromium:3519246
Change-Id: I08b6bf12e02c211275c11f1886f23f71217e40b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3518657
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-03-15 17:29:21 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Vikram Auradkar
ae5118f5c7 Enable windows tests for a few crates
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.

Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.

The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.

RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.

Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-18 03:18:58 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Dennis Kempin
6b06f405ff docs: Use mdformat to format markdown files
The tool is added to ./tools/fmt which will be called during
./tools/presubmit as well as by Kokoro during testing.

This requires a new dev container version to bundle the mdformat
tool in the container.

Note: mdformat does not have any IDE integrations, but the prettier
plugin with prose-wrap enabled and a line length of 100 provides
almost identical results.

BUG=None
TEST=./tools/fmt --check

Change-Id: I0ae5659eff8555df7c85c70e62095a1e116b98da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-27 21:29:11 +00:00
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
Chih-Yang Hsia
34b48775ab audio_streams: Fix incorrect write impl in AudioBuffer
If frame_size is not "power of 2" (e.g. 12 bytes in 6channel/S16_LE),
current write implementation will trigger io::copy error since
- io::copy will split reader into multiple buffers with len() = "power of 2"
  if writer.capacity() >= DEFAULT_BUF_SIZE (which is 8192) and
- trigger early return since current write don't support incomplete frames
  writing.

Changes:
- Remove redundant write impl
- Fix write implementation in AudioBuffer
- Add io_copy_audio_buffer unit test

BUG=b:199001477
BUG=b:201382814
TEST=`cargo test`
TEST=`cargo clippy --all-targets --all-features -- -D warnings`
TEST=`aplay -Dhw:0,0 -f dat /dev/zeros -c 6` with virtio-snd

Change-Id: Ia6b587ab20f474d8c620b69940ca0cc7095da6db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331976
Reviewed-by: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-13 05:04:55 +00:00
Keiichi Watanabe
3893a1dcbe audio_streams: Introduce SharedMemory trait for base::SharedMemory
Define `SharedMemory` trait, implement it for `base::SharedMemory`, and
use it for `ShmStreamSource::new_stream()` so that we can pass on
`base::SharedMemory` without exposing `base` to libcras.

Note that we implement the trait for `base::SharedMemory` in `base`
crate instead of in `audio_streams`, which means `base` depends on
`audio_streams`, because `audio_streams` is available for non-crosvm
projects while `base` isn't.

The corresponding CRAS change is crrev.com/c/3251123.

BUG=b:194137301, b:204444445
TEST=cargo test --all-features

Change-Id: I2430d9881d98032592c9f9202d70deb22e006f63
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251820
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-18 08:45:14 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00