diff -ur Csound5.10.1/Top/csound.c Csound5.10.1-patch/Top/csound.c --- Csound5.10.1/Top/csound.c 2009-10-15 21:46:28.608183562 -0400 +++ Csound5.10.1-patch/Top/csound.c 2009-10-15 21:53:50.272631365 -0400 @@ -1363,6 +1363,10 @@ { int done; int returnValue; + /* WTB - Oct 15 2009: only perform if CS_STATE_COMP set. */ + if (UNLIKELY((csound->engineState & CS_STATE_COMP) == 0)) { + return 1; + } /* setup jmp for return after an exit() */ if ((returnValue = setjmp(csound->exitjmp))) { #ifndef MACOSX @@ -1383,6 +1387,10 @@ { int done = 0; int returnValue; + /* WTB - Oct 15 2009: only perform if CS_STATE_COMP set. */ + if (UNLIKELY((csound->engineState & CS_STATE_COMP) == 0)) { + return 1; + } /* setup jmp for return after an exit() */ if ((returnValue = setjmp(csound->exitjmp))) { #ifndef MACOSX @@ -1402,6 +1410,10 @@ { int returnValue; int done; + /* WTB - Oct 15 2009: only perform if CS_STATE_COMP set. */ + if (UNLIKELY((csound->engineState & CS_STATE_COMP) == 0)) { + return 1; + } /* Setup jmp for return after an exit(). */ if ((returnValue = setjmp(csound->exitjmp))) { #ifndef MACOSX @@ -1427,6 +1439,10 @@ int done; int returnValue; csound->performState = 0; + /* WTB - Oct 15 2009: only perform if CS_STATE_COMP set. */ + if (UNLIKELY((csound->engineState & CS_STATE_COMP) == 0)) { + return 1; + } /* setup jmp for return after an exit() */ if ((returnValue = setjmp(csound->exitjmp))) { #ifndef MACOSX diff -ur Csound5.10.1/Top/main.c Csound5.10.1-patch/Top/main.c --- Csound5.10.1/Top/main.c 2008-08-11 03:42:21.000000000 -0400 +++ Csound5.10.1-patch/Top/main.c 2009-10-15 21:49:14.804391186 -0400 @@ -89,7 +89,8 @@ dbfs_init(csound, DFLT_DBFS); csound->csRtClock = (RTCLOCK*) csound->Calloc(csound, sizeof(RTCLOCK)); csoundInitTimerStruct(csound->csRtClock); - csound->engineState |= CS_STATE_COMP | CS_STATE_CLN; + /* WTB - Oct 15 2009: only set CS_STATE_CLN; CS_STATE_COMP set when retval=0. */ + csound->engineState |= /*CS_STATE_COMP |*/ CS_STATE_CLN; #ifndef USE_DOUBLE #ifdef BETA @@ -430,6 +431,13 @@ } - return musmon(csound); + n = musmon(csound); + + /* WTB - Oct 15 2009: CS_STATE_COMP set when retval=0. */ + if (n == 0) { + csound->engineState |= CS_STATE_COMP; + } + + return n; }