I've run into a bit of trouble with OpenAL contexts; but firstly I have some questions.
- Are you allowed to play multiple contexts at the same time?
- The maximum number of sources that can be played at once, is this only associated with each context or for all? So say you can only have 32 sources playing at once, if you have a second context playing can you have 64 sources then playing at once?
- If the maximum number of sources being played at once isn't associated with each context, then if there's another OpenAL application running would this be using some of those playable sources?
Now I've just assumed I can play multiple contexts at the same time. I know you can have multiple and switch between them but I couldn't find out if you could have them playing altogether. So that's what I tried.
By play I mean process (alcProcessContext) and stop I mean suspend (alcSuspendContext).
If I play one context and stop it then play another context and stop it, all works fine. But if I play one context then play a second context, and all is still fine until I go to stop one of them. Since when I stop one (doesn't matter which) it will only stop the context that was played after the first one, then after that has been stopped to stop the first context I need to play and stop and then it will stop.
For instance:
a = context 1
b = context 2
a: play
b: play
(Both are playing and all appears fine)
b: stop (or a: stop)
(Whatever stop is used, it will only stop b)
a: stop
(a will not stop)
a: play
a: stop
(a has stopped)
OpenAL Playing multiple contexts
I've run into a bit of trouble with OpenAL contexts; but firstly I have some questions.
- Are you allowed to play multiple contexts at the same time?
- The maximum number of sources that can be played at once, is this only associated with each context or for all? So say you can only have 32 sources playing at once, if you have a second context playing can you have 64 sources then playing at once?
- If the maximum number of sources being played at once isn't associated with each context, then if there's another OpenAL application running would this be using some of those playable sources?
Now I've just assumed I can play multiple contexts at the same time. I know you can have multiple and switch between them but I couldn't find out if you could have them playing altogether. So that's what I tried.
By play I mean process (alcProcessContext) and stop I mean suspend (alcSuspendContext).
If I play one context and stop it then play another context and stop it, all works fine. But if I play one context then play a second context, and all is still fine until I go to stop one of them. Since when I stop one (doesn't matter which) it will only stop the context that was played after the first one, then after that has been stopped to stop the first context I need to play and stop and then it will stop.
For instance:
a = context 1
b = context 2
a: play
b: play
(Both are playing and all appears fine)
b: stop (or a: stop)
(Whatever stop is used, it will only stop
a: stop
(a will not stop)
a: play
a: stop
(a has stopped)
The number of available channels is driver/hardware bound. I doubt that using multiple context will increase the real number of sources. It is more likely that multiple contexts (either in the same process or in multiple procresses) will overwrite the "play" commands of each other.
Although you can use and process multiple contexts in a single program concurrently, you can only manipulate one at a time. So, ensure to switch to the right context before calling the suspend/process (alcMakeContextCurrent).
I would sugguest to keep only one context. If you need to play more than the available (hardware) channels, you need to write some kind of sound manager. This sound manager works on top of OpenAL and decides which game entity is able to play a certain sound. You need some kind of basic culling (ignore sources which are too far away) and some priority handling (a npc telling you some important information should have a higher priority than some background water drop sounds ).
[quote name='bottomy' timestamp='1299423161' post='4782417']
I've run into a bit of trouble with OpenAL contexts; but firstly I have some questions.
- Are you allowed to play multiple contexts at the same time?
- The maximum number of sources that can be played at once, is this only associated with each context or for all? So say you can only have 32 sources playing at once, if you have a second context playing can you have 64 sources then playing at once?
- If the maximum number of sources being played at once isn't associated with each context, then if there's another OpenAL application running would this be using some of those playable sources?
Now I've just assumed I can play multiple contexts at the same time. I know you can have multiple and switch between them but I couldn't find out if you could have them playing altogether. So that's what I tried.
By play I mean process (alcProcessContext) and stop I mean suspend (alcSuspendContext).
If I play one context and stop it then play another context and stop it, all works fine. But if I play one context then play a second context, and all is still fine until I go to stop one of them. Since when I stop one (doesn't matter which) it will only stop the context that was played after the first one, then after that has been stopped to stop the first context I need to play and stop and then it will stop.
For instance:
a = context 1
b = context 2
a: play
b: play
(Both are playing and all appears fine)
b: stop (or a: stop)
(Whatever stop is used, it will only stop
a: stop
(a will not stop)
a: play
a: stop
(a has stopped)
The number of available channels is driver/hardware bound. I doubt that using multiple context will increase the real number of sources. It is more likely that multiple contexts (either in the same process or in multiple procresses) will overwrite the "play" commands of each other.
Although you can use and process multiple contexts in a single program concurrently, you can only manipulate one at a time. So, ensure to switch to the right context before calling the suspend/process (alcMakeContextCurrent).
I would sugguest to keep only one context. If you need to play more than the available (hardware) channels, you need to write some kind of sound manager. This sound manager works on top of OpenAL and decides which game entity is able to play a certain sound. You need some kind of basic culling (ignore sources which are too far away) and some priority handling (a npc telling you some important information should have a higher priority than some background water drop sounds ).
[/quote]
Thanks, that was my problem with the suspend, I didn't realize you had to have the context as current because I thought since you're passing in the context it wasn't needed. Same with the process too, though I happened to set the current context for that, so that was why I wasn't getting the same trouble with that.
And I did make a sound manager then after I made it I started fiddling with multiple contexts; how I had it set up was it saved 2 sources used for playing music, and the rest was for all other kinds of sounds. So I had priority orientated queues and a few other factors to decide what sounds to play. But I thought having multiple contexts would be better because I could then keep different groups of sounds with different contexts, so I could have one context for music, one for menu sounds, one for environment sounds (or could split that up further), etc.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement