| Iain Duncan wrote:
> I have a question though, it seems to me in main that there might be
> some oddness over the calling of parse error control, there are a couple
> of spots where I can't see it being called. Can you look over that part?
It should be called after csoundCompile(), and the last call of
csoundPerformKsmps() which returned non-zero. Note that you should
actually ignore the return value of csoundCleanup(): even though
it returns an int, its purpose is not entirely clear. It had to do
something with exiting or continuing after the end of performance
in the now removed Winsound, but it definitely does not report errors,
and unless you register an ExitGraph callback of which the return
value would be returned, csoundCleanup() always returns zero.
It is possible that the return type of csoundCleanup() will be
changed to void to avoid confusion. Anyway, you may want to call
csoundReset() instead that implies csoundCleanup(), and calling
the latter explicitly is rarely useful and sometimes even dangerous.
> Example 4 will have an fltk window thread and the extra api bus
> functions I figure. I think examples 1, 2, & 3 might be good for the
> article in the csound Journal if all agree.
It would be nice to have an example that includes use
of the bus interface.
> /* change the below to the correct location of csound.h ( gimpy on my system right now ) */
> #include "/csound5/H/csound.h"
> //#include "csound.h"
I think it may be preferable to just have "csound.h", and specify the
include path on the command line for the compiler. Of course, this is
a C file, so not all compilers may like the // comments.
> #include
This example does not actually need unistd.h. While it does not
make a difference most of the time, it does slightly reduce portability.
> /* Wait on the csound thread until it is done, this keeps main open until csound is finished */
> if ( cs_result = (int) csoundJoinThread( cs_thread ) )
> { printf("\n\n HOST: ERROR IN CSOUNDCLEANUP, EXITING. \n\n");
> return( cs_result ); }
In this message CSOUNDCLEANUP should really be PERFORMANCE.
I forgot to change that in the previous example, so the old
message is left there as a source of confusion.
> /* it is time to exit now, but why do we do this? who uses cs_data.exit_now
> at this point? is the display thread reading exit now? */
> csoundWaitThreadLockNoTimeout( cs_data.mtx );
> cs_data.exit_now = 1;
> csoundNotifyThreadLock( cs_data.mtx );
Well, you can remove the lock/unlock if you want, it probably
does not make much of a difference in practice. However, exit_now
does have to be set, otherwise the display thread would not know
when it should exit, and attempting to join the thread would never
return.
> /* Istvan, where does the parse error code get called here? */
> return cs_result; /* return the converted error code */
It is not called here, but rather in the Csound thread.
> /* csound has finished performing, so clean up and destroy */
> if ( cs_result = csoundCleanup(csound) )
> { printf("\n\n HOST: ERROR IN CSOUNDCLEANUP, EXITING. \n\n");
> return( cs_result ); }
Now this is the place where cs_result should not be set to the return
value of csoundCleanup(), as not only does this function not report any
errors (see above), but you also overwrite the error code preserved from
the last call of csoundPerformKsmps() which should not be ignored on the
other hand.
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |