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:
@@ -104,11 +104,6 @@ fpp_t AudioDevice::getNextBuffer( sampleFrameA * _ab )
|
||||
// release lock
|
||||
unlock();
|
||||
|
||||
if( getMixer()->hasFifoWriter() )
|
||||
{
|
||||
CPU::freeFrames( b );
|
||||
}
|
||||
|
||||
return frames;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user