Hi guys!

Attached is a testing-only patch against TRUNK Rev 1163. On my system, it greatly reduces the "Jack Zombies" (a.k.a. Hollunder's bug, a.k.a Ticket #85). However, it totally kills all logging.

Has anyone else been able to reproduce the bug? Does this patch seem to help? Be sure to test first with a debug build.

FYI, here's the ideas behind the patch:

  * I did some profiling with oprofile and found that
    AudioEngine::try_lock() was taking _way_ to long.
    Reason?  This:

       AudioEngine::get_instance()->try_lock( "string literal" );

    The string literal get implicitly converted to a QString.
    This will _always_ call the QString copy constructor.  This is
    fixed by making the string literal a static QString.

  * try_lock() still sometimes took too long,
    so I killed the QString assignment for the __locker
    variable.

  * All logging is disabled.  When the logging thread
    is actively processing it's data, it locks the queue.
    Anything in a process() cycle that wants to add
    something to the logging queue has to wait. (At
    least... as far as I can tell.  :-))

  * The audioEngine_process() aborts if not in STATE_READY
    or STATE_PLAYING.  Any other state doesn't make sense.

Thanks,
Gabriel
diff --git a/libs/hydrogen/include/hydrogen/Object.h b/libs/hydrogen/include/hydrogen/Object.h
index 9653c5f..030728a 100644
--- a/libs/hydrogen/include/hydrogen/Object.h
+++ b/libs/hydrogen/include/hydrogen/Object.h
@@ -37,13 +37,13 @@
 
 // LOG MACROS
 
-#define _INFOLOG(x) Logger::get_instance()->info_log( __PRETTY_FUNCTION__, "", x );
-#define _WARNINGLOG(x) Logger::get_instance()->warning_log( __PRETTY_FUNCTION__, "", x );
-#define _ERRORLOG(x) Logger::get_instance()->error_log( __PRETTY_FUNCTION__, "", x );
+#define _INFOLOG(x) ((void)0);
+#define _WARNINGLOG(x) ((void)0);
+#define _ERRORLOG(x) ((void)0);
 
-#define INFOLOG(x) Logger::get_instance()->info_log( __FUNCTION__, get_class_name(), x );
-#define WARNINGLOG(x) Logger::get_instance()->warning_log( __FUNCTION__, get_class_name(), x );
-#define ERRORLOG(x) Logger::get_instance()->error_log( __FUNCTION__, get_class_name(), x );
+#define INFOLOG(x) ((void)0);
+#define WARNINGLOG(x) ((void)0);
+#define ERRORLOG(x) ((void)0);
 
 
 
diff --git a/libs/hydrogen/src/audio_engine.cpp b/libs/hydrogen/src/audio_engine.cpp
index aa9d11a..b295426 100644
--- a/libs/hydrogen/src/audio_engine.cpp
+++ b/libs/hydrogen/src/audio_engine.cpp
@@ -123,7 +123,7 @@ bool AudioEngine::try_lock( const QString& locker )
 		WARNINGLOG( "trylock != 0. Lock in " + __locker );
 		return false;
 	}
-	__locker = locker;
+	//__locker = locker;
 
 	return true;
 }
diff --git a/libs/hydrogen/src/hydrogen.cpp b/libs/hydrogen/src/hydrogen.cpp
index d18e440..5f25f7d 100644
--- a/libs/hydrogen/src/hydrogen.cpp
+++ b/libs/hydrogen/src/hydrogen.cpp
@@ -38,6 +38,10 @@
 #include <ctime>
 #include <cmath>
 
+#include <signal.h>
+#include <jack/jack.h>
+#include <jack/types.h>
+
 #include <hydrogen/LocalFileMng.h>
 #include <hydrogen/event_queue.h>
 #include <hydrogen/adsr.h>
@@ -703,10 +707,22 @@ inline void audioEngine_process_clearAudioBuffers( uint32_t nFrames )
 /// Main audio processing function. Called by audio drivers.
 int audioEngine_process( uint32_t nframes, void* /*arg*/ )
 {
-	if ( AudioEngine::get_instance()->try_lock( "audioEngine_process" ) == false ) {
+	static QString me("audioEngine_process");
+
+	if( (m_audioEngineState != STATE_READY) && (m_audioEngineState != STATE_PLAYING) ) {
 		return 0;
 	}
 
+
+	if ( AudioEngine::get_instance()->try_lock( me ) == false ) {
+		return 0;
+	}
+
+	if( (m_audioEngineState != STATE_READY) && (m_audioEngineState != STATE_PLAYING) ) {
+		AudioEngine::get_instance()->unlock();
+	    return 0;
+	}
+
 	timeval startTimeval = currentTime2();
 
 	if ( m_nBufferSize != nframes ) {
@@ -1580,22 +1596,11 @@ void audioEngine_startAudioDrivers()
 #endif
 	}
 
-	// change the current audio engine state
-	if ( m_pSong == NULL ) {
-		m_audioEngineState = STATE_PREPARED;
-	} else {
-		m_audioEngineState = STATE_READY;
-	}
-
-
-	if ( m_pSong ) {
-		m_pAudioDriver->setBpm( m_pSong->__bpm );
-	}
-
 	// update the audiodriver reference in the sampler
 	AudioEngine::get_instance()->get_sampler()->set_audio_output( m_pAudioDriver );
 
 	if ( m_pAudioDriver ) {
+		_INFOLOG( QString("at connect %1").arg(todo_delete_this_debugging_counter) );
 		int res = m_pAudioDriver->connect();
 		if ( res != 0 ) {
 			audioEngine_raiseError( Hydrogen::ERROR_STARTING_DRIVER );
@@ -1624,6 +1629,18 @@ void audioEngine_startAudioDrivers()
 
 
 
+	// change the current audio engine state
+	if ( m_pSong == NULL ) {
+		m_audioEngineState = STATE_PREPARED;
+	} else {
+		m_audioEngineState = STATE_READY;
+	}
+
+
+	if ( m_pSong ) {
+		m_pAudioDriver->setBpm( m_pSong->__bpm );
+	}
+
 	if ( m_audioEngineState == STATE_PREPARED ) {
 		EventQueue::get_instance()->push_event( EVENT_STATE, STATE_PREPARED );
 	} else if ( m_audioEngineState == STATE_READY ) {
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Hydrogen-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel

Reply via email to