From 2f24d635c34f5aa146a6adf1eb5b39c3447dd57e Mon Sep 17 00:00:00 2001 From: Alexandre Almeida Date: Sun, 9 Aug 2015 11:50:12 -0300 Subject: [PATCH] Add a MINIMUM_BUFFER_SIZE constant and comments --- src/core/Mixer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 51d8e2666..5e204f08b 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -85,22 +85,26 @@ Mixer::Mixer( bool renderOnly ) : // determine FIFO size and number of frames per period int fifoSize = 1; + // if not only rendering (that is, using the GUI), load the buffer + // size from user configuration if( renderOnly == false ) { m_framesPerPeriod = ( fpp_t ) ConfigManager::inst()-> value( "mixer", "framesperaudiobuffer" ).toInt(); - if( m_framesPerPeriod < 32 ) + // if the value read from user configuration is not set or + // lower than the minimum allowed, use the default value and + // save it to the configuration + if( m_framesPerPeriod < MINIMUM_BUFFER_SIZE ) { ConfigManager::inst()->setValue( "mixer", - "framesperaudiobuffer", + "framesperaudiobuffer", QString::number( DEFAULT_BUFFER_SIZE ) ); m_framesPerPeriod = DEFAULT_BUFFER_SIZE; } - - if( m_framesPerPeriod > DEFAULT_BUFFER_SIZE ) + else if( m_framesPerPeriod > DEFAULT_BUFFER_SIZE ) { fifoSize = m_framesPerPeriod / DEFAULT_BUFFER_SIZE; m_framesPerPeriod = DEFAULT_BUFFER_SIZE;