开发者

Playing OpenAL sounds from background thread

In my iOS app I wan't to play sounds using OpenAL. I have AudioManager class, responsible for sound-management (singleton). All sound sources & buffers are initialized when it is created (on the first instance call).

So to play sound all I need - is to stop previous sound, clear the old buffer (of necessary source), attach new buffer, set pitch & gain and finally, play the sound. All these operations are in playSound:(AMSound)sound method (AMSound is a simple enum).

For UI effects I call this method from main thread. But my app has a lot of background work, which is sometimes also accompanied by sound effects.

开发者_如何学GoCan I call playSound: directly from background threads or should Ido it on main thread only? And what about simultaneous sounds: one created from main thread, another - from background?


Doesn't matter on which thread you call playsound, openAL will actually play it on its own thread anyway. As for simultaneous sounds, it depends on how you want to mix them, anyway, openAL will always manage its own play threads, so from threading perspective it doesn't really matter where you call playsound

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜