simple xrun-detection

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@80 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-02-07 13:36:41 +00:00
parent e3e8f539d7
commit 94d5107450
9 changed files with 186 additions and 40 deletions

View File

@@ -1,3 +1,12 @@
2006-02-06 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* include/mixer.h:
* include/song_editor.h:
* src/core/mixer.cpp:
* src/core/song_editor.cpp:
simple xrun-detection - do not accept new note-play-handles if xruns
are detected
2006-02-06 Andreas Brandmaier <andy/at/brandmaier.de>
* plugins/bitinvader/bitinvader.cpp

1
TODO
View File

@@ -1,5 +1,6 @@
to be done as soon as possible:
- separate GUI and data/sound-processing-code
- fix qtimer-problem /channel-activity-LEDs
- make color-scheme switchable: LMMS / user
- autosave every 30s (configurable!) and offer recovery at startup after crash

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(lmms, 0.1.4-cvs20060205, tobydox/at/users/dot/sourceforge/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060205)
AC_INIT(lmms, 0.1.4-cvs20060206, tobydox/at/users/dot/sourceforge/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060206)
AM_CONFIG_HEADER(config.h)

115
include/engine.h Normal file
View File

@@ -0,0 +1,115 @@
/*
* engine.h - engine-system of LMMS
*
* Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifndef _ENGINE_H
#define _ENGINE_H
class mixer;
class lmmsMainWin;
class songEditor;
class bbEditor;
class pianoRoll;
class engine
{
public:
engine( bool _has_gui = TRUE );
engine( const engine & _engine );
~engine();
engine * duplicate( const engine * _engine )
{
return( new engine( *_engine ) );
}
inline bool hasGUI( void ) const
{
return( m_hasGUI );
}
inline mixer * getMixer( void )
{
return( m_mixer );
}
inline lmmsMainWin * getMainWindow( void )
{
return( m_mainWindow );
}
inline songEditor * getSongEditor( void )
{
return( m_songEditor );
}
inline bbEditor * getBBEditor( void )
{
return( m_bbEditor );
}
inline pianoRoll * getPianoRoll( void )
{
return( m_pianoRoll );
}
private:
bool m_hasGUI;
mixer * m_mixer;
lmmsMainWin * m_mainWindow;
songEditor * m_songEditor;
bbEditor * m_bbEditor;
pianoRoll * m_pianoRoll;
} ;
class engineObject
{
public:
engineObject( engine * _engine );
~engineObject();
inline engine * eng( void )
{
return( m_engine );
}
inline bool hasGUI( void ) const
{
return( m_engine->hasGUI() );
}
private:
engine * m_engine;
} ;
#endif

View File

@@ -195,7 +195,14 @@ public:
inline void addPlayHandle( playHandle * _ph )
{
m_playHandles.push_back( _ph );
if( criticalXRuns() == FALSE )
{
m_playHandles.push_back( _ph );
}
else
{
delete _ph;
}
}
inline void removePlayHandle( playHandle * _ph )
@@ -223,7 +230,7 @@ public:
return( m_masterGain );
}
inline void setMasterGain( float _mo )
inline void setMasterGain( const float _mo )
{
m_masterGain = _mo;
}
@@ -277,6 +284,7 @@ public:
return( m_playHandles.size() == 0 );
}
bool criticalXRuns( void ) const;
const surroundSampleFrame * renderNextBuffer( void );

View File

@@ -2,7 +2,7 @@
* pattern.h - declaration of class pattern, which contains all informations
* about a pattern
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -78,7 +78,7 @@ public:
BEAT_PATTERN, MELODY_PATTERN/*, AUTOMATION_PATTERN*/
} ;
pattern( channelTrack * _channel_track );
pattern( channelTrack * _channel_track ) FASTCALL;
pattern( const pattern & _pat_to_copy ) FASTCALL;
virtual ~pattern();

View File

@@ -119,6 +119,8 @@ public:
return( m_exporting );
}
bool realTimeTask( void ) const;
inline bool exportDone( void ) const
{
return( m_exporting == TRUE &&

View File

@@ -130,6 +130,15 @@ void mixer::stopProcessing( void )
bool mixer::criticalXRuns( void ) const
{
return( ( m_cpuLoad >= 98 &&
songEditor::inst()->realTimeTask() == TRUE ) );
}
const surroundSampleFrame * mixer::renderNextBuffer( void )
{
microTimer timer;
@@ -168,8 +177,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
++it;
}
m_playHandlesToRemove.erase(
m_playHandlesToRemove.begin() );
m_playHandlesToRemove.erase( m_playHandlesToRemove.begin() );
}
// now swap the buffers... current buffer becomes next (last)
@@ -179,36 +187,38 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
// clear last audio-buffer
clearAudioBuffer( m_curBuf, m_framesPerAudioBuffer );
csize idx = 0;
while( idx < m_playHandles.size() )
// if( criticalXRuns() == FALSE )
{
register playHandle * n = m_playHandles[idx];
// delete play-handle if it played completely
if( n->done() )
csize idx = 0;
while( idx < m_playHandles.size() )
{
delete n;
m_playHandles.erase( m_playHandles.begin() +
idx );
register playHandle * n = m_playHandles[idx];
// delete play-handle if it played completely
if( n->done() )
{
delete n;
m_playHandles.erase( m_playHandles.begin() +
idx );
}
else
{
// play all uncompletely-played play-handles...
n->play();
++idx;
}
}
else
{
// play all uncompletely-played play-handles...
n->play();
++idx;
}
}
songEditor::inst()->processNextBuffer();
songEditor::inst()->processNextBuffer();
for( vvector<audioPort *>::iterator it = m_audioPorts.begin();
it != m_audioPorts.end(); ++it )
{
if( ( *it )->m_bufferUsage != audioPort::NONE )
for( vvector<audioPort *>::iterator it = m_audioPorts.begin();
it != m_audioPorts.end(); ++it )
{
processBuffer( ( *it )->firstBuffer(),
( *it )->nextFxChannel() );
( *it )->nextPeriod();
if( ( *it )->m_bufferUsage != audioPort::NONE )
{
processBuffer( ( *it )->firstBuffer(),
( *it )->nextFxChannel() );
( *it )->nextPeriod();
}
}
}
@@ -329,14 +339,8 @@ void mixer::setHighQuality( bool _hq_on )
delete m_audioDev;
// set new quality-level...
if( _hq_on == TRUE )
{
m_qualityLevel = HIGH_QUALITY_LEVEL;
}
else
{
m_qualityLevel = DEFAULT_QUALITY_LEVEL;
}
m_qualityLevel = ( _hq_on == TRUE ) ? HIGH_QUALITY_LEVEL :
DEFAULT_QUALITY_LEVEL;
// and re-open device
m_audioDev = tryAudioDevices();

View File

@@ -1050,6 +1050,13 @@ void songEditor::processNextBuffer( void )
bool songEditor::realTimeTask( void ) const
{
return( !( m_exporting == TRUE || ( m_playMode == PLAY_PATTERN &&
m_patternToPlay->freezing() == TRUE ) ) );
}
void songEditor::play( void )