Commit Graph

63 Commits

Author SHA1 Message Date
Matias Ezequiel Vara Larsen
a48138f8cd sound: skip musl builds
Disable builds for musl, where alsa-sys and pipewire build fail on
rust-vmm-container due to missing tools and headers. Alsa and Pipewire
backends are available only on gnu.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2024-01-02 15:54:13 +01:00
dependabot[bot]
5e42f296cb build(deps): bump the vhost-device group in /staging with 16 updates
Bumps the vhost-device group in /staging with 16 updates:

| Package | From | To |
| --- | --- | --- |
| [clap](https://github.com/clap-rs/clap) | `4.4.11` | `4.4.12` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.51` | `1.0.53` |
| [tempfile](https://github.com/Stebalien/tempfile) | `3.8.1` | `3.9.0` |
| [futures-executor](https://github.com/rust-lang/futures-rs) | `0.3.29` | `0.3.30` |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.75` | `1.0.78` |
| [clang-sys](https://github.com/KyleMayes/clang-sys) | `1.6.1` | `1.7.0` |
| [futures](https://github.com/rust-lang/futures-rs) | `0.3.29` | `0.3.30` |
| [is-terminal](https://github.com/sunfishcode/is-terminal) | `0.4.9` | `0.4.10` |
| [memchr](https://github.com/BurntSushi/memchr) | `2.6.4` | `2.7.1` |
| [pkg-config](https://github.com/rust-lang/pkg-config-rs) | `0.3.27` | `0.3.28` |
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | `1.0.70` | `1.0.73` |
| [quote](https://github.com/dtolnay/quote) | `1.0.33` | `1.0.34` |
| [relative-path](https://github.com/udoprog/relative-path) | `1.9.0` | `1.9.2` |
| [serde_spanned](https://github.com/toml-rs/toml) | `0.6.4` | `0.6.5` |
| [syn](https://github.com/dtolnay/syn) | `2.0.41` | `2.0.44` |
| [winnow](https://github.com/winnow-rs/winnow) | `0.5.28` | `0.5.31` |


Updates `clap` from 4.4.11 to 4.4.12
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.4.11...v4.4.12)

Updates `thiserror` from 1.0.51 to 1.0.53
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.51...1.0.53)

Updates `tempfile` from 3.8.1 to 3.9.0
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.8.1...v3.9.0)

Updates `futures-executor` from 0.3.29 to 0.3.30
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.29...0.3.30)

Updates `anyhow` from 1.0.75 to 1.0.78
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.75...1.0.78)

Updates `clang-sys` from 1.6.1 to 1.7.0
- [Release notes](https://github.com/KyleMayes/clang-sys/releases)
- [Changelog](https://github.com/KyleMayes/clang-sys/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KyleMayes/clang-sys/compare/v1.6.1...v1.7.0)

Updates `futures` from 0.3.29 to 0.3.30
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.29...0.3.30)

Updates `is-terminal` from 0.4.9 to 0.4.10
- [Commits](https://github.com/sunfishcode/is-terminal/compare/v0.4.9...v0.4.10)

Updates `memchr` from 2.6.4 to 2.7.1
- [Commits](https://github.com/BurntSushi/memchr/compare/2.6.4...2.7.1)

Updates `pkg-config` from 0.3.27 to 0.3.28
- [Changelog](https://github.com/rust-lang/pkg-config-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/pkg-config-rs/compare/0.3.27...0.3.28)

Updates `proc-macro2` from 1.0.70 to 1.0.73
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.70...1.0.73)

Updates `quote` from 1.0.33 to 1.0.34
- [Release notes](https://github.com/dtolnay/quote/releases)
- [Commits](https://github.com/dtolnay/quote/compare/1.0.33...1.0.34)

Updates `relative-path` from 1.9.0 to 1.9.2
- [Release notes](https://github.com/udoprog/relative-path/releases)
- [Commits](https://github.com/udoprog/relative-path/commits)

Updates `serde_spanned` from 0.6.4 to 0.6.5
- [Commits](https://github.com/toml-rs/toml/compare/serde_spanned-v0.6.4...serde_spanned-v0.6.5)

Updates `syn` from 2.0.41 to 2.0.44
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.41...2.0.44)

Updates `winnow` from 0.5.28 to 0.5.31
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v0.5.28...v0.5.31)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: futures-executor
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: anyhow
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: clang-sys
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: futures
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: is-terminal
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: memchr
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: pkg-config
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: proc-macro2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: quote
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: relative-path
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: serde_spanned
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: syn
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: winnow
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-02 12:00:19 +05:30
dependabot[bot]
438f9ac7cc build(deps): bump the vhost-device group in /staging with 3 updates
Bumps the vhost-device group in /staging with 3 updates: [thiserror](https://github.com/dtolnay/thiserror), [syn](https://github.com/dtolnay/syn) and [winnow](https://github.com/winnow-rs/winnow).


Updates `thiserror` from 1.0.50 to 1.0.51
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.50...1.0.51)

Updates `syn` from 2.0.40 to 2.0.41
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.40...2.0.41)

Updates `winnow` from 0.5.26 to 0.5.28
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v0.5.26...v0.5.28)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: syn
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: winnow
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-18 10:22:37 +05:30
Manos Pitsidianakis
3ca50b71be staging: update coverage score
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
ee038d6179 sound: deny clippy::undocumented_unsafe_blocks
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
5012ffa7fc sound: add QueueIdx enum for virtio queue indices
Add type safe enum to use instead of raw u16 values, which we have to
validate every time we use them.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
35de89df16 sound: test backend with and without event_idx
This increases test coverage.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
a46d8d8bab sound: add unit tests to alsa backend
Test whatever we can without actually playing/recording everything; this
would require integration tests, not unit tests.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
d523e85efa sound: add unit tests to audio_backends.rs
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
30fb9b7766 sound/alsa: fix missing StreamWithIdNotFound check
stop() was not returning an error if stream_id was invalid, it was
succeeding.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
c0c75d36ff sound: add init_logger() helper for testing
The init_logger() function gets compiled in tests only, and serves to
initialize logging only once per test thread.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
Manos Pitsidianakis
6d81397eed sound: fix invalid HandleUnknownEvent detection
Error event HandleUnknownEvent was not detected correctly, since we
first assume `device_event` is correct, use it as an index value to
access `vrings` slice, possible panic, and then match on the `queue_idx`
from the `vring`.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-14 21:41:14 +02:00
dependabot[bot]
8bcd13128a build(deps): bump the vhost-device group in /staging with 10 updates
Bumps the vhost-device group in /staging with 10 updates:

| Package | From | To |
| --- | --- | --- |
| [clap](https://github.com/clap-rs/clap) | `4.4.10` | `4.4.11` |
| [libc](https://github.com/rust-lang/libc) | `0.2.150` | `0.2.151` |
| [anstream](https://github.com/rust-cli/anstyle) | `0.6.4` | `0.6.5` |
| [anstyle-parse](https://github.com/rust-cli/anstyle) | `0.2.2` | `0.2.3` |
| [anstyle-query](https://github.com/rust-cli/anstyle) | `1.0.0` | `1.0.2` |
| [anstyle-wincon](https://github.com/rust-cli/anstyle) | `3.0.1` | `3.0.2` |
| [once_cell](https://github.com/matklad/once_cell) | `1.18.0` | `1.19.0` |
| [rustix](https://github.com/bytecodealliance/rustix) | `0.38.26` | `0.38.28` |
| [syn](https://github.com/dtolnay/syn) | `2.0.39` | `2.0.40` |
| [winnow](https://github.com/winnow-rs/winnow) | `0.5.19` | `0.5.26` |


Updates `clap` from 4.4.10 to 4.4.11
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.4.10...v4.4.11)

Updates `libc` from 0.2.150 to 0.2.151
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.150...0.2.151)

Updates `anstream` from 0.6.4 to 0.6.5
- [Commits](https://github.com/rust-cli/anstyle/compare/anstream-v0.6.4...anstream-v0.6.5)

Updates `anstyle-parse` from 0.2.2 to 0.2.3
- [Commits](https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.2...anstyle-parse-v0.2.3)

Updates `anstyle-query` from 1.0.0 to 1.0.2
- [Commits](https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.0.0...anstyle-query-v1.0.2)

Updates `anstyle-wincon` from 3.0.1 to 3.0.2
- [Commits](https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.1...anstyle-wincon-v3.0.2)

Updates `once_cell` from 1.18.0 to 1.19.0
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.18.0...v1.19.0)

Updates `rustix` from 0.38.26 to 0.38.28
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.26...v0.38.28)

Updates `syn` from 2.0.39 to 2.0.40
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.39...2.0.40)

Updates `winnow` from 0.5.19 to 0.5.26
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v0.5.19...v0.5.26)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: anstream
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: anstyle-parse
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: anstyle-query
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: anstyle-wincon
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: once_cell
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: rustix
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: syn
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: winnow
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-11 09:53:41 +05:30
Matias Ezequiel Vara Larsen
6a072fa02c sound: remove ControlMessage parameter from release()
This commit removes ControlMessage from the release() method. The
backends process the release() command immediately thus not requiring the
audio backend to notify guest later. The notification happens in the
device after the cmd is processed. This also removes the need of
handling descriptors in the audio backend. This commit fixes the tests
in pw.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-12-08 10:57:00 +05:30
Matias Ezequiel Vara Larsen
a045950d74 sound: remove ControlMessage from set_param()
This commit removes ControlMessage in the set_param() method and
replaces it with the VirtioSndPcmSetParams structure that is already
parsed by the device. Both backends are able to handle that request
immediately so there is not need to pass ControlMessage to notify the
guest afterwards. By doing this, this commit removes any descriptor
manipulation from the audio backends. The commit fixes the test in pw.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-12-08 10:57:00 +05:30
Matias Ezequiel Vara Larsen
4742cf1a28 sound/pipewire: stop threadloop during drop
The threadloop has to be stopped only when the audio backend is dropped
otherwise release() stops it and it is not started again. The threadloop
must be active all alone the life of the audio backend.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-12-05 14:14:47 +02:00
Matias Ezequiel Vara Larsen
afdefc70af sound/pipewire: handle errors and propagate to device
This commit adds the corresponding handling and propagation of errors
that may happen when device communicate with the pw backend.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-12-04 17:34:03 +01:00
Matias Ezequiel Vara Larsen
252494f782 sound/alsa: handle errors and propagate to device
This commit adds the corresponding handling and propagation of errors
that may happen when device communicates with the alsa backend.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-12-04 17:34:03 +01:00
Matias Ezequiel Vara Larsen
7727895aec sound/alsa: remove runner thread
This commit removes the need for a runner thread to be created when the
alsa backend is instantiated. This thread is responsible for handling
control requests and communicating with worker threads for starting and
stopping playback/capturing streams. When the virtio-sound daemon gets a
control cmd, a msg is sent over a channel and the runner processes the
request. With this commit, we propose that we handle the msg immediately
without needing to use a thread. The following reasons have led to the
removal of this thread:

* to propagate the error to the device in case an operation fails
* to simplify the backend by removing an extra thread
* to prepare the backend to remove ControlMsg from the header of the
  set_param() and release() methods. Ideally, the audio backend shall
  know nothing about descriptors. By removing the use of a thread to
  handle the control request, notification to guest can happen
  immediately in the device instead of letting the audio backend to handle
  the notifications

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-12-04 17:34:03 +01:00
dependabot[bot]
b0a7a8b093 build(deps): bump the vhost-device group in /staging with 4 updates
Bumps the vhost-device group in /staging with 4 updates: [clap](https://github.com/clap-rs/clap), [errno](https://github.com/lambda-fairy/rust-errno), [linux-raw-sys](https://github.com/sunfishcode/linux-raw-sys) and [rustix](https://github.com/bytecodealliance/rustix).


Updates `clap` from 4.4.8 to 4.4.10
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.4.8...v4.4.10)

Updates `errno` from 0.3.7 to 0.3.8
- [Changelog](https://github.com/lambda-fairy/rust-errno/blob/main/CHANGELOG.md)
- [Commits](https://github.com/lambda-fairy/rust-errno/compare/v0.3.7...v0.3.8)

Updates `linux-raw-sys` from 0.4.11 to 0.4.12
- [Commits](https://github.com/sunfishcode/linux-raw-sys/compare/v0.4.11...v0.4.12)

Updates `rustix` from 0.38.25 to 0.38.26
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.25...v0.38.26)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: errno
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: linux-raw-sys
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: rustix
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 10:52:14 +05:30
Manos Pitsidianakis
842d1965e4 sound: remove duplicate ControlMessage definitions
Somehow slipped through the reviews. Thanks @MatiasVara for catching
this.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-12-01 14:57:46 +05:30
Viresh Kumar
00ad80d736 vhost-device: Don't return bool unnecessarily
Since everyone copied the first bits of code from the I2C crate, the
same issue is present almost everywhere. The returned value isn't
checked at all by the callers. Stop returning bool unnecessarily.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-12-01 09:40:52 +01:00
Matias Ezequiel Vara Larsen
f34f7b9869 sound/pipewire: stop threadloop before destroying context
During release(), the threadloop has to be stopped before the context is
destroyed, otherwise the threadloop continues to execute thus ending in
crashes due to SIGABRT or SIGSEGV.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-11-27 11:13:02 +05:30
dependabot[bot]
f7cbe50dd0 build(deps): bump the vhost-device group in /staging with 3 updates
Bumps the vhost-device group in /staging with 3 updates: [hashbrown](https://github.com/rust-lang/hashbrown), [proc-macro2](https://github.com/dtolnay/proc-macro2) and [serde](https://github.com/serde-rs/serde).


Updates `hashbrown` from 0.14.2 to 0.14.3
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.14.2...v0.14.3)

Updates `proc-macro2` from 1.0.69 to 1.0.70
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.69...1.0.70)

Updates `serde` from 1.0.192 to 1.0.193
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.192...v1.0.193)

---
updated-dependencies:
- dependency-name: hashbrown
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: proc-macro2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: serde
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-27 10:40:38 +05:30
Erik Schilling
25c6ac3362 tree-wide: use new serve convenience function
This become available with the recent vhost-user-backend [1] updates and
allows to get rid of some boilerplate code.

[1] https://github.com/rust-vmm/vhost/pull/173

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
2023-11-20 13:05:48 +05:30
dependabot[bot]
9a6d12389f build(deps): bump the vhost-device group in /staging with 2 updates
Bumps the vhost-device group in /staging with 2 updates: [rustix](https://github.com/bytecodealliance/rustix) and [toml](https://github.com/toml-rs/toml).


Updates `rustix` from 0.38.24 to 0.38.25
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.24...v0.38.25)

Updates `toml` from 0.8.2 to 0.8.8
- [Commits](https://github.com/toml-rs/toml/compare/toml-v0.8.2...toml-v0.8.8)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: toml
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-20 10:17:48 +05:30
dependabot[bot]
2e8dc1bb47 build(deps): bump the vhost-device group in /staging with 22 updates
Bumps the vhost-device group in /staging with 22 updates:

| Package | From | To |
| --- | --- | --- |
| [alsa](https://github.com/diwic/alsa-rs) | `0.7.1` | `0.8.1` |
| [clap](https://github.com/clap-rs/clap) | `4.4.6` | `4.4.8` |
| [env_logger](https://github.com/rust-cli/env_logger) | `0.10.0` | `0.10.1` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.49` | `1.0.50` |
| [tempfile](https://github.com/Stebalien/tempfile) | `3.8.0` | `3.8.1` |
| [num_enum](https://github.com/illicitonion/num_enum) | `0.7.0` | `0.7.1` |
| [futures-executor](https://github.com/rust-lang/futures-rs) | `0.3.28` | `0.3.29` |
| [errno](https://github.com/lambda-fairy/rust-errno) | `0.3.5` | `0.3.7` |
| [futures](https://github.com/rust-lang/futures-rs) | `0.3.28` | `0.3.29` |
| [hashbrown](https://github.com/rust-lang/hashbrown) | `0.14.1` | `0.14.2` |
| [indexmap](https://github.com/bluss/indexmap) | `2.0.2` | `2.1.0` |
| [proc-macro-crate](https://github.com/bkchr/proc-macro-crate) | `1.3.1` | `2.0.0` |
| [serde](https://github.com/serde-rs/serde) | `1.0.189` | `1.0.192` |
| [serde_spanned](https://github.com/toml-rs/toml) | `0.6.3` | `0.6.4` |
| [smallvec](https://github.com/servo/rust-smallvec) | `1.11.1` | `1.11.2` |
| [syn](https://github.com/dtolnay/syn) | `2.0.38` | `2.0.39` |
| [system-deps](https://github.com/gdesmott/system-deps) | `6.1.2` | `6.2.0` |
| [target-lexicon](https://github.com/bytecodealliance/target-lexicon) | `0.12.11` | `0.12.12` |
| [termcolor](https://github.com/BurntSushi/termcolor) | `1.3.0` | `1.4.0` |
| [toml_datetime](https://github.com/toml-rs/toml) | `0.6.3` | `0.6.5` |
| [toml_edit](https://github.com/toml-rs/toml) | `0.20.2` | `0.20.7` |
| [winnow](https://github.com/winnow-rs/winnow) | `0.5.17` | `0.5.19` |


Updates `alsa` from 0.7.1 to 0.8.1
- [Commits](https://github.com/diwic/alsa-rs/compare/v0.7.1...v0.8.1)

Updates `clap` from 4.4.6 to 4.4.8
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.4.6...v4.4.8)

Updates `env_logger` from 0.10.0 to 0.10.1
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-cli/env_logger/compare/v0.10.0...v0.10.1)

Updates `thiserror` from 1.0.49 to 1.0.50
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.49...1.0.50)

Updates `tempfile` from 3.8.0 to 3.8.1
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/commits)

Updates `num_enum` from 0.7.0 to 0.7.1
- [Commits](https://github.com/illicitonion/num_enum/compare/0.7.0...0.7.1)

Updates `futures-executor` from 0.3.28 to 0.3.29
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.28...0.3.29)

Updates `errno` from 0.3.5 to 0.3.7
- [Changelog](https://github.com/lambda-fairy/rust-errno/blob/main/CHANGELOG.md)
- [Commits](https://github.com/lambda-fairy/rust-errno/compare/v0.3.5...v0.3.7)

Updates `futures` from 0.3.28 to 0.3.29
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.28...0.3.29)

Updates `hashbrown` from 0.14.1 to 0.14.2
- [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/hashbrown/compare/v0.14.1...v0.14.2)

Updates `indexmap` from 2.0.2 to 2.1.0
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/bluss/indexmap/compare/2.0.2...2.1.0)

Updates `proc-macro-crate` from 1.3.1 to 2.0.0
- [Release notes](https://github.com/bkchr/proc-macro-crate/releases)
- [Commits](https://github.com/bkchr/proc-macro-crate/compare/v1.3.1...v2.0.0)

Updates `serde` from 1.0.189 to 1.0.192
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.189...v1.0.192)

Updates `serde_spanned` from 0.6.3 to 0.6.4
- [Commits](https://github.com/toml-rs/toml/compare/serde_spanned-v0.6.3...serde_spanned-v0.6.4)

Updates `smallvec` from 1.11.1 to 1.11.2
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.11.1...v1.11.2)

Updates `syn` from 2.0.38 to 2.0.39
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.38...2.0.39)

Updates `system-deps` from 6.1.2 to 6.2.0
- [Release notes](https://github.com/gdesmott/system-deps/releases)
- [Commits](https://github.com/gdesmott/system-deps/compare/system-deps@6.1.2...system-deps@6.2.0)

Updates `target-lexicon` from 0.12.11 to 0.12.12
- [Commits](https://github.com/bytecodealliance/target-lexicon/compare/v0.12.11...v0.12.12)

Updates `termcolor` from 1.3.0 to 1.4.0
- [Commits](https://github.com/BurntSushi/termcolor/compare/1.3.0...1.4.0)

Updates `toml_datetime` from 0.6.3 to 0.6.5
- [Commits](https://github.com/toml-rs/toml/compare/toml_datetime-v0.6.3...toml_datetime-v0.6.5)

Updates `toml_edit` from 0.20.2 to 0.20.7
- [Commits](https://github.com/toml-rs/toml/compare/v0.20.2...v0.20.7)

Updates `winnow` from 0.5.17 to 0.5.19
- [Changelog](https://github.com/winnow-rs/winnow/blob/main/CHANGELOG.md)
- [Commits](https://github.com/winnow-rs/winnow/compare/v0.5.17...v0.5.19)

---
updated-dependencies:
- dependency-name: alsa
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: env_logger
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: num_enum
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: futures-executor
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: errno
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: futures
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: hashbrown
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: indexmap
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: proc-macro-crate
  dependency-type: indirect
  update-type: version-update:semver-major
  dependency-group: vhost-device
- dependency-name: serde
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: serde_spanned
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: smallvec
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: syn
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: system-deps
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: target-lexicon
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: termcolor
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: vhost-device
- dependency-name: toml_datetime
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: toml_edit
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
- dependency-name: winnow
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: vhost-device
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-16 11:26:18 +01:00
Erik Schilling
31154ea0da Update vhost-user-backend to 0.11 series
- Features were renamed from slave -> backend
- Generics got simplified
- Some write and read functions on Volatile slice got turned into
  standalone traits: ReadVolatile, WriteVolatile
- handle_event no longer returns a bool

Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
2023-11-14 10:48:19 +02:00
Manos Pitsidianakis
1212df9e26 sound/pipewire: add test harness for pipewire+dbus
Add test utility to launch a temporary dbus daemon, pipewire.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-11-10 17:44:32 +02:00
Matias Ezequiel Vara Larsen
4eb461ee3f sound/test: add tests for virtio_sound.rs
This commit adds simple tests for the structures in virtio_sound.rs. The
tests are split into two tests to fix a clippy error regarding the
cognitive complexity.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-11-09 09:50:39 +02:00
Dorinda Bassey
31212150c1 sound: Add Test for vhost-device-sound
This PR adds test for uncovered code paths

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-11-07 11:15:06 +02:00
Matias Ezequiel Vara Larsen
7a00d935f9 sound/test: add tests for device.rs
This commit adds tests in test_sound_thread_failure to test that
process_control() returns Err() in the following four conditions:
    * control request with a single descriptor
    * control request in which first descriptor is write-only
    * control request in which second descriptor is read-only
    * control request with less than three descriptors for control requests
      that require three, e.g., PcmInfo, ChmapInfo

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-11-02 16:19:54 +01:00
Manos Pitsidianakis
3416215092 sound: add virtualization in Cargo.toml categories
Previous commit added categories to Cargo.toml, but the only value was
`multimedia::audio`.

Thanks @stefano-garzarella for noticing I missed this.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-11-02 10:39:25 +01:00
Manos Pitsidianakis
90f547e98c sound: add clippy lint checks
Add basic lints to deny unidiomatic or potentially bad code.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-11-02 10:46:49 +05:30
Manos Pitsidianakis
75ca1ee428 sound: add package.categories field to Cargo.toml
Suggested by lint https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-11-02 10:46:49 +05:30
Manos Pitsidianakis
7255036df6 sound/pipewire: prevent unsigned sub overflow
A subtraction between unsigned integers is made, which by default panics
on overflow. However, we don't really need to know the difference, only
that it is not zero or less.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-11-02 10:46:49 +05:30
Dorinda Bassey
0f1eab60ec sound/pipewire: Add Pipewire Capture
Add pipewire capture to enable capturing for pipewire backend

Co-authored-by: Dorinda Bassey <dbassey@redhat.com>
Co-authored-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-31 16:07:46 +05:30
Dorinda Bassey
a2d9b2e721 sound: Improve function definition
instead of consume() fn name, use read_output() fn which
is more appropriate and in sync with the write_input() fn.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-30 16:34:06 +05:30
Manos Pitsidianakis
1921ec21d8 sound: Implement RX in ALSA backend
Add an RX code path that is similar to the existing TX code in the ALSA
backend.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-27 11:39:04 +01:00
Manos Pitsidianakis
d00014f5a6 sound: add Buffer::desc_len() method
Add a method to return the length of the descriptor memory region and
make `data_descriptor` field private.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-27 11:39:04 +01:00
Manos Pitsidianakis
31175bf66c sound: Add Direction enum
We use input/output direction values in many places, yet we lose Rust's
exhaustive static checks when matching for a stream's direction. This
commits adds a Direction enum and From/Into implementations for audio
backend respective direction types.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-27 16:04:31 +05:30
Manos Pitsidianakis
573e592037 sound: fix broken tests
Tests were not updated with changes in previous commits, so update them.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-25 12:53:44 +05:30
Albert Esteve
5993c1f6c1 staging: update coverage target
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-10-24 19:09:41 +05:30
Manos Pitsidianakis
30d5cf4e10 sound: clean up and improve comments, definitions
- Add some documentation comments
- Rename TxState to IoState in preparation for RX implementation
- Fix inline rust code not being escaped properly in doc comments
- Rename some fields to make their function clearer
- Cleanup some error log messages
- Replace an old TODO comment about queue size with an explanation

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00
Manos Pitsidianakis
04f80fc8e9 sound: add latency_bytes field to IOMessage
The latency field specifies how long it will take until the device
finishes playing the I/O message's buffers.

Since the I/O message is dropped as soon as the last bytes are copied
over to the host's internal buffers, assume the message is dropped
almost after the host has started playing this buffer.

This solves the issue of a guest app exiting before the host has done
playing audio because it kept sending new buffers as fast as possible
without waiting (latency).

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00
Manos Pitsidianakis
2ba56bef25 sound/alsa: fix host hwparams calculation
The host's period and buffer sizes were not being calculated correctly.

This resulted in timing mismatches.

This commit calculates the correct sizes by taking the guest's
parameters into account.

Impossible cases when matching with stream parameters will lead to
unreachable!().

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00
Manos Pitsidianakis
84c58404b8 sound/alsa: fix consume() use for playback
Use of consume() method was incorrect. This commit fixes the buffer
bounds used with playback in ALSA.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00
Manos Pitsidianakis
c10b8e18c4 sound/alsa: stop actual playback after PCM_STOP
Queued buffers were played even after the guest issued PCM_STOP.

This commit:

- makes the ALSA worker threads respect the stopped status instead
- send a start signal to worker threads on PCM_START to handle
  pre-buffering
- reduce the time of playback callbacks holding the stream lock

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00
Manos Pitsidianakis
aa16ef0699 sound/pipewire: handle StreamWithIdNotFound consistently
When handling controlq messages, handle StreamWithIdNotFound the same
way on all methods:

- if we are passed a &mut ControlMessage, set it to
  VIRTIO_SND_S_BAD_MSG.
- if we are passed a stream_id, return StreamWithIdNotFound.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00
Manos Pitsidianakis
208a796061 sound/alsa: handle PCM state transition errors gracefully
Handle some state transition errors more gracefully by retrying ALSA
operations if possible. Also rewrite the PCM_RELEASE handler to make it
more clear.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-24 11:08:26 +01:00