mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-01-03 13:45:41 +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.
|
||||
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
|
||||
|
||||
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 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 WASAPI (Windows) backend, get examples working
|
||||
0. implement JACK backend, get examples working
|
||||
0. Avoid calling `panic` in PulseAudio.
|
||||
0. implement ASIO (Windows) backend, get examples working
|
||||
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
|
||||
and smaller mlock requirements
|
||||
0. Consider testing on FreeBSD
|
||||
0. make rtprio warning a callback and have existing behavior be the default callback
|
||||
|
||||
## Planned Uses for libsoundio
|
||||
|
||||
|
|
|
@ -509,6 +509,8 @@ static int refresh_devices(SoundIoPrivate *si) {
|
|||
SoundIoDevicesInfo *devices_info = create<SoundIoDevicesInfo>();
|
||||
if (!devices_info)
|
||||
return SoundIoErrorNoMem;
|
||||
devices_info->default_output_index = -1;
|
||||
devices_info->default_input_index = -1;
|
||||
|
||||
void **hints;
|
||||
if (snd_device_name_hint(-1, "pcm", &hints) < 0) {
|
||||
|
|
|
@ -259,8 +259,13 @@ static void finish_device_query(SoundIoPrivate *si) {
|
|||
}
|
||||
|
||||
// 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_input_index = -1;
|
||||
|
||||
if (sipa->current_devices_info->input_devices.length > 0) {
|
||||
sipa->current_devices_info->default_input_index = 0;
|
||||
for (int i = 0; i < sipa->current_devices_info->input_devices.length; i += 1) {
|
||||
SoundIoDevice *device = sipa->current_devices_info->input_devices.at(i);
|
||||
assert(device->purpose == SoundIoDevicePurposeInput);
|
||||
|
@ -268,6 +273,10 @@ static void finish_device_query(SoundIoPrivate *si) {
|
|||
sipa->current_devices_info->default_input_index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sipa->current_devices_info->output_devices.length > 0) {
|
||||
sipa->current_devices_info->default_output_index = 0;
|
||||
for (int i = 0; i < sipa->current_devices_info->output_devices.length; i += 1) {
|
||||
SoundIoDevice *device = sipa->current_devices_info->output_devices.at(i);
|
||||
assert(device->purpose == SoundIoDevicePurposeOutput);
|
||||
|
@ -275,6 +284,7 @@ static void finish_device_query(SoundIoPrivate *si) {
|
|||
sipa->current_devices_info->default_output_index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
soundio_destroy_devices_info(sipa->ready_devices_info);
|
||||
sipa->ready_devices_info = sipa->current_devices_info;
|
||||
|
|
|
@ -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);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
void soundio_device_ref(struct SoundIoDevice *device);
|
||||
|
|
Loading…
Reference in a new issue