Best practice for signalling fatal error from (audio) thread


#1

Hi all
What is the best / recommended way to signal a fatal error from a thread, for example the audio thread? My goal is for the application to quit and print a descriptive error message on the command line when the error occurs. The application is running on linux and is started from the command line. I thought I could call Logger::writeToLog and then call exit(some code) in my thread but I don’t see the error message and I don’t seem to be able to print the code when executing “echo $?” on the command line, so I’m just wondering what the best way is to safely / correctly handle this.
Thanks
B


#2

Maybe just don’t have fatal errors in the audio processing? What fatal error do you have to deal with?


#3

I wish I could write code that would need no error handling!


#4

Of course there can be error handling but what situation do you have that would need to require quitting the application? If you notice something is wrong during the audio processing stage, you could just fill the output buffers with silence, for example. More ideally, you should be able to determine if the playback can be safely started before/during the prepareToPlay or equivalent method.


#5

I am developing a custom audio driver, so I need to be able to at least during the development stage catch weird situations where for example the requested number of samples does not match the size of some of my buffers … it’s really a situation that is probably not relevant for 90% of the developers here but it matters to me.