예제 #1
0
    // simply return contents of the file (if applicable applying its own compression)
    // idx and off are values where the file will be stored at - so the callee
    // better write it down to talk about it later via meta()
    //
    // if the file wishes to flush current chunk it is in, it can return true
    public void GetData(ChunkBuilder cb, Stream os)
    {
        cb.FlushOnOverflow((int)orig_size, MAXSIZE, os);
        cb.lastf = this;
        ushort chp = cb.chpos;

        chpos     = chp;
        chunk_idx = cb.idx;
        chunk_off = (uint)cb.buffer.Length;
        if (chpos == 0)
        {
            Debug.Assert(chunk_off == 0);
        }
        var src = pp.CreateReadStream();

        if (naked)
        {
            var wav = new byte[orig_size];
            src.Read(wav, 0, (int)orig_size);
            encodeWavToOpus(wav, cb.buffer);
            //encodeWavToFLAC(wav, cb.buffer);
        }
        else
        {
            src.CopyTo(cb.buffer);
        }
    }