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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
If a PCM_RELEASE control request comes from the guest and the state
transition is invalid by spec standards, release the buffers anyway.
This doesn't change the current behavior.
When dealing with an unrelated vhost-user issue, the state transitions
became invalid because of unexpected errors in the virto-snd driver.
Making this change made the issue obvious while debugging. Plus, the
spec does not state rejecting a PCM lifecycle control request if the
transition is not possible. (The possible state transitions are
non-normative statements.)
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Add v4l2 wrapper functions to be able
to mock (and test) v4l2r library responses
without the need of having a underlying video device.
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Complete the README file for the video crate
with the help information for the CLI, and a
working example to run and test the device.
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Add test for all modules, with dev-dependencies
(including rstest [1] for parametrized tests), and
infrastructure.
[1] - https://docs.rs/rstest/latest/rstest/
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Add new v4l2-decoder backend, that
uses v4l2r [1] for interactions with the
video device in the host. Specialized for
Linux systems.
[1] - https://github.com/Gnurou/v4l2r
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Initial skeleton for virtio-video crate.
This crate is based on the v3 of the virtio-video
specs patch[1].
It has a big part of the infrastructure
required, although not all commands are implemented,
and does not have any backend available.
Includes support for async responses to the driver
(through VIDEO_EVENT) to QueueResource messages.
[1] -
https://lists.oasis-open.org/archives/virtio-dev/202002/msg00002.html
Related: #364
Signed-off-by: Albert Esteve <aesteve@redhat.com>
Let's use custom pipelines to run CI tests in the nested worskpace.
We have included all the tests we usually run in the main workspace
(rust-vmm-ci/.buildkite/test_description.json), except for "commit-format"
which also covers commits for staging crates.
Let's add a `staging\coverage_config_x86_64.json` for testing coverage of
crates in staging.
All staging tests have `soft_fail = true` to prevent failures in staging
from affecting the CI of the main workspace.
Closes#478
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>