csvorbis.VorbisFile.prefetch_all_headers C# (CSharp) Method

prefetch_all_headers() static private method

static private prefetch_all_headers ( Info first_i, Comment first_c, int dataoffset ) : void
first_i Info
first_c Comment
dataoffset int
return void
        void prefetch_all_headers(Info first_i,Comment first_c, int dataoffset)
        {
            Page og=new Page();
            int ret;

            vi=new Info[links];
            vc=new Comment[links];
            dataoffsets=new long[links];
            pcmlengths=new long[links];
            serialnos=new int[links];

            for(int i=0;i<links;i++)
            {
                if(first_i!=null && first_c!=null && i==0)
                {
                    // we already grabbed the initial header earlier.  This just
                    // saves the waste of grabbing it again
                    // !!!!!!!!!!!!!
                    vi[i]=first_i;
                    //memcpy(vf->vi+i,first_i,sizeof(vorbis_info));
                    vc[i]=first_c;
                    //memcpy(vf->vc+i,first_c,sizeof(vorbis_comment));
                    dataoffsets[i]=dataoffset;
                }
                else
                {
                    // seek to the location of the initial header
                    seek_helper(offsets[i]); //!!!
                    if(fetch_headers(vi[i], vc[i], null, null)==-1)
                    {
                        Console.Error.WriteLine("Error opening logical bitstream #"+(i+1)+"\n");
                        dataoffsets[i]=-1;
                    }
                    else
                    {
                        dataoffsets[i]=offset;
                        os.clear();
                    }
                }

                // get the serial number and PCM length of this link. To do this,
                // get the last page of the stream
                long end=offsets[i+1]; //!!!
                seek_helper(end);

                while(true)
                {
                    ret=get_prev_page(og);
                    if(ret==-1)
                    {
                        // this should not be possible
                        Console.Error.WriteLine("Could not find last page of logical "+
                            "bitstream #"+(i)+"\n");
                        vi[i].clear();
                        vc[i].clear();
                        break;
                    }
                    if(og.granulepos()!=-1)
                    {
                        serialnos[i]=og.serialno();
                        pcmlengths[i]=og.granulepos();
                        break;
                    }
                }
            }
        }