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>
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>
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>
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>
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>
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>
Added device configuration and common definitions from the
virtio sound specifications to the header file
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>