Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] HELP!! API threading problem...

Date2006-07-07 11:40
FromVictor Lazzarini
SubjectRe: [Cs-dev] HELP!! API threading problem...
And another thing, instead of quitting the perf thread
with a boolean call, you could join it (csoundJoinThread or
something) from the main thread and then reset csound.
That's probably safer.

Victor

>
> Hi everyone. I really have a problem when using the API
> with GUI  applications. Basically it seems that if I start
> and stop the  performance thread too quickly I get a
> crash. I've even tried putting in  a sleep call but that
> doesn't seem to be helping either. It's beginning  to get
> really annoying, the sleep will help if it's set to over 1
> second  which is way too long to have to hold the process.
> Here is the complete  .cpp code for a minimal application
> that will cause the problem...if  anyone needs to see the
> header file let me know...
>
>
> __fastcall TcsoundGUItest::TcsoundGUItest(TComponent*
> Owner)
>     : TForm(Owner)
> {
> cmdl = (char **) malloc(sizeof(char*)*(2));
> pd = (csdata *) malloc(sizeof(csdata));
> pd->instance = csoundCreate(0);
> pd->status = 0;
> FIRSTRUN = 1;
> }
> //--------------------------------------------------------
> -------------------
>
> void __fastcall TcsoundGUItest::Button1Click(TObject
> *Sender) {
> Sleep(600);//at 1000 it seems to be ok??
> if(!FIRSTRUN)csoundJoinThread(threadID);
> if(pd->status==0){
>    cmdl[0] = "csound";
>    cmdl[1] =
> "D:/MyDocuments/SourceCode/MinCsound/basic.csd";
>    csoundSetMessageCallback(pd->instance,
> csoundMessageCall);
>    pd->result = csoundCompile(pd->instance, 2, cmdl);
>    pd->status = 1;
>    threadID = csoundCreateThread((uintptr_t(*)(void
> *))csThread, (void  *)pd);
>    }
> else pd->status=!pd->status;
> }
> //--------------------------------------------------------
> ------------------- void csoundMessageCall(CSOUND* csound,
> int attr, const char* format,  va_list valist)
> {
> AnsiString csoundMess;
> csoundMess.vprintf(format, valist);
> csoundMess.Trim();
> csoundGUItest->Memo1->Text = csoundGUItest->Memo1->Text +
> csoundMess; }
> //--------------------------------------------------------
> ------------------- uintptr_t csThread(void *clientData)
> {
> csdata *p = (csdata *) clientData;
>       if(!p->result)
>         {
>
> while((csoundPerformKsmps(p->instance)==0)&&(p->status));
>         csoundReset(p->instance);
>         }
>       return 1;
> }
>
> Using Tomcat but need to do more? Need to support web
> services, security? Get stuff done quickly with
> pre-integrated technology to make your job easier Download
> IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
--------------------------------------
   This Email Was brought to you by
               WebMail
    A Netwin Web Based EMail Client
  http://netwinsite.com/webmail/tag.htm

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net