os: fix crash when creating non high priority thread fails

This commit is contained in:
Andrew Kelley 2015-09-17 15:01:16 -07:00
parent dbed33abd2
commit 71e31b88fe
2 changed files with 3 additions and 2 deletions

View file

@ -359,7 +359,8 @@ struct SoundIo {
/// This callback is fired when making thread real-time priority failed. By
/// default, it will print to stderr only the first time it is called
/// a message instructing the user how to configure their system to allow
/// real-time priority threads.
/// real-time priority threads. This must be set to a function not NULL.
/// To silence the warning, assign this to a function that does nothing.
void (*emit_rtprio_warning)(void);
/// Optional: JACK info callback.

View file

@ -234,7 +234,7 @@ int soundio_os_thread_create(
}
if ((err = pthread_create(&thread->id, &thread->attr, run_pthread, thread))) {
if (err == EPERM) {
if (err == EPERM && emit_rtprio_warning) {
emit_rtprio_warning();
err = pthread_create(&thread->id, NULL, run_pthread, thread);
}