示例#1
0
        protected void UpdateScheduledTime()
        {
            if (state == AudioStates.Stopped)
            {
                return;
            }

            UpdateDelays();

            // Schedule sources
            int    delayIndex    = sourcesIndex - sources.Count;
            double remainingTime = 0d;

            for (int i = 0; i < sources.Count; i++)
            {
                IAudioItem item = sources[i];
                double     time;

                if (i == 0)
                {
                    time = Math.Max(AudioSettings.dspTime, scheduledTime) + delay;
                }
                else
                {
                    time = AudioSettings.dspTime + remainingTime;
                }

                if (state == AudioStates.Playing && item.State == AudioStates.Waiting)
                {
                    item.PlayScheduled(time);
                }
                else
                {
                    item.SetScheduledTime(time);
                }

                if (delayIndex < settings.Delays.Count)
                {
                    remainingTime = item.RemainingTime() + settings.Delays[delayIndex++];
                }
                else
                {
                    remainingTime = item.RemainingTime();
                }
            }
        }
示例#2
0
        protected void UpdateScheduledTime()
        {
            if (state == AudioStates.Stopped)
            {
                return;
            }

            UpdateDeltaTime();
            double remainingTime = 0d;

            requestNextSettings = state != AudioStates.Paused;

            for (int i = 0; i < sources.Count; i++)
            {
                IAudioItem       source = sources[i];
                AudioDynamicData data   = dynamicData[i];

                // Decrease delay
                if (state != AudioStates.Paused)
                {
                    switch (data.PlayMode)
                    {
                    case AudioDynamicData.PlayModes.Now:
                        data.Delay = Math.Max(data.Delay - deltaTime, 0d);
                        break;

                    case AudioDynamicData.PlayModes.After:
                        if (i == 0)
                        {
                            data.Delay = Math.Max(data.Delay - deltaTime, 0d);
                        }
                        else
                        {
                            requestNextSettings = false;
                        }
                        break;
                    }

                    if (data.Delay > 0d)
                    {
                        requestNextSettings = false;
                    }
                }

                // Schedule source
                double time = Math.Max(AudioSettings.dspTime, scheduledTime) + remainingTime + data.Delay;

                if (state == AudioStates.Playing && source.State == AudioStates.Waiting)
                {
                    source.PlayScheduled(time);
                }
                else
                {
                    source.SetScheduledTime(time);
                }

                // Set remaining time
                switch (data.PlayMode)
                {
                case AudioDynamicData.PlayModes.Now:
                    remainingTime = data.Delay;
                    break;

                case AudioDynamicData.PlayModes.After:
                    remainingTime = source.RemainingTime();
                    break;
                }
            }
        }