Question

I use OpenAL to play sound from network streaming in my NPAPI plugin (browser plugin). When I open more than one browser's tab, I close one of the tabs, the others' sound also dispeared. Anyone could give me some help? Or anyone can give me some advice for playing stream audio, such as audio from mic or such devices. When I use audio queue service, it still cannot surport multi instances. For work's reason, I cannot paste my code in there, sorry about that. I use OpenAL some way as Apple's Developer's example - oalTouch, the link is https://developer.apple.com/library/ios/samplecode/oalTouch/Introduction/Intro.html

I use the system default device to play sound, which means I use alcOpenDevice(NULL) to open the device.

Was it helpful?

Solution 2

Now I have found the reason. OpenAL do support multi audio source, but when I use it as the oalTouch example, I did not change anything. The reason why I close one browser's tab, the sound stopped is that the device is closed by me when I destroy the plugin instance. So if I want to use it in multi instances, I should design it carefully, and this is my design: I use static var to indicate if the default device is opened, if it is opened, I do not open it again (use alOpenDevice(NULL) method). But for different tabs, I use different sourceId (alGenSource(...) method is used). When I close the browser's teb, the plugin instance is destroyed too. I use the static variable to check if there still have plugin instance use the default audio device, if yes, do nothing, otherwise close the device.

OTHER TIPS

When a page with your plugin closes, the corresponding instance of your plugin is destroyed; there's one instance per plugin that is simultaneously active in the browser. Presumably the problem is that you are doing something in your plugin instance teardown that tears down something global.

Without being able to see anything about what your code is doing, it's hard to see how anyone can help figure out what that thing is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top