Exemple #1
0
BufferPtr Stream::GetNextBuffer(){
    // First get the next decoded buffer
    BufferPtr currentBuffer = this->GetNextDecoderBuffer();

    if(currentBuffer){
        /////////////////////////////////////////////
        // Lets check if the buffer is too small
        bool moreBuffers(true);
        while(currentBuffer->Samples()<this->preferedBufferSampleSize && moreBuffers){
            BufferPtr appendBuffer = this->GetNextDecoderBuffer();
            if(appendBuffer){
                currentBuffer->Append(appendBuffer);
                this->DeleteBuffer(appendBuffer);
            }else{
                moreBuffers = false;
            }
        }
        /////////////////////////////////////////////

        BufferPtr oldBuffer     = this->NewBuffer();

        // Now lets loop through all DSP plugins
        for(Dsps::iterator dsp=this->dsps.begin();dsp!=this->dsps.end();++dsp){
            oldBuffer->CopyFormat(currentBuffer);
            oldBuffer->position = currentBuffer->position;

            if( (*dsp)->ProcessBuffers(currentBuffer.get(),oldBuffer.get()) ){
                // Success in processing DSP, swap the buffers
                currentBuffer.swap(oldBuffer);
            }
        }

        this->DeleteBuffer(oldBuffer);

    }

    return currentBuffer;
}