mirror of
https://github.com/Tha14/toxic.git
synced 2025-07-04 06:36:46 +02:00
Rework audio device handling
We now have at most one input and one output device open at any time, but can have multiple capture callbacks and multiple output sources.
This commit is contained in:
14
src/toxic.c
14
src/toxic.c
@ -103,6 +103,7 @@ struct av_thread av_thread;
|
||||
struct arg_opts arg_opts;
|
||||
struct user_settings *user_settings = NULL;
|
||||
|
||||
pthread_mutex_t tox_lock;
|
||||
|
||||
static struct user_password {
|
||||
bool data_is_encrypted;
|
||||
@ -945,9 +946,12 @@ static void do_toxic(Tox *m)
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&tox_lock);
|
||||
|
||||
tox_iterate(m, NULL);
|
||||
do_tox_connection(m);
|
||||
|
||||
pthread_mutex_unlock(&tox_lock);
|
||||
pthread_mutex_unlock(&Winthread.lock);
|
||||
}
|
||||
|
||||
@ -1392,6 +1396,10 @@ int main(int argc, char **argv)
|
||||
exit_toxic_err("failed in main", FATALERR_MEMORY);
|
||||
}
|
||||
|
||||
if (pthread_mutex_init(&tox_lock, NULL) != 0) {
|
||||
exit_toxic_err("failed in main", FATALERR_MUTEX_INIT);
|
||||
}
|
||||
|
||||
const char *p = arg_opts.config_path[0] ? arg_opts.config_path : NULL;
|
||||
|
||||
if (settings_load(user_settings, p) == -1) {
|
||||
@ -1457,12 +1465,12 @@ int main(int argc, char **argv)
|
||||
exit_toxic_err("failed in main", FATALERR_THREAD_CREATE);
|
||||
}
|
||||
|
||||
set_primary_device(input, user_settings->audio_in_dev);
|
||||
set_primary_device(output, user_settings->audio_out_dev);
|
||||
set_al_device(input, user_settings->audio_in_dev);
|
||||
set_al_device(output, user_settings->audio_out_dev);
|
||||
|
||||
#elif SOUND_NOTIFY
|
||||
|
||||
if (init_devices() == de_InternalError) {
|
||||
if (init_audio() == de_InternalError) {
|
||||
queue_init_message("Failed to init audio devices");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user