Commit Graph

675 Commits

Author SHA1 Message Date
dorindabassey
6124bea340
Merge pull request #38 from dorindabassey/ctrlmsg
device.rs: Add Chmap_info and Jack_info support
2023-10-04 14:36:29 +02:00
Dorinda Bassey
19cc0a318d device.rs: Add Chmap_info and Jack_info support
Added the supported features for Chmap_info and Jack_info control messages.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-10-04 08:30:16 +02:00
Matias Ezequiel Vara Larsen
0b4523617f
Merge pull request #32 from MatiasVara/add-delay-reading-from-guest
crates/sound: read buffers from guest memory rather than copying them
2023-10-03 15:25:28 +02:00
Matias Ezequiel Vara Larsen
3d0f785d66 crates/sound: read buffers from guest memory rather than copying them
In this commit, the buffers are only read from the available ring when
the audio backend will consume them. The guest driver moves buffers from
the used to the avail ring without knowing if the user application has
updated the content. As a result, when a request is enqueued into the
available ring, the device only reads the buffer from guest memory when
it is required by the audio engine. By doing this, we add enough delay
so that we can read the updated buffer.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-09-29 10:44:11 +02:00
Matias Ezequiel Vara Larsen
cbc80bee22
Merge pull request #36 from slp/pipewire-fix-thread_loop
sound/pipewire: move stream_hash insert into lock
2023-09-28 14:12:03 +02:00
Sergio Lopez
c9c86bd9aa sound/pipewire: move stream_hash insert into lock
Inserting a new stream into stream_hash can potentially move out of
context a stream previously stored in the hash with the same id,
triggering pw::stream::Stream::Drop, which calls pw_stream_destroy.

As calls to the pipewire library must happen either in the pipewire
thread or under thread_loop lock protection, move the insert into
stream_hash under the latter.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2023-09-27 17:00:31 +02:00
Stefano Garzarella
e906351003
Merge pull request #34 from dorindabassey/threadl
pipewire.rs: Remove unsafe threadloop bindings
2023-09-26 10:43:01 +02:00
Dorinda Bassey
a80d6ccf22 pipewire.rs: Remove unsafe threadloop bindings
contributed these bindings upstream, use the bindings in pipewire rust

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-09-26 10:39:46 +02:00
Matias Ezequiel Vara Larsen
29a02a6899
Merge pull request #33 from MatiasVara/fixforclipyandfmt
Fix for clipy and fmt
2023-09-20 14:34:39 +02:00
Matias Ezequiel Vara Larsen
18eace76f8 cargo fmt
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-09-20 10:38:06 +02:00
Matias Ezequiel Vara Larsen
be904f93fa remove unnecessary casting to the same type
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-09-20 10:25:45 +02:00
dorindabassey
35fa83aa85
Merge pull request #31 from dorindabassey/safeq
pipewire.rs: use safe queue API
2023-09-18 12:40:24 +02:00
Dorinda Bassey
5984715806 audio_backends/pipewire.rs: use safe queue API
use safe queue API

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-09-14 14:52:09 +02:00
dorindabassey
62575fa25c
Merge pull request #28 from dorindabassey/rebasepw
crates/sound: Rebase pipewire backend
2023-09-13 10:56:52 +02:00
Dorinda Bassey
917d24c7fa crates/sound: Rebase pipewire backend
Rebase pipewire Backend

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

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-09-11 16:47:08 +02:00
Stefano Garzarella
428d349516
Merge pull request #27 from aesteve-rh/sound-null-unconditional
sound: always compile null backend
2023-09-04 15:54:26 +02:00
Albert Esteve
bf18c3ee62 sound: always compile null backend
Make Null backend compiled unconditionally,
removing the null-backend feature. That
allows having the other backend choices in
the BackendType enum to be conditional, and
make them not available if their features is
opted out at compile time.

For example, compiled with no backend features,
there is only choice (i.e., null) for --backend:

```
$ target/debug/vhost-user-sound --help

Usage: vhost-user-sound --socket <SOCKET> --backend <BACKEND>

Options:
      --socket <SOCKET>    vhost-user Unix domain socket path
      --backend <BACKEND>  audio backend to be used [possible values: null]
  -h, --help               Print help
  -V, --version            Print version
```

Fixes: #26
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-09-04 11:26:31 +02:00
Stefano Garzarella
15516ccea4
Merge pull request #24 from aesteve-rh/virtio-sound-cli-backend
Change CLI backend option to ValueEnum
2023-09-04 09:54:31 +02:00
Albert Esteve
cd955a7132 sound: introduce rstest crate
Introduce 'rstest'[1] crate dependency to allow
run multiple parametrized tests (and fixtures).

[1] - https://docs.rs/rstest/latest/rstest/

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:43:57 +02:00
Albert Esteve
4867edc009 sound: test cli backend argument
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:43:17 +02:00
Albert Esteve
6c5b2db7db sound: audio backend allow unused
When compiled with no features, the `streams`
parameter of the alloc_audio_backend() function
is not used. Mark it as allowed to avoid the
compilation warning.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:41:47 +02:00
Albert Esteve
a48bff27b1 sound: cli backend selector
Change the CLI backend option to receive values
listed in a ValueEnum.

Current '--help' output:
```
A virtio-sound device using the vhost-user protocol.

Usage: vhost-user-sound --socket <SOCKET> --backend <BACKEND>

Options:
      --socket <SOCKET>  vhost-user Unix domain socket path
      --backend <BACKEND>  audio backend to be used [possible values:
      null, pipewire, alsa]
  -h, --help             Print help
  -V, --version          Print version
```

If a wrong backend is given, it give hints:
```
$ cargo run -- --socket /tmp/sound.sock --backend nul
error: invalid value 'nul' for '<BACKEND>'
  [possible values: null, pipewire, alsa]

  tip: a similar value exists: 'null'
```

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-08-31 11:40:40 +02:00
Manos Pitsidianakis
855eefb380
sound: add ALSA backend
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:01:34 +03:00
Manos Pitsidianakis
b7122e66af
sound: Add TX queue handler
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:01:32 +03:00
Manos Pitsidianakis
ecf88fb602
sound: Add CTRL queue handler
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:00:19 +03:00
Manos Pitsidianakis
d385dcd1b2
sound: add Stream, ControlMessage and other types
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 23:00:17 +03:00
Manos Pitsidianakis
91a5259cce
Add vhost-user-sound crate
Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
2023-08-23 22:12:35 +03:00
Stefano Garzarella
583d15433b
Merge pull request #15 from dorindabassey/cargofmt
cargo fmt
2023-07-12 09:07:13 +02:00
Dorinda Bassey
e49e8117d7 cargo fmt
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-07-11 18:23:33 +02:00
Matias Ezequiel Vara Larsen
508508afaf
Merge pull request #9 from MatiasVara/vsound-set-param
Vsound set param
2023-07-11 17:56:33 +02:00
Matias Ezequiel Vara Larsen
03241612a7 Sound: Add set_param()
This commit adds the set_param() method. This method can only be called
if the stream is in the "set parameters", "prepare" or "release" state.
For the pw backend, this method only updates the internal values for the
given stream.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-07-11 12:08:30 +02:00
dorindabassey
4027f61d92
Merge pull request #14 from dorindabassey/pwnew
instantiate new backend with PW thread loop functions
2023-07-11 11:39:00 +02:00
Dorinda Bassey
08078b752c instantiate new backend with PW thread loop functions
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-07-10 18:58:06 +02:00
Matias Ezequiel Vara Larsen
3a0f49d279
Merge pull request #7 from MatiasVara/vsound-init-streamsinfo
Sound: initialize StreamInfo
2023-07-06 15:44:01 +02:00
Matias Ezequiel Vara Larsen
b3b83c1f41 Sound: initialize StreamInfo
This commit adds a vector named StreamInfo that contains the supported
configuration for the audio backends, e.g., rate, format. This
information is stored in the context of VhostUserSoundBackend. The
device reponses this information when getting the VIRTIO_SND_R_PCM_INFO
msg. The number of streams that are exposed in the device configuration
is got from this table.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-07-05 17:02:13 +02:00
dorindabassey
4cf4e675ff
Merge pull request #6 from dorindabassey/vsound_newtx
instantiate new backend
2023-07-03 16:57:26 +02:00
Dorinda Bassey
110ccd736c instantiate new backend
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-07-03 16:02:37 +02:00
Matias Ezequiel Vara Larsen
e77e32646d
Merge pull request #5 from MatiasVara/vsound-tx-queue
Vsound tx queue
2023-06-30 17:26:58 +02:00
Matias Ezequiel Vara Larsen
e3d5071246 Sound: add audio_backend parameter
Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-06-30 10:33:13 +02:00
Matias Ezequiel Vara Larsen
c4b253c433 Sound: Handle tx queue
This commit handles the pcm i/o messages to the tx transmission queue.
These msgs contains three descriptors: hdr, data and status. The data
descriptor shall be processed by the audio backend. The data may be
split in multiples descriptors.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
2023-06-30 10:31:48 +02:00
dorindabassey
170933506c
Merge pull request #3 from dorindabassey/vsound_test
Sound: Handle control Queue
2023-06-21 13:14:23 +02:00
Dorinda Bassey
582a66ff07 Sound: Handle control queue
Handle ctrl msgs from the control Queue in method for handling control queue

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-06-21 13:02:58 +02:00
Stefano Garzarella
9f20f6502f
Merge pull request #4 from epilys/fix/chmaps-typo
rename typo virtio_snd_config.chmpas -> chmaps
2023-06-06 13:49:55 +02:00
Manos Pitsidianakis
d39140f82a
sound: rename typo virtio_snd_config.chmpas -> chmaps 2023-06-05 13:53:37 +03:00
Stefano Garzarella
63db2e8b41
Merge pull request #2 from dorindabassey/v_sound
sound: add PipeWire backend skeleton
2023-05-26 17:49:10 +02:00
Dorinda Bassey
05a959d703 sound: add PipeWire backend skeleton
to enable the pipewire backend feature, build with `--features pw-backend`

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2023-05-26 17:44:05 +02:00
Stefano Garzarella
a198f48cde sound: rename alloc_audio_backend 2023-05-19 18:19:47 +02:00
Stefano Garzarella
65f7c78dbd sound: support --backend option 2023-05-19 18:16:21 +02:00
Stefano Garzarella
82660840ca sound: add NullBackend skeleton 2023-05-19 18:11:14 +02:00
Stefano Garzarella
5e8fd650e9 sound: add AudioBackend trait 2023-05-19 18:11:14 +02:00