Exemple #1
0
        /// <summary>
        /// Update the internal play state from user play state.
        /// </summary>
        /// <param name="userPlayState">The target user play state.</param>
        public void UpdatePlayState(PlayState userPlayState)
        {
            Types.PlayState oldServerPlayState = PlayState;

            PreviousPlayState = oldServerPlayState;

            Types.PlayState newServerPlayState;

            switch (userPlayState)
            {
            case Common.PlayState.Start:
                newServerPlayState = Types.PlayState.Started;
                break;

            case Common.PlayState.Stop:
                if (oldServerPlayState == Types.PlayState.Stopped)
                {
                    return;
                }

                newServerPlayState = Types.PlayState.Stopping;
                break;

            case Common.PlayState.Pause:
                newServerPlayState = Types.PlayState.Paused;
                break;

            default:
                throw new NotImplementedException($"Unhandled PlayState.{userPlayState}");
            }

            PlayState = newServerPlayState;
        }
Exemple #2
0
        /// <summary>
        /// Initialize the <see cref="VoiceState"/>.
        /// </summary>
        public void Initialize()
        {
            IsNew                   = false;
            VoiceDropFlag           = false;
            DataSourceStateUnmapped = false;
            BufferInfoUnmapped      = false;
            FlushWaveBufferCount    = 0;
            PlayState               = Types.PlayState.Stopped;
            Priority                = RendererConstants.VoiceLowestPriority;
            Id             = 0;
            NodeId         = 0;
            SampleRate     = 0;
            SampleFormat   = SampleFormat.Invalid;
            ChannelsCount  = 0;
            Pitch          = 0.0f;
            Volume         = 0.0f;
            PreviousVolume = 0.0f;
            BiquadFilters.ToSpan().Fill(new BiquadFilterParameter());
            WaveBuffersCount = 0;
            WaveBuffersIndex = 0;
            MixId            = RendererConstants.UnusedMixId;
            SplitterId       = RendererConstants.UnusedSplitterId;
            DataSourceStateAddressInfo.Setup(0, 0);

            InitializeWaveBuffers();
        }