Oolite
Loading...
Searching...
No Matches
OOSoundSourcePool(Private) Category Reference

Instance Methods

(uint8_t) - selectSlotForPriority:

Detailed Description

Definition at line 42 of file OOSoundSourcePool.m.

Method Documentation

◆ selectSlotForPriority:

- (uint8_t) selectSlotForPriority: (float) priority

Extends class OOSoundSourcePool.

Definition at line 216 of file OOSoundSourcePool.m.

216 :(float)priority
217{
218 uint8_t curr, count, expiredLower = kNoSlot, unexpiredLower = kNoSlot, expiredEqual = kNoSlot;
219 PoolElement* element = NULL;
220 OOTimeAbsolute now = [UNIVERSE getTime];
221
222#define NEXT(x) (((x) + 1) % _count)
223
224 curr = _latest;
225 count = _count;
226 do {
227 curr = NEXT(curr);
228 element = &_sources[curr];
229
230 if (element->source == nil || ![element->source isPlaying])
231 return curr; // Best type of slot: empty
232 else if (element->priority < priority) {
233 if (element->expiryTime <= now)
234 expiredLower = curr; // Second-best type: expired lower-priority
235 else if (curr != _reserved)
236 unexpiredLower = curr; // Third-best type: unexpired lower-priority
237 } else if (element->priority == priority && element->expiryTime <= now) {
238 expiredEqual = curr; // Fourth-best type: expired equal-priority.
239 }
240 } while (--count);
241
242 if (expiredLower != kNoSlot)
243 return expiredLower;
244 if (unexpiredLower != kNoSlot)
245 return unexpiredLower;
246 return expiredEqual; // Will be kNoSlot if none found
247}
unsigned count
return nil
@ kNoSlot
#define NEXT(x)
struct OOSoundSourcePoolElement PoolElement
double OOTimeAbsolute
Definition OOTypes.h:192

References count, OOSoundSourcePoolElement::expiryTime, kNoSlot, NEXT, nil, OOSoundSourcePoolElement::priority, and OOSoundSourcePoolElement::source.


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