| Description | Hierarchy | Fields | Methods | Properties |
type TALSourceAllocator = class(TObject)
This class manages a list of allocated OpenAL sounds.
The idea is that you leave to this class creating and deleting of OpenAL sounds. When you need OpenAL sound to do something, just call AllocateSource method.
This class will manage OpenAL sources in an intelligent manner, which means when you need new sound, we may
reuse already allocated sound that is not used to play anything
allocate new sound (but we will keep allocated sounds count within MaxAllocatedSources sound limit, to not overload OpenAL implementation with work).
we may simply interrupt already allocated sound, if new sound is more important.
This class may exist only when OpenAL context is active (and it's the same OpenAL context).
The very reason behind this class is to hide from you the fact that the number of OpenAL sources are limited. In particular, this means that when OpenAL will run out of sources, no OpenAL error (alGetError) will be left, and no exception will be raised. In the worst case TALSourceAllocator.AllocateSource will return nil, but in more probable cases some other sources (unused, or with less priority) will be reused.
Note that this means that the code in this unit must read in some situations alGetError. That's because reading alGetError is the only way to know when OpenAL implementation has run out of sources. So the code in this unit may in various places raise EALError if you made some error in your OpenAL code, and you didn't check alGetError yourself often enough.
![]() |
constructor Create(const AMinAllocatedSources, AMaxAllocatedSources: Cardinal); |
![]() |
destructor Destroy; override; |
![]() |
function AllocateSource(const Importance: Integer): TALAllocatedSource; |
![]() |
procedure RefreshUsed; |
![]() |
property MinAllocatedSources: Cardinal
read FMinAllocatedSources write SetMinAllocatedSources; |
![]() |
property MaxAllocatedSources: Cardinal
read FMaxAllocatedSources write SetMaxAllocatedSources; |
![]() |
property AllocatedSources: TALAllocatedSourcesList read FAllocatedSources; |
![]() |
constructor Create(const AMinAllocatedSources, AMaxAllocatedSources: Cardinal); |
![]() |
destructor Destroy; override; |
![]() |
function AllocateSource(const Importance: Integer): TALAllocatedSource; |
|
Call this when you need new OpenAL sound. This indicates that you want to use new sound. This is the most important function of this class — actually the sole purpose of TALSourceAllocator and TALAllocatedSource classes is to provide you this function. If we can't allocate new OpenAL sound for this (because we already allocated MaxAllocatedSources, or OpenAL cannot allocate so many sources (so ENoMoreOpenALSources is catched and silenced by this function), and all existing sounds are used and their Importance is > given here Importance), returns nil. Else returns non-nil TALAllocatedSource instance, with Used to to | |
![]() |
procedure RefreshUsed; |
|
Check and eventually set some sources from used to unused state. For every source that is marked as Used, this checks whether this source is actually in playing/paused state right now. If not, it calls DoUsingEnd (thus setting Used to See TALAllocatedSource.OnUsingEnd for more description. Generally, you don't need to call this procedure — this unit is smart, and every operation does such refreshing (at least partially) by itself, when it's really needed (e.g. AllocateSource may do this if no unused source will be found). You may need to call this procedure from time to time if you frequently perform some expensive operation for all used sources. | |
![]() |
property MinAllocatedSources: Cardinal
read FMinAllocatedSources write SetMinAllocatedSources; |
|
For the sake of speed, this class always has allocated at least Setting this to too large value (so large that OpenAL cannot create so many sources) will raise ENoMoreOpenALSources. Also creating the TALSourceAllocator instance with initial value for | |
![]() |
property MaxAllocatedSources: Cardinal
read FMaxAllocatedSources write SetMaxAllocatedSources; |
|
This class always has allocated at most This must always be >= MinAllocatedSources. | |
![]() |
property AllocatedSources: TALAllocatedSourcesList read FAllocatedSources; |
|
This is read-only from outside. You can read | |