Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print list of available audio drivers #251

Closed
gavv opened this issue Sep 11, 2019 · 2 comments
Closed

Print list of available audio drivers #251

gavv opened this issue Sep 11, 2019 · 2 comments
Labels
easy hacks The solution is expected to be straightforward even if you are new to the project enhancement help wanted An important and awaited task but we have no human resources for it yet sound io Audio I/O
Milestone

Comments

@gavv
Copy link
Member

gavv commented Sep 11, 2019

Intro

We have four concepts in roc_sndio module:

  • audio backend

    Audio backend provides one or multiple audio drivers, and each driver can be used to work with audio sources and audio sinks of some specific type.

    In code, a backend is an implementation of sndio::IBackend interface.

    Examples of backends are: SoxBackend (opens sources and sinks using libsox; it supports numerous drivers, e.g. "wav" or "alsa"), PulseaudioBackend (opens sources and sinks using libpulse; it supports a single driver "pulseaudio").

  • audio driver

    Audio driver works with sources and sinks of some specific type.

    In code, a driver is just a string passed to backend implementation when opening a source or a sink. It depends on the specific backend how to interpret this string.

    Examples of drivers are: "wav" (WAV file), "alsa" (ALSA device), "pulseaudio" (PulseAudio device).

  • audio source

    Audio source represents a recording audio device or input audio file. We can read sound stream from a source.

    In code, a source is an implementation of sndio::ISource. Sources are opened using IBackend::open_source() method.

  • audio sink

    Audio sink represents a playback audio device or output audio file. We can write sound stream to a sink.

    In code, a sink is an implementation of sndio::ISink. Sinks are opened using IBackend::open_sink() method.

Backends are not visible to the user. When the user starts roc-recv or roc-send, they specify the driver and the input name (in roc-send) or an output name (in roc-recv). The name can be a file name or a device name, depending on the driver.

The driver and the name are passed to BackendDispatcher. It looks at the driver name and selects a backend that can handle this driver. Then it passes the driver name and the input or output name to the backend, and the backend creates a source (in roc-send) or a sink (in roc-recv).

Task

This task is rather simple: we need to be able to print the list of supported drivers.

Something like this:

$ roc-recv -L
pulseaudio
alsa
wav
...

Implementation

The following implementation is suggested:

  • Add a new structure sndio::DriverInfo. It should contain at list one field const char* name. We can also add other fields, like backend name, driver type (a file or a device), but this can be done later.

  • Add a new method IBackend::get_drivers(core::Array<DriverInfo>&) that will add info to the list about every driver supported by the backend. If a driver is already present in the list, it should not be added. It can happen because the same driver can be supported by different backends (e.g. "pulseaudio" driver is supported by PulseaudioBackend and SoxBackend).

  • Implement this method for all IBackend implementations.

    • For PulseaudioBackend, the only supported driver is "pulseaudio".

    • For SoxBackend, the list of supported drivers can be retrieved using sox_get_format_fns() function.

  • Implement BackendDispatcher::get_drivers(core::Array<DriverInfo>&) that will collect drivers from all registered backends.

  • Add --list-drivers (-L) option to roc-recv and roc-send. It should invoke BackendDispatcher::get_drivers() and then print all collected drivers to stdout.

@gavv gavv added enhancement help wanted An important and awaited task but we have no human resources for it yet easy hacks The solution is expected to be straightforward even if you are new to the project labels Sep 11, 2019
@gavv gavv added the sound io Audio I/O label Sep 12, 2019
@gavv
Copy link
Member Author

gavv commented Sep 16, 2019

Assigned (#262).

tomd1990 pushed a commit to tomd1990/roc that referenced this issue Sep 19, 2019
tomd1990 pushed a commit to tomd1990/roc that referenced this issue Sep 19, 2019
tomd1990 pushed a commit to tomd1990/roc that referenced this issue Sep 22, 2019
tomd1990 pushed a commit to tomd1990/roc that referenced this issue Sep 22, 2019
tomd1990 pushed a commit to tomd1990/roc that referenced this issue Sep 24, 2019
gavv pushed a commit that referenced this issue Sep 24, 2019
@gavv
Copy link
Member Author

gavv commented Sep 24, 2019

PR is merged.

@gavv gavv closed this as completed Sep 24, 2019
hrishikeshSuresh pushed a commit to hrishikeshSuresh/roc that referenced this issue Oct 1, 2019
hrishikeshSuresh pushed a commit to hrishikeshSuresh/roc that referenced this issue Oct 1, 2019
hrishikeshSuresh pushed a commit to hrishikeshSuresh/roc that referenced this issue Oct 1, 2019
@gavv gavv added this to the 0.2.0 milestone Oct 5, 2019
@gavv gavv modified the milestones: 0.2.0, 0.1.3 Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy hacks The solution is expected to be straightforward even if you are new to the project enhancement help wanted An important and awaited task but we have no human resources for it yet sound io Audio I/O
Projects
Status: Done
Development

No branches or pull requests

1 participant