Re: Suspend/resume change the IO thread
Re: Suspend/resume change the IO thread
- Subject: Re: Suspend/resume change the IO thread
- From: "Paul Sanders" <email@hidden>
- Date: Thu, 27 May 2010 15:45:43 +0100
> We need to call some code *once* in the IO thread (to
setup up a pthread_key_t thread local stuff...). Until now we were using a
second IO callback to be added and started (AudioDeviceAddIOProc and
AudioDeviceStart) and that was just removing itself (AudioDeviceStop..;) after
being called.
I'm a bit puzzled as to why you need thread local storage in the IO
thread. It sounds like life would be simpler if you could do away with
this.
> We have just seen that the IO thread identifier (the
one got with pthread_self()) is changed when the machine is
suspended/resumed. So our init code is not properly called anymore when
the IO thread resume. Is there any cleaner and more reliable way to
call some code once in the IO thread and properly handle the suspend/resume
case? (like some notification to be listened to) ?
I may be missing
something here, but if you are using thread-local data the destructor passed to
pthread_key_create should tell you when the IO thread terminates
(I guess you might need an 'I am the IO thread' flag in your thread-specific
data block). And when the new thread starts up (if it ever does),
pthread_getspecific will return NULL so you can start over. This also
applies the first time through, of course.
Paul Sanders.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden