示例#1
0
        private void FillBuffer()
        {
            // load the indices from the database
            indexCount   = 0;
            currentIndex = 0;
            bool continuousData;

            bool streamOutOfData = DatabaseUtility.LoadIndices(indices, endingTick + 1, streamID, frame.Buffer.Length,
                                                               out indexCount, out minOffset, out maxOffset, out continuousData);

            //Debug.WriteLine("FillBuffer for StreamID=" + streamID.ToString() + "; starting tick=" + (endingTick + 1).ToString());

            // load the associated buffer from the database if we're not empty....
            if (indexCount > 0)
            {
                /// Note on data quirks: Sometimes the raw data from the archive service is out of order.
                /// I think this is a bug in Archive Service.  The indices are in order by timestamp, but the start/end fields may not
                /// align one after another.  In this case there are also corresponding discontinuities in the raw data.
                /// To work around this we have LoadIndices keep track of the minimum start and the maximum end in the
                /// indices we've just fetched.  They are not necessarily the first and last items in the array.
                /// We also add a check to make sure we don't try to fetch more data than the frame buffer can
                /// hold.

                if (!continuousData)
                {
                    DateTime dt = new DateTime(this.endingTick + 1);
                    Console.WriteLine("DBStreamPlayer.FillBuffer: A data discontinuity was found for streamID=" + streamID.ToString() + ";near time=" + dt.ToString());
                }

                this.startingTick = indices[0].timestamp;
                this.endingTick   = indices[indexCount - 1].timestamp;

                DatabaseUtility.LoadBuffer(streamID, minOffset, maxOffset, ref frame);
            }
            else
            {
                streamEndReached = true;
            }
        }