The compiler already infers the correct types without the extra
&(ref ..., ref ...), so just drop them.
Fixes clippy lints in Rust 1.68.
BUG=b:276487055
TEST=tools/clippy # with rust 1.68
Change-Id: I0947d653c80e7c7a5a561d2970ecae24a3700adf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4390736
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This is supported since Rust 1.62.
Fixes the new derivable_impls clippy lint, added in Rust 1.67.
BUG=b:276487055
TEST=tools/clippy # with rust 1.68
Change-Id: I3696dd3cf4acbf9b5a2cfa8c2046e7656e13dbbd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4390735
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add latency_bytes to the AsyncBufferCommit and the BufferCommit trait
to allow virtio sound device to report the audio latency from the
virtio_snd_pcm_status.
BUG=b:269989582
TEST=play Audio Video Sync Test video from the ARCVM youtube app.
Change-Id: I9415933ed1bd8e3b326fe2c5c73a835ed96dff02
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4273577
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
This CL is to prepare for parsing virtio-snd parameters from cmdline
argument to StreamEffect with serde_keyvalue. Deserialize will be used
when parsing from cmdline. Serialize will be used when we store
StreamEffect inside Parameters struct as the whole struct must be
serializable.
BUG=b:269984052
TEST=cargo check
Change-Id: Ica2169f395f53a4884d407c07fedff16d13cbedd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4273570
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.
BUG=None
TEST=tools/cargo-doc
Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add default implementation for wait_fd_readable to help with uprev
process with older package of cros_async.
BUG=b:258759773
TEST=emerge audio_streams
Change-Id: I494ac8615e4d73a0cceaf4c2e1beb6e04e9eedc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4086627
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Add async_new_async_{playback,capture}_stream to StreamSource trait.
These methods are used to create new async playback or capture stream
asynchronously. Default implementation is to call their sync version.
cros_async: Add wait_fd_readable to AudioStreamsExecutor trait, this
will be used by libcras to implement the new async_new_async_*_stream
method.
BUG=b:258759773
TEST=emerge audio_streams cros_async
TEST=FEATURES=test emerge-amd64-generic audio_streams
Change-Id: I8dfc743eb8fa6552a1a6b2953b79666e2909e417
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4066242
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
The most notable changes are:
* Playback Async support
* Audio Client flags to hide app from SndVol when audio session has
expired
* Updates to audio_streams and cros_async crates for playback async
support
BUG=b:256655413
TEST=Verified to work downstream
Change-Id: Ifbe9a15791feaa41d6e1d5eaf2c5824b2c7c25b8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3994882
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
This greatly simplifies and speeds up compilation
and clippy times.
This ChromeOS-side building these crates has been
updated to copy the source out of the source tree
so that they will compile as a separate workspace.
BUG=b:256020427
TEST=presubmit
Change-Id: I2e0f1f6724924d6bdd70ea28d7777df7966cf724
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988324
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)
This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:
/*
* Example comment block
*/ <-- this line
Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.
This fulfills the request from legal and unifies our notices.
./tools/health-check has been updated to only accept this style.
BUG=b:246579983
TEST=./tools/health-check
Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
The first version of audio_streams_conformance_test.
It is used to test if the implementation of
audio_streams::AsyncPlaybackBufferStream is correct.
This version only supports the playback test of NoopStream.
It prints the following information for NoopStream.
==
Playback Source: NoopStream
Channels: 2
Format: S16LE
Sample rate: 48000 frames/s
Buffer size: 240 frames
Iterations: 10
Cold start latency: 3.89µs
Records count: 10
[Step] min: 4.94 ms, max: 5.15 ms, average: 5.01 ms,
standard deviation: 0.06 ms.
[Linear Regression] rate: 47916.19 frames/s, standard error: 2.0
BUG=b:238038707
TEST=cargo run
Change-Id: Ifca7dfd35473ffd75856a27e2c6aa1555eba7576
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3805090
Tested-by: Judy Hsiao <judyhsiao@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
We originally removed it because we had frequent merge conflicts
and all downstream projects were doing their own pinning already.
We also had CI issues because ChromeOS changes could trigger
Cargo.lock changes in crosvm back then.
The new Cargo.lock format should ease the merge conflicts and we
no longer have issues with external changes triggering changes
in our Cargo.lock. So let's bring it back in.
This will allow us to judge the impact of changing third party
dependencies and gives us a chance to implement a special
review process.
BUG=b:240435583
TEST=CQ
Change-Id: Ie53e5616cc98d7e50a84f3c0a91902dd539f2520
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3795655
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
- Remove trailing ::{self} on all use statements
- Remove any resulting single-level use statements (e.g. use libc;)
- Reformat with `tools/fmt --nightly`
BUG=b:239937122
TEST=tools/dev_container tools/presubmit --all
Change-Id: I8afd1b0458ca6d08d9b41a24583f7d4148597ccb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3798973
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.
Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.
BUG=b:239937122
TEST=CQ
Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.
The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.
A few remaining references to sys_util have been updated to base.
BUG=b:227226222,b:229016539
TEST=presubmit
Change-Id: I7a711044de7e067b217287f2bac822d6ac7d3964
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593852
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
sys_util is only used to have a SharedMemory instance to run test.
This commit replaces that with a mock implementation.
BUG=b:229114164
TEST=presubmit
Change-Id: I6268f36dd3d986422090b1d2506ba55896cbca62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593851
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This reverts commit aac461e25e.
Reason for revert: Breaks audio_streams portage build
Original change's description:
> Remove temporarily duplicated code from codebase
>
> This removes sys_util(_core), which moved into base::unix/common, as
> well as common/(cros_async,io_uring), which moved into the root
> directory.
>
> The only reason the code was still around is that they were still
> used in the ChromeOS codebase.
> ChromeOS has pinned the version of crosvm it uses for these libraries
> so we can go ahead and remove the code.
>
> A few remaining references to sys_util have been updated to base.
>
> BUG=b:227226222,b:229016539
> TEST=presubmit
>
> Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
> Reviewed-by: Allen Webb <allenwebb@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
Bug: b:227226222,b:229016539
Change-Id: I907279ab47718355cd57915830580929dc157f84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593846
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.
The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.
A few remaining references to sys_util have been updated to base.
BUG=b:227226222,b:229016539
TEST=presubmit
Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This script moves win_util from crosvm/common/ to crosvm/
and win_sys_util into base::windows.
The CL makes some prerequisite code changes needed to enable
building of tests after the script is applied.
BUG=b:223206469
TEST=presubmit
Change-Id: I5c1952596d3161730be3f42ce5d6cb554ab66b4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3537257
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
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>
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>
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>
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>
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>
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>
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>
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>