Mixer, FifoBuffer, AudioDevice: removed memory allocation/free cycles

There's really no need to allocate a buffer each period, push it to the
FifoBuffer and free it when fetching the buffer in
AudioDevice::getNextBuffer(). Instead keep the pointer in FifoBuffer's
pool and reuse it.
This commit is contained in:
Tobias Doerffel
2009-11-24 12:40:56 +01:00
parent 9cabd559dc
commit c517f1fa5a
3 changed files with 16 additions and 7 deletions

View File

@@ -104,11 +104,6 @@ fpp_t AudioDevice::getNextBuffer( sampleFrameA * _ab )
// release lock
unlock();
if( getMixer()->hasFifoWriter() )
{
CPU::freeFrames( b );
}
return frames;
}

View File

@@ -1151,8 +1151,12 @@ void mixer::fifoWriter::run()
const fpp_t frames = m_mixer->framesPerPeriod();
while( m_writing )
{
sampleFrameA * buffer = CPU::allocFrames( frames );
const sampleFrameA * b = m_mixer->renderNextBuffer();
sampleFrameA * buffer = m_fifo->nextWriteBuffer();
if( buffer == NULL )
{
buffer = CPU::allocFrames( frames );
}
CPU::memCpy( buffer, b, frames * sizeof( sampleFrameA ) );
m_fifo->write( buffer );
}