mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 02:13:01 +01:00
Merge branch 'EnniRosario-refresh_devices'
This commit is contained in:
commit
ecdf6f01d2
@ -633,6 +633,9 @@ void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refresh device list.
|
||||||
|
get_devices_names();
|
||||||
|
|
||||||
print_devices(self, type);
|
print_devices(self, type);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -100,34 +100,7 @@ DeviceError init_devices(ToxAV *av_)
|
|||||||
DeviceError init_devices()
|
DeviceError init_devices()
|
||||||
#endif /* AUDIO */
|
#endif /* AUDIO */
|
||||||
{
|
{
|
||||||
const char *stringed_device_list;
|
get_devices_names();
|
||||||
|
|
||||||
size[input] = 0;
|
|
||||||
|
|
||||||
if ( (stringed_device_list = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER)) ) {
|
|
||||||
ddevice_names[input] = alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
|
|
||||||
|
|
||||||
for ( ; *stringed_device_list && size[input] < MAX_DEVICES; ++size[input] ) {
|
|
||||||
devices_names[input][size[input]] = stringed_device_list;
|
|
||||||
stringed_device_list += strlen( stringed_device_list ) + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size[output] = 0;
|
|
||||||
|
|
||||||
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
|
|
||||||
stringed_device_list = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
|
|
||||||
else
|
|
||||||
stringed_device_list = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
|
||||||
|
|
||||||
if (stringed_device_list) {
|
|
||||||
ddevice_names[output] = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
|
|
||||||
|
|
||||||
for ( ; *stringed_device_list && size[output] < MAX_DEVICES; ++size[output] ) {
|
|
||||||
devices_names[output][size[output]] = stringed_device_list;
|
|
||||||
stringed_device_list += strlen( stringed_device_list ) + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start poll thread
|
// Start poll thread
|
||||||
if (pthread_mutex_init(&mutex, NULL) != 0)
|
if (pthread_mutex_init(&mutex, NULL) != 0)
|
||||||
@ -160,6 +133,38 @@ DeviceError terminate_devices()
|
|||||||
return (DeviceError) de_None;
|
return (DeviceError) de_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void get_devices_names() {
|
||||||
|
|
||||||
|
const char *stringed_device_list;
|
||||||
|
|
||||||
|
size[input] = 0;
|
||||||
|
|
||||||
|
if ( (stringed_device_list = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER)) ) {
|
||||||
|
ddevice_names[input] = alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
|
||||||
|
|
||||||
|
for ( ; *stringed_device_list && size[input] < MAX_DEVICES; ++size[input] ) {
|
||||||
|
devices_names[input][size[input]] = stringed_device_list;
|
||||||
|
stringed_device_list += strlen( stringed_device_list ) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size[output] = 0;
|
||||||
|
|
||||||
|
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
|
||||||
|
stringed_device_list = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
|
else
|
||||||
|
stringed_device_list = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
||||||
|
|
||||||
|
if (stringed_device_list) {
|
||||||
|
ddevice_names[output] = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
|
||||||
|
|
||||||
|
for ( ; *stringed_device_list && size[output] < MAX_DEVICES; ++size[output] ) {
|
||||||
|
devices_names[output][size[output]] = stringed_device_list;
|
||||||
|
stringed_device_list += strlen( stringed_device_list ) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeviceError device_mute(DeviceType type, uint32_t device_idx)
|
DeviceError device_mute(DeviceType type, uint32_t device_idx)
|
||||||
{
|
{
|
||||||
if (device_idx >= MAX_DEVICES) return de_InvalidSelection;
|
if (device_idx >= MAX_DEVICES) return de_InvalidSelection;
|
||||||
@ -481,8 +486,9 @@ void print_devices(ToxWindow *self, DeviceType type)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < size[type]; ++i)
|
for (i = 0; i < size[type]; ++i) {
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "%d: %s", i, devices_names[type][i]);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, i == primary_device[type] ? 1 : 0, 0, "%d: %s", i, devices_names[type][i]);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ DeviceError init_devices(ToxAV *av);
|
|||||||
DeviceError init_devices();
|
DeviceError init_devices();
|
||||||
#endif /* AUDIO */
|
#endif /* AUDIO */
|
||||||
|
|
||||||
|
void get_devices_names();
|
||||||
DeviceError terminate_devices();
|
DeviceError terminate_devices();
|
||||||
|
|
||||||
/* Callback handles ready data from INPUT device */
|
/* Callback handles ready data from INPUT device */
|
||||||
|
Loading…
Reference in New Issue
Block a user