Merge pull request #2237 from M374LX/iss1878

Fix #1878
This commit is contained in:
Colin Wallace
2015-08-09 09:08:25 -07:00
6 changed files with 33 additions and 32 deletions

View File

@@ -46,7 +46,7 @@ class EXPORT Engine : public QObject
{
Q_OBJECT
public:
static void init();
static void init( bool renderOnly );
static void destroy();
// core

View File

@@ -57,6 +57,7 @@ class MidiClient;
class AudioPort;
const fpp_t MINIMUM_BUFFER_SIZE = 32;
const fpp_t DEFAULT_BUFFER_SIZE = 256;
const int BYTES_PER_SAMPLE = sizeof( sample_t );
@@ -382,7 +383,7 @@ private:
} ;
Mixer();
Mixer( bool renderOnly );
virtual ~Mixer();
void startProcessing( bool _needs_fifo = true );

View File

@@ -50,7 +50,7 @@ DummyTrackContainer * Engine::s_dummyTC = NULL;
void Engine::init()
void Engine::init( bool renderOnly )
{
Engine *engine = inst();
@@ -60,7 +60,7 @@ void Engine::init()
emit engine->initProgress(tr("Initializing data structures"));
s_projectJournal = new ProjectJournal;
s_mixer = new Mixer;
s_mixer = new Mixer( renderOnly );
s_song = new Song;
s_fxMixer = new FxMixer;
s_bbTrackContainer = new BBTrackContainer;

View File

@@ -58,7 +58,7 @@
Mixer::Mixer() :
Mixer::Mixer( bool renderOnly ) :
m_framesPerPeriod( DEFAULT_BUFFER_SIZE ),
m_workingBuf( NULL ),
m_inputBufferRead( 0 ),
@@ -83,37 +83,37 @@ Mixer::Mixer() :
clearAudioBuffer( m_inputBuffer[i], m_inputBufferSize[i] );
}
// just rendering?
if( !gui )
{
m_framesPerPeriod = DEFAULT_BUFFER_SIZE;
m_fifo = new fifo( 1 );
}
else if( ConfigManager::inst()->value( "mixer", "framesperaudiobuffer"
).toInt() >= 32 )
{
m_framesPerPeriod =
(fpp_t) ConfigManager::inst()->value( "mixer",
"framesperaudiobuffer" ).toInt();
// determine FIFO size and number of frames per period
int fifoSize = 1;
if( m_framesPerPeriod > DEFAULT_BUFFER_SIZE )
// 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 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 )
{
m_fifo = new fifo( m_framesPerPeriod
/ DEFAULT_BUFFER_SIZE );
ConfigManager::inst()->setValue( "mixer",
"framesperaudiobuffer",
QString::number( DEFAULT_BUFFER_SIZE ) );
m_framesPerPeriod = DEFAULT_BUFFER_SIZE;
}
else
else if( m_framesPerPeriod > DEFAULT_BUFFER_SIZE )
{
m_fifo = new fifo( 1 );
fifoSize = m_framesPerPeriod / DEFAULT_BUFFER_SIZE;
m_framesPerPeriod = DEFAULT_BUFFER_SIZE;
}
}
else
{
ConfigManager::inst()->setValue( "mixer",
"framesperaudiobuffer",
QString::number( m_framesPerPeriod ) );
m_fifo = new fifo( 1 );
}
// allocte the FIFO from the determined size
m_fifo = new fifo( fifoSize );
// now that framesPerPeriod is fixed initialize global BufferManager
BufferManager::init( m_framesPerPeriod );

View File

@@ -509,7 +509,7 @@ int main( int argc, char * * argv )
else
{
// we're going to render our song
Engine::init();
Engine::init( true );
printf( "loading project...\n" );
Engine::getSong()->loadProject( file_to_load );

View File

@@ -90,7 +90,7 @@ GuiApplication::GuiApplication()
this, SLOT(displayInitProgress(const QString&)));
// Init central engine which handles all components of LMMS
Engine::init();
Engine::init(false);
s_instance = this;
@@ -188,4 +188,4 @@ void GuiApplication::childDestroyed(QObject *obj)
{
m_controllerRackView = nullptr;
}
}
}