I have a main view (or a scene in cocos2d) that opens when the app is starts .
from there i call the audioUnit to listen to the input audio that comes from microphone .
it works great (the callbacks on audioUnit are called always and do stuff) , but i can see that it takes the main thread- something that i dont want because the main scene has UILabel and other stuff that needs to be the main thread in order to be changed .
at the main scene i do at the start :
remoteIns=[[remoteIO alloc]init]; //turn on the callback function on class remoteIO .
[remoteIns StartListeningWithFrequency]; // this function takes the main thread
then when i check in the main scene later with :
NSLog(@"isMainThread%d",[NSThread isMainThread]);
i can see it’s not the main thread ,hence i cant change UILabels in it .
I need to start the audioUnit function (another class) and set it to be in another thread, keep the main scene to be the main thread, and let the audioUnit work good .
The audio Unit is not in the main thread.
But the main scene is also not in the main thread.
In order to change the UILabel on the main scene , it most be the main thread, so i change its text with this : (its being called in the scene observer to call a function that changes the text :
and in
updateText:i change the text. it works great .