OGRECave / ogre-audiovideo

plugins for theora video playback and openAL audio
https://ogrecave.github.io/ogre-audiovideo/
BSD 3-Clause "New" or "Revised" License
14 stars 11 forks source link

Properly release resources when finalizing the Plugin #23

Closed sercero closed 3 years ago

sercero commented 3 years ago

In function OgreOggSoundManager::_createSourcePool() there were lots of calls to alGenSources(), they were replaced with one call (same thing when releasing with alDeleteSources()).

Initially the objective was to try to understand why I'm getting this warning from OpenAL Soft: "[ALSOFT] (WW) 1 Source not deleted".

So, the problem was that mSourcePool was being used in OgreOggSoundManager::_releaseAll() to query which sources to destroy.

That is wrong because the pool gets depeleted each time that a sound source is requested by the Manager.

In sinthesis: mSourcePool should not be used to tell which sources to destroy at the end.

sercero commented 3 years ago

@paroj your suggestions let me thinking about the original code and that there might be some merit in what they were doing.

What they were doing is calling alGenSources() until MaxSources or until it failed.

My changes assumed that there is always enough memory to create MaxSources, but I don't know how much memory does it take but probably is not much.

I have to think this change better.

Should I close the pull request?

paroj commented 3 years ago

there might be some merit in what they were doing.

yes, according to this, it is the only documented way to stay below the context limit: https://stackoverflow.com/questions/2871905/openal-determine-maximum-sources

however, given that OpenAL Soft is the go-to implementation nowadays, you could also just assume that the 100 sources we request by default just work.

sercero commented 3 years ago

@paroj I will open another pull request since I created a new branch with a slightly different approach

paroj commented 3 years ago

superceded by #24