␉␉␉␉␉}␊ |
␉␉␉␉␉else if (maxCueBehavior == MaxInstanceBehavior.ReplaceOldest)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉INTERNAL_removeOldestCue(activeCues[0].Name);␊ |
␉␉␉␉␉␉if (!INTERNAL_removeOldestCue(activeCues[0].Name))␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉return false; // Just ignore us...␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉}␊ |
␉␉␉␉␉else if (maxCueBehavior == MaxInstanceBehavior.ReplaceQuietest)␊ |
␉␉␉␉␉{␊ |
|
␉␉␉␉␉␉int lowestIndex = -1;␊ |
␉␉␉␉␉␉for (int i = 0; i < activeCues.Count; i += 1)␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉float vol = activeCues[i].INTERNAL_calculateVolume();␊ |
␉␉␉␉␉␉␉if (vol < lowestVolume)␊ |
␉␉␉␉␉␉␉if (!activeCues[i].JustStarted)␊ |
␉␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉␉lowestVolume = vol;␊ |
␉␉␉␉␉␉␉␉lowestIndex = i;␊ |
␉␉␉␉␉␉␉␉float vol = activeCues[i].INTERNAL_calculateVolume();␊ |
␉␉␉␉␉␉␉␉if (vol < lowestVolume)␊ |
␉␉␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉␉␉lowestVolume = vol;␊ |
␉␉␉␉␉␉␉␉␉lowestIndex = i;␊ |
␉␉␉␉␉␉␉␉}␊ |
␉␉␉␉␉␉␉}␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉␉if (lowestIndex > -1)␊ |
|
␉␉␉␉␉␉␉cueInstanceCounts[activeCues[lowestIndex].Name] -= 1;␊ |
␉␉␉␉␉␉␉activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored);␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉␉else␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉return false; // Just ignore us...␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉}␊ |
␉␉␉␉␉else if (maxCueBehavior == MaxInstanceBehavior.ReplaceLowestPriority)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉// FIXME: Priority?␊ |
␉␉␉␉␉␉INTERNAL_removeOldestCue(activeCues[0].Name);␊ |
␉␉␉␉␉␉if (!INTERNAL_removeOldestCue(activeCues[0].Name));␊ |
␉␉␉␉␉␉{␊ |
␉␉␉␉␉␉␉return false; // Just ignore us...␊ |
␉␉␉␉␉␉}␊ |
␉␉␉␉␉}␊ |
␉␉␉␉}␊ |
␉␉␉␉cueInstanceCounts[newCue.Name] += 1;␊ |
|
␉␉␉return true;␊ |
␉␉}␊ |
␊ |
␉␉internal void INTERNAL_removeLatestCue()␊ |
␉␉{␊ |
␉␉␉lock (activeCues)␊ |
␉␉␉{␊ |
␉␉␉␉Cue toDie = activeCues[activeCues.Count - 1];␊ |
␉␉␉␉cueInstanceCounts[toDie.Name] -= 1;␊ |
␉␉␉␉activeCues.RemoveAt(activeCues.Count - 1);␊ |
␉␉␉}␊ |
␉␉}␊ |
␊ |
␉␉internal void INTERNAL_removeOldestCue(string name)␊ |
␉␉internal bool INTERNAL_removeOldestCue(string name)␊ |
␉␉{␊ |
␉␉␉lock (activeCues)␊ |
␉␉␉{␊ |
␉␉␉␉for (int i = 0; i < activeCues.Count; i += 1)␊ |
␉␉␉␉{␊ |
␉␉␉␉␉if (activeCues[i].Name.Equals(name))␊ |
␉␉␉␉␉if (activeCues[i].Name.Equals(name) && !activeCues[i].JustStarted)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉activeCues[i].Stop(AudioStopOptions.AsAuthored);␊ |
␉␉␉␉␉␉return;␊ |
␉␉␉␉␉␉return true;␊ |
␉␉␉␉␉}␊ |
␉␉␉␉}␊ |
␉␉␉␉return false;␊ |
␉␉␉}␊ |
␉␉}␊ |
␊ |
␉␉internal void INTERNAL_removeQuietestCue(string name)␊ |
␉␉internal bool INTERNAL_removeQuietestCue(string name)␊ |
␉␉{␊ |
␉␉␉float lowestVolume = float.MaxValue;␊ |
␉␉␉int lowestIndex = -1;␊ |
|
␉␉␉{␊ |
␉␉␉␉for (int i = 0; i < activeCues.Count; i += 1)␊ |
␉␉␉␉{␊ |
␉␉␉␉␉if (activeCues[i].Name.Equals(name))␊ |
␉␉␉␉␉if (activeCues[i].Name.Equals(name) && !activeCues[i].JustStarted)␊ |
␉␉␉␉␉{␊ |
␉␉␉␉␉␉float vol = activeCues[i].INTERNAL_calculateVolume();␊ |
␉␉␉␉␉␉if (vol < lowestVolume)␊ |
|
␉␉␉␉{␊ |
␉␉␉␉␉cueInstanceCounts[name] -= 1;␊ |
␉␉␉␉␉activeCues[lowestIndex].Stop(AudioStopOptions.AsAuthored);␊ |
␉␉␉␉␉return true;␊ |
␉␉␉␉}␊ |
␉␉␉␉return false;␊ |
␉␉␉}␊ |
␉␉}␊ |
␊ |