protected override void OnModifications(WaveformPreview.MessageFlags cFlags)
        {
            bool flag = false;

            if (WaveformPreview.HasFlag(cFlags, WaveformPreview.MessageFlags.TextureChanged) || WaveformPreview.HasFlag(cFlags, WaveformPreview.MessageFlags.Size) || WaveformPreview.HasFlag(cFlags, WaveformPreview.MessageFlags.Length) || WaveformPreview.HasFlag(cFlags, WaveformPreview.MessageFlags.Looping))
            {
                this.KillAndClearStreamers();
                if (base.length <= 0.0)
                {
                    return;
                }
                StreamedAudioClipPreview.ClipPreviewDetails details = new StreamedAudioClipPreview.ClipPreviewDetails(this.m_Clip, base.looping, (int)base.Size.x, base.start, base.length);
                this.UploadPreview(details);
                if (details.IsCandidateForStreaming())
                {
                    flag = true;
                }
            }
            if (!base.optimized)
            {
                this.KillAndClearStreamers();
                flag = false;
            }
            else if (WaveformPreview.HasFlag(cFlags, WaveformPreview.MessageFlags.Optimization) && !flag)
            {
                StreamedAudioClipPreview.ClipPreviewDetails clipPreviewDetails = new StreamedAudioClipPreview.ClipPreviewDetails(this.m_Clip, base.looping, (int)base.Size.x, base.start, base.length);
                if (clipPreviewDetails.IsCandidateForStreaming())
                {
                    flag = true;
                }
            }
            if (flag)
            {
                this.m_StreamedSegments = this.CalculateAndStartStreamers(base.start, base.length);
                if (this.m_StreamedSegments != null && this.m_StreamedSegments.Length > 0)
                {
                    StreamedAudioClipPreview.Segment[] streamedSegments = this.m_StreamedSegments;
                    for (int i = 0; i < streamedSegments.Length; i++)
                    {
                        StreamedAudioClipPreview.Segment segment = streamedSegments[i];
                        if (!this.m_Contexts.ContainsKey(segment.streamer))
                        {
                            this.m_Contexts.Add(segment.streamer, new StreamedAudioClipPreview.StreamingContext());
                        }
                    }
                }
            }
            base.OnModifications(cFlags);
        }
        private StreamedAudioClipPreview.Segment[] CalculateAndStartStreamers(double localStart, double localLength)
        {
            double num = localStart;

            localStart %= (double)this.m_Clip.length;
            double num2 = localLength / (double)base.Size.x;

            StreamedAudioClipPreview.Segment[] result;
            if (!base.looping)
            {
                if (num > (double)this.m_Clip.length)
                {
                    result = null;
                }
                else
                {
                    double num3 = Math.Min((double)this.m_Clip.length - num, localLength);
                    int    num4 = (int)Math.Min((double)base.Size.x, (double)base.Size.x * Math.Max(0.0, num3 / localLength));
                    if (num4 < 1)
                    {
                        result = null;
                    }
                    else
                    {
                        StreamedAudioClipPreview.Segment[] array = new StreamedAudioClipPreview.Segment[1];
                        array[0].streamer             = new WaveformStreamer(this.m_Clip, num, num3, num4, new Func <WaveformStreamer, float[], int, bool>(this.OnNewWaveformData));
                        array[0].segmentLength        = (int)base.Size.x;
                        array[0].textureOffset        = 0;
                        array[0].streamingIndexOffset = 0;
                        result = array;
                    }
                }
            }
            else
            {
                StreamedAudioClipPreview.Segment[] array;
                if (localStart + localLength - num2 > (double)this.m_Clip.length)
                {
                    double num5 = (double)base.Size.x / localLength;
                    if (localLength >= (double)this.m_Clip.length)
                    {
                        double           num6     = localLength / (double)this.m_Clip.length;
                        WaveformStreamer streamer = new WaveformStreamer(this.m_Clip, 0.0, (double)this.m_Clip.length, (int)((double)base.Size.x / num6), new Func <WaveformStreamer, float[], int, bool>(this.OnNewWaveformData));
                        double           num7     = (double)this.m_Clip.length - localStart;
                        double           num8     = 0.0;
                        array = new StreamedAudioClipPreview.Segment[Mathf.CeilToInt((float)((localStart + localLength) / (double)this.m_Clip.length))];
                        for (int i = 0; i < array.Length; i++)
                        {
                            double num9 = Math.Min(num7 + num8, localLength) - num8;
                            array[i].streamer             = streamer;
                            array[i].segmentLength        = (int)(num9 * num5);
                            array[i].textureOffset        = (int)(num8 * num5);
                            array[i].streamingIndexOffset = (int)(((double)this.m_Clip.length - num7) * num5);
                            num8 += num7;
                            num7  = (double)this.m_Clip.length;
                        }
                    }
                    else
                    {
                        double num10 = (double)this.m_Clip.length - localStart;
                        double num11 = localLength - num10;
                        array                         = new StreamedAudioClipPreview.Segment[2];
                        array[0].streamer             = new WaveformStreamer(this.m_Clip, localStart, num10, (int)(num10 * num5), new Func <WaveformStreamer, float[], int, bool>(this.OnNewWaveformData));
                        array[0].segmentLength        = (int)(num10 * num5);
                        array[0].textureOffset        = 0;
                        array[0].streamingIndexOffset = 0;
                        array[1].streamer             = new WaveformStreamer(this.m_Clip, 0.0, num11, (int)(num11 * num5), new Func <WaveformStreamer, float[], int, bool>(this.OnNewWaveformData));
                        array[1].segmentLength        = (int)(num11 * num5);
                        array[1].textureOffset        = (int)(num10 * num5);
                        array[1].streamingIndexOffset = 0;
                    }
                }
                else
                {
                    array                         = new StreamedAudioClipPreview.Segment[1];
                    array[0].streamer             = new WaveformStreamer(this.m_Clip, localStart, localLength, (int)base.Size.x, new Func <WaveformStreamer, float[], int, bool>(this.OnNewWaveformData));
                    array[0].segmentLength        = (int)base.Size.x;
                    array[0].textureOffset        = 0;
                    array[0].streamingIndexOffset = 0;
                }
                result = array;
            }
            return(result);
        }