Oolite 1.91.0.7668-250429-8542c40
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 228 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
@ kNoSlot
#define NEXT(x)
struct OOSoundSourcePoolElement PoolElement
double OOTimeAbsolute
Definition OOTypes.h:223

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


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