/// <summary> /// Indicate if the server voice information needs to be updated. /// </summary> /// <param name="parameter">The user parameter.</param> /// <returns>Return true, if the server voice information needs to be updated.</returns> private bool ShouldUpdateParameters(ref VoiceInParameter parameter) { if (DataSourceStateAddressInfo.CpuAddress == parameter.DataSourceStateAddress) { return(DataSourceStateAddressInfo.Size != parameter.DataSourceStateSize); } return(DataSourceStateAddressInfo.CpuAddress != parameter.DataSourceStateAddress || DataSourceStateAddressInfo.Size != parameter.DataSourceStateSize || DataSourceStateUnmapped); }
/// <summary> /// Write the status of the voice to the given user output. /// </summary> /// <param name="outStatus">The given user output.</param> /// <param name="parameter">The user parameter.</param> /// <param name="voiceUpdateStates">The voice states associated to the <see cref="VoiceState"/>.</param> public void WriteOutStatus(ref VoiceOutStatus outStatus, ref VoiceInParameter parameter, Memory <VoiceUpdateState>[] voiceUpdateStates) { #if DEBUG // Sanity check in debug mode of the internal state if (!parameter.IsNew && !IsNew) { for (int i = 1; i < ChannelsCount; i++) { ref VoiceUpdateState stateA = ref voiceUpdateStates[i - 1].Span[0]; ref VoiceUpdateState stateB = ref voiceUpdateStates[i].Span[0]; Debug.Assert(stateA.WaveBufferConsumed == stateB.WaveBufferConsumed); Debug.Assert(stateA.PlayedSampleCount == stateB.PlayedSampleCount); Debug.Assert(stateA.Offset == stateB.Offset); Debug.Assert(stateA.WaveBufferIndex == stateB.WaveBufferIndex); Debug.Assert(stateA.Fraction == stateB.Fraction); Debug.Assert(stateA.IsWaveBufferValid.SequenceEqual(stateB.IsWaveBufferValid)); }
/// <summary> /// Update the internal state from a user parameter. /// </summary> /// <param name="outErrorInfo">The possible <see cref="ErrorInfo"/> that was generated.</param> /// <param name="parameter">The user parameter.</param> /// <param name="poolMapper">The mapper to use.</param> /// <param name="behaviourContext">The behaviour context.</param> public void UpdateParameters(out ErrorInfo outErrorInfo, ref VoiceInParameter parameter, ref PoolMapper poolMapper, ref BehaviourContext behaviourContext) { InUse = parameter.InUse; Id = parameter.Id; NodeId = parameter.NodeId; UpdatePlayState(parameter.PlayState); SrcQuality = parameter.SrcQuality; Priority = parameter.Priority; SortingOrder = parameter.SortingOrder; SampleRate = parameter.SampleRate; SampleFormat = parameter.SampleFormat; ChannelsCount = parameter.ChannelCount; Pitch = parameter.Pitch; Volume = parameter.Volume; parameter.BiquadFilters.ToSpan().CopyTo(BiquadFilters.ToSpan()); WaveBuffersCount = parameter.WaveBuffersCount; WaveBuffersIndex = parameter.WaveBuffersIndex; if (behaviourContext.IsFlushVoiceWaveBuffersSupported()) { FlushWaveBufferCount += parameter.FlushWaveBufferCount; } MixId = parameter.MixId; if (behaviourContext.IsSplitterSupported()) { SplitterId = parameter.SplitterId; } else { SplitterId = RendererConstants.UnusedSplitterId; } parameter.ChannelResourceIds.ToSpan().CopyTo(ChannelResourceIds.ToSpan()); DecodingBehaviour behaviour = DecodingBehaviour.Default; if (behaviourContext.IsDecodingBehaviourFlagSupported()) { behaviour = parameter.DecodingBehaviourFlags; } DecodingBehaviour = behaviour; if (parameter.ResetVoiceDropFlag) { VoiceDropFlag = false; } if (ShouldUpdateParameters(ref parameter)) { DataSourceStateUnmapped = !poolMapper.TryAttachBuffer(out outErrorInfo, ref DataSourceStateAddressInfo, parameter.DataSourceStateAddress, parameter.DataSourceStateSize); } else { outErrorInfo = new ErrorInfo(); } }