diff --git a/ChangeLog b/ChangeLog index 4a01b2774..608c27133 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-06 Tobias Doerffel + + * 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 * plugins/bitinvader/bitinvader.cpp diff --git a/TODO b/TODO index 36104243f..40e55d733 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/configure.in b/configure.in index 9e958b9d3..b1f7cec2e 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/include/engine.h b/include/engine.h new file mode 100644 index 000000000..c67603d8f --- /dev/null +++ b/include/engine.h @@ -0,0 +1,115 @@ +/* + * engine.h - engine-system of LMMS + * + * Copyright (c) 2006 Tobias Doerffel + * + * 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 diff --git a/include/mixer.h b/include/mixer.h index 50225a9dc..5f379d67f 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -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 ); diff --git a/include/pattern.h b/include/pattern.h index d3987e2b6..a5a88ba01 100644 --- a/include/pattern.h +++ b/include/pattern.h @@ -2,7 +2,7 @@ * pattern.h - declaration of class pattern, which contains all informations * about a pattern * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * 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(); diff --git a/include/song_editor.h b/include/song_editor.h index 062ae3df4..17b73210b 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -119,6 +119,8 @@ public: return( m_exporting ); } + bool realTimeTask( void ) const; + inline bool exportDone( void ) const { return( m_exporting == TRUE && diff --git a/src/core/mixer.cpp b/src/core/mixer.cpp index fd366334f..27198e60e 100644 --- a/src/core/mixer.cpp +++ b/src/core/mixer.cpp @@ -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::iterator it = m_audioPorts.begin(); - it != m_audioPorts.end(); ++it ) - { - if( ( *it )->m_bufferUsage != audioPort::NONE ) + for( vvector::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(); diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index 22ccf9d67..2adf23441 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -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 )