[linux-audio-dev] How to kill a rogue (p)thread

Jack O'Quin joq at io.com
Wed Mar 31 16:44:15 UTC 2004


Arve Knudsen <aknuds-1 at broadpark.no> writes:

> The thing is I don't have complete control over the audio thread, a
> user defined callback is involved. In working on the ALSA
> implementation of the PortAudio library there has been a request for
> realtime scheduling of the audio thread, similar to the older OSS
> implementation. The OSS implementation starts both a watchdog and a
> canary thread; the watchdog will kill the audio thread (with SIGKILL)
> if it doesn't respond within 3-second intervals, or lower it's
> priority if the (normal priority) canary thread is starved.

You can do something like this...

  int oldtype;
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);

  /* invoke the callback */
  framesProcessed = PaUtil_EndBufferProcessing( &stream->bufferProcessor,
                                                &callbackResult );

  /* restore original canceltype setting */
  pthread_setcanceltype(oldtype, NULL);

-- 
  joq



More information about the Linux-audio-dev mailing list