mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-01-03 14:15:47 +00:00
default device index is -1 if no devices available
This commit is contained in:
parent
db06391646
commit
a3388e792a
|
@ -146,7 +146,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### "Best Backend"
|
### Backend Priority
|
||||||
|
|
||||||
When you use `soundio_connect`, libsoundio tries these backends in order.
|
When you use `soundio_connect`, libsoundio tries these backends in order.
|
||||||
If unable to connect to that backend, due to the backend not being installed,
|
If unable to connect to that backend, due to the backend not being installed,
|
||||||
|
@ -238,12 +238,12 @@ view `coverage/index.html` in a browser.
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
0. pipe record to playback example working with dummy linux, osx, windows
|
|
||||||
0. pipe record to playback example working with pulseaudio linux
|
0. pipe record to playback example working with pulseaudio linux
|
||||||
0. pipe record to playback example working with ALSA linux
|
0. pipe record to playback example working with ALSA linux
|
||||||
|
0. pipe record to playback example working with dummy linux, osx, windows
|
||||||
|
0. implement JACK backend, get examples working
|
||||||
0. implement CoreAudio (OSX) backend, get examples working
|
0. implement CoreAudio (OSX) backend, get examples working
|
||||||
0. implement WASAPI (Windows) backend, get examples working
|
0. implement WASAPI (Windows) backend, get examples working
|
||||||
0. implement JACK backend, get examples working
|
|
||||||
0. Avoid calling `panic` in PulseAudio.
|
0. Avoid calling `panic` in PulseAudio.
|
||||||
0. implement ASIO (Windows) backend, get examples working
|
0. implement ASIO (Windows) backend, get examples working
|
||||||
0. clean up API and improve documentation
|
0. clean up API and improve documentation
|
||||||
|
@ -266,6 +266,7 @@ view `coverage/index.html` in a browser.
|
||||||
0. instead of `void *backend_data` use a union for better cache locality
|
0. instead of `void *backend_data` use a union for better cache locality
|
||||||
and smaller mlock requirements
|
and smaller mlock requirements
|
||||||
0. Consider testing on FreeBSD
|
0. Consider testing on FreeBSD
|
||||||
|
0. make rtprio warning a callback and have existing behavior be the default callback
|
||||||
|
|
||||||
## Planned Uses for libsoundio
|
## Planned Uses for libsoundio
|
||||||
|
|
||||||
|
|
|
@ -509,6 +509,8 @@ static int refresh_devices(SoundIoPrivate *si) {
|
||||||
SoundIoDevicesInfo *devices_info = create<SoundIoDevicesInfo>();
|
SoundIoDevicesInfo *devices_info = create<SoundIoDevicesInfo>();
|
||||||
if (!devices_info)
|
if (!devices_info)
|
||||||
return SoundIoErrorNoMem;
|
return SoundIoErrorNoMem;
|
||||||
|
devices_info->default_output_index = -1;
|
||||||
|
devices_info->default_input_index = -1;
|
||||||
|
|
||||||
void **hints;
|
void **hints;
|
||||||
if (snd_device_name_hint(-1, "pcm", &hints) < 0) {
|
if (snd_device_name_hint(-1, "pcm", &hints) < 0) {
|
||||||
|
|
|
@ -259,20 +259,30 @@ static void finish_device_query(SoundIoPrivate *si) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// based on the default sink name, figure out the default output index
|
// based on the default sink name, figure out the default output index
|
||||||
|
// if the name doesn't match just pick the first one. if there are no
|
||||||
|
// devices then we need to set it to -1.
|
||||||
sipa->current_devices_info->default_output_index = -1;
|
sipa->current_devices_info->default_output_index = -1;
|
||||||
sipa->current_devices_info->default_input_index = -1;
|
sipa->current_devices_info->default_input_index = -1;
|
||||||
for (int i = 0; i < sipa->current_devices_info->input_devices.length; i += 1) {
|
|
||||||
SoundIoDevice *device = sipa->current_devices_info->input_devices.at(i);
|
if (sipa->current_devices_info->input_devices.length > 0) {
|
||||||
assert(device->purpose == SoundIoDevicePurposeInput);
|
sipa->current_devices_info->default_input_index = 0;
|
||||||
if (strcmp(device->name, sipa->default_source_name) == 0) {
|
for (int i = 0; i < sipa->current_devices_info->input_devices.length; i += 1) {
|
||||||
sipa->current_devices_info->default_input_index = i;
|
SoundIoDevice *device = sipa->current_devices_info->input_devices.at(i);
|
||||||
|
assert(device->purpose == SoundIoDevicePurposeInput);
|
||||||
|
if (strcmp(device->name, sipa->default_source_name) == 0) {
|
||||||
|
sipa->current_devices_info->default_input_index = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < sipa->current_devices_info->output_devices.length; i += 1) {
|
|
||||||
SoundIoDevice *device = sipa->current_devices_info->output_devices.at(i);
|
if (sipa->current_devices_info->output_devices.length > 0) {
|
||||||
assert(device->purpose == SoundIoDevicePurposeOutput);
|
sipa->current_devices_info->default_output_index = 0;
|
||||||
if (strcmp(device->name, sipa->default_sink_name) == 0) {
|
for (int i = 0; i < sipa->current_devices_info->output_devices.length; i += 1) {
|
||||||
sipa->current_devices_info->default_output_index = i;
|
SoundIoDevice *device = sipa->current_devices_info->output_devices.at(i);
|
||||||
|
assert(device->purpose == SoundIoDevicePurposeOutput);
|
||||||
|
if (strcmp(device->name, sipa->default_sink_name) == 0) {
|
||||||
|
sipa->current_devices_info->default_output_index = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,9 +483,11 @@ struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int inde
|
||||||
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index);
|
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index);
|
||||||
|
|
||||||
// returns the index of the default input device
|
// returns the index of the default input device
|
||||||
|
// returns -1 if there are no devices.
|
||||||
int soundio_get_default_input_device_index(struct SoundIo *soundio);
|
int soundio_get_default_input_device_index(struct SoundIo *soundio);
|
||||||
|
|
||||||
// returns the index of the default output device
|
// returns the index of the default output device
|
||||||
|
// returns -1 if there are no devices.
|
||||||
int soundio_get_default_output_device_index(struct SoundIo *soundio);
|
int soundio_get_default_output_device_index(struct SoundIo *soundio);
|
||||||
|
|
||||||
void soundio_device_ref(struct SoundIoDevice *device);
|
void soundio_device_ref(struct SoundIoDevice *device);
|
||||||
|
|
Loading…
Reference in a new issue