csPerfThread.hpp

Go to the documentation of this file.
00001 /*
00002     csPerfThread.hpp:
00003 
00004     Copyright (C) 2005 Istvan Varga
00005 
00006     This file is part of Csound.
00007 
00008     The Csound Library is free software; you can redistribute it
00009     and/or modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     Csound is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with Csound; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00021     02111-1307 USA
00022 */
00023 
00024 #ifndef CSOUND_CSPERFTHREAD_HPP
00025 #define CSOUND_CSPERFTHREAD_HPP
00026 
00027 class CsoundPerformanceThreadMessage;
00028 class CsPerfThread_PerformScore;
00029 
00044 #ifdef SWIGPYTHON
00045 struct PUBLIC pycallbackdata {
00046   PyObject *func;
00047   PyObject *data;
00048 };
00049 #endif
00050 
00051 class PUBLIC CsoundPerformanceThread {
00052  private:
00053     volatile CsoundPerformanceThreadMessage *firstMessage;
00054     CsoundPerformanceThreadMessage *lastMessage;
00055     CSOUND  *csound;
00056     void    *queueLock;         // this is actually a mutex
00057     void    *pauseLock;
00058     void    *flushLock;
00059     void    *perfThread;
00060     int     paused;
00061     int     status;
00062     void *    cdata;
00063     // --------
00064     int  Perform();
00065     void csPerfThread_constructor(CSOUND *);
00066     void QueueMessage(CsoundPerformanceThreadMessage *);
00067     void (*processcallback)(void *cdata);
00068  public:
00069 
00070 #ifdef SWIGPYTHON
00071   PyThreadState *_tstate;
00072   pycallbackdata pydata;
00073 #endif
00074 
00077   void *GetProcessCallback() { return (void *)processcallback; }
00078 
00082    void SetProcessCallback(void (*Callback)(void *), void *cbdata){
00083     processcallback = Callback;
00084     cdata = cbdata;
00085    }
00089     CSOUND *GetCsound()
00090     {
00091       return csound;
00092     }
00098     int GetStatus()
00099     {
00100       return status;
00101     }
00105     void Play();
00109     void Pause();
00114     void TogglePause();
00118     void Stop();
00125     void ScoreEvent(int absp2mode, char opcod, int pcnt, const MYFLT *p);
00129     void InputMessage(const char *s);
00133     void SetScoreOffsetSeconds(double timeVal);
00140     int Join();
00145     void FlushMessageQueue();
00146     // --------
00147     CsoundPerformanceThread(Csound *);
00148     CsoundPerformanceThread(CSOUND *);
00149     ~CsoundPerformanceThread();
00150     // --------
00151     friend class CsoundPerformanceThreadMessage;
00152     friend class CsPerfThread_PerformScore;
00153 };
00154 
00155 #endif  // CSOUND_CSPERFTHREAD_HPP
00156 

Generated on Tue Apr 14 11:00:49 2009 for Csound and CsoundAC by  doxygen 1.5.8