Commit Graph

20 Commits

Author SHA1 Message Date
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
Manos Pitsidianakis
33c977cc0f sound/alsa: Release buffers even on RELEASE err
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>
2023-10-24 11:08:26 +01:00
Albert Esteve
3921238555 video: add v4l2 mocks
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>
2023-10-24 11:17:33 +02:00
Albert Esteve
cb4ec6ad12 video: fill readme
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>
2023-10-24 11:17:33 +02:00
Albert Esteve
f84ea414e3 video: add tests
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>
2023-10-24 11:17:33 +02:00
Albert Esteve
72dc2e78f2 video: add v4l2-decoder backend
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>
2023-10-24 11:17:33 +02:00
Albert Esteve
5edf1dfb7b video: initial skeleton
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>
2023-10-24 11:17:33 +02:00
Dorinda Bassey
1ccb3b6e58 sound/pipewire: add safety comments
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-24 14:19:24 +05:30
Dorinda Bassey
cae9fd0f79 sound/test: add testing module for sound
add testing modules

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-20 18:35:29 +05:30
Dorinda Bassey
d04d6b42fc sound: Return error if no memory configured
Add option to return error if no memory is configured

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-20 18:35:29 +05:30
Dorinda Bassey
ab33111ecb sound/Cargo.toml: update dependencies
Update dependencies and add support for xen builds

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-20 18:35:29 +05:30
Stefano Garzarella
994ffe1864 staging: add custom pipelines to run CI tests
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>
2023-10-17 16:35:55 +05:30
Manos Pitsidianakis
eb2e2227e4
Move vhost-device-sound to staging workspace
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-16 14:58:40 +03:00
Manos Pitsidianakis
54b5db72e0 Add new workspace under staging/ subdirectory
Add a new workspace for devices that have no final specification merged
into the virtio spec.

Closes #459

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-10-11 16:25:00 +05:30