开发者

Finch Audio Engine not opening default OpenAL device

开发者 https://www.devze.com 2023-02-13 03:08 出处:网络
I have an abstract class that initializes Finch to the global variable Finch *engine in the awakeFromNib method as follows:

I have an abstract class that initializes Finch to the global variable Finch *engine in the awakeFromNib method as follows:

engine = [[Finch alloc] init];

None of the abstract class's subclasses override the method. However, whenever I try my program, Finch prints "Finch: Could not open default OpenAL device." in the debugger. Why can't Finch get the default OpenAL device? As far as I can tell I'm doing everything as shown in their code开发者_如何学编程 example.


I just came across the same problem. For me, it was caused by instantiating a Finch object in more than one view controller. For some reason the second one seemed to cancel the first one out and I got that error message whenever I tried to play a sound.

To solve it, I simply created one Finch object in the App Delegate and now it's working perfectly throughout the whole app.

Hope this helps :)


Warning, if you are allocating multiple Finch classes:

In FISoundEngine, the dealloc method calls closeAudioDevice. This closes the OpenAL audio device. And as you probably know, only one OpenAL device exists in your entire app!

So, that means you can only have one engine (and one factory) for your entire app, or you will be closing the device in places where it should stay open.

Whether this is a design flaw, I don't know. I suggested that Finch be turned into a singleton class, but my idea was rejected by the author.

0

精彩评论

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