Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOSoundSourcePool(Private) Category Reference

Instance Methods

(uint8_t) - selectSlotForPriority:
 

Detailed Description

Definition at line 47 of file OOSoundSourcePool.m.

Method Documentation

◆ selectSlotForPriority:

- (uint8_t) selectSlotForPriority: (float) priority

Extends class OOSoundSourcePool.

Definition at line 43 of file OOSoundSourcePool.m.

228 :(float)priority
229{
230 uint8_t curr, count, expiredLower = kNoSlot, unexpiredLower = kNoSlot, expiredEqual = kNoSlot;
231 PoolElement *element = NULL;
232 OOTimeAbsolute now = [UNIVERSE getTime];
233
234#define NEXT(x) (((x) + 1) % _count)
235
236 curr = _latest;
237 count = _count;
238 do
239 {
240 curr = NEXT(curr);
241 element = &_sources[curr];
242
243 if (element->source == nil || ![element->source isPlaying]) return curr; // Best type of slot: empty
244 else if (element->priority < priority)
245 {
246 if (element->expiryTime <= now) expiredLower = curr; // Second-best type: expired lower-priority
247 else if (curr != _reserved) unexpiredLower = curr; // Third-best type: unexpired lower-priority
248 }
249 else if (element->priority == priority && element->expiryTime <= now)
250 {
251 expiredEqual = curr; // Fourth-best type: expired equal-priority.
252 }
253 } while (--count);
254
255 if (expiredLower != kNoSlot) return expiredLower;
256 if (unexpiredLower != kNoSlot) return unexpiredLower;
257 return expiredEqual; // Will be kNoSlot if none found
258}
unsigned count
return nil
#define NEXT(x)
@ kNoSlot
double OOTimeAbsolute
Definition OOTypes.h:223

The documentation for this category was generated from the following file: