Example #1
0
static int start_portmidi(CSOUND *csound)
{
    const char  *errMsg = NULL;

#if !defined(WIN32)
    csound_global_mutex_lock();
#endif
    if (!portmidi_init_cnt) {
      if (UNLIKELY(Pm_Initialize() != pmNoError))
        errMsg = Str(" *** error initialising PortMIDI");
      else if (UNLIKELY(Pt_Start(1, NULL, NULL) != ptNoError))
        errMsg = Str(" *** error initialising PortTime");
      }

    if (errMsg == NULL)
      portmidi_init_cnt++;
#if !defined(WIN32)
    csound_global_mutex_unlock();
#endif
    if (UNLIKELY(errMsg != NULL)) {
      csound->ErrorMsg(csound, Str(errMsg));
      return -1;
    }
#if !defined(WIN32)
    csound_global_mutex_unlock();
#endif
    return csound->RegisterResetCallback(csound, NULL, stop_portmidi);
}
Example #2
0
static int stop_portmidi(CSOUND *csound, void *userData)
{
    (void) csound;
    (void) userData;
#if !defined(WIN32)
    csound_global_mutex_lock();
#endif
    if (portmidi_init_cnt) {
      if (--portmidi_init_cnt == 0UL) {
        Pm_Terminate();
        Pt_Stop();
      }
    }
#if !defined(WIN32)
    csound_global_mutex_unlock();
#endif
    return 0;
}
Example #3
0
void csoundLock(void)
{
    csound_global_mutex_lock();
}