示例#1
0
        public void OnBufferChanged(IAudioBufferProto eventSource)
        {
            if (FlowRiderSettings.IsFlowRecorded == false)
            {
                return;
            }

            lock (_flowDictionary)
            {
                if (_flowDictionary.ContainsKey(eventSource.BufferUid) == false)
                {
                    _flowDictionary.Add(eventSource.BufferUid, new List <BufferFlowDescription>());

                    if (string.IsNullOrEmpty(eventSource.Name))
                    {
                        throw new BuffersException(
                                  $"Unable to register flow for unnamed buffer with UID {eventSource.BufferUid}");
                    }

                    _flowBufferNames.Add(eventSource.BufferUid, eventSource.Name);
                }

                var flowList = _flowDictionary[eventSource.BufferUid];

                var lastState    = flowList.LastOrDefault();
                var currentState = BufferFlowDescription.FromSource(eventSource);

                if (lastState == null && currentState.DataLength == 0)
                {
                    return;
                }

                flowList.Add(currentState);
            }
        }
 public static BufferFlowDescription FromSource(IAudioBufferProto source)
 {
     return(new BufferFlowDescription
     {
         Priority = source.Priority,
         SampleRate = source.SampleRate,
         Channels = source.Channels,
         DataLength = source.DataLengthSamples,
         BufferLastTimestamp = source.LastTimestamp
     });
 }