static void msw_close_midiin(void)
{
    unsigned int i;
    /* Stop, reset, close MIDI input.  Free callback instance data.
     */

    for (i=0; (i<wNumDevices) && (i<MAXMIDIINDEV); i++)
    {
        if (hMidiIn[i])
        {
            if (sys_verbose)
                post("closing MIDI input %d...", i);
            midiInStop(hMidiIn[i]);
            midiInReset(hMidiIn[i]);
            midiInClose(hMidiIn[i]);
            FreeCallbackInstanceData(lpCallbackInstanceData[i]);
        }
    }
    
    /* Free input buffer.
     */
    if (lpInputBuffer)
        FreeCircularBuffer(lpInputBuffer);

    if (sys_verbose)
        post("...done");
    wNumDevices = 0;
}
void msw_open_midiin(int nmidiin, int *midiinvec)
{
    UINT  wRtn;
    char szErrorText[256];
    unsigned int i;
    unsigned int ndev = 0;
    /* Allocate a circular buffer for low-level MIDI input.  This buffer
     * is filled by the low-level callback function and emptied by the
     * application.
     */
    lpInputBuffer = AllocCircularBuffer((DWORD)(INPUT_BUFFER_SIZE));
    if (lpInputBuffer == NULL)
    {
        printf("Not enough memory available for input buffer.\n");
        return;
    }

    /* Open all MIDI input devices after allocating and setting up
     * instance data for each device.  The instance data is used to
     * pass buffer management information between the application and
     * the low-level callback function.  It also includes a device ID,
     * a handle to the MIDI Mapper, and a handle to the application's
     * display window, so the callback can notify the window when input
     * data is available.  A single callback function is used to service
     * all opened input devices.
     */
    for (i=0; (i<(unsigned)nmidiin) && (i<MAXMIDIINDEV); i++)
    {
        if ((lpCallbackInstanceData[ndev] = AllocCallbackInstanceData()) == NULL)
        {
            printf("Not enough memory available.\n");
            FreeCircularBuffer(lpInputBuffer);
            return;
        }
        lpCallbackInstanceData[i]->dwDevice = i;
        lpCallbackInstanceData[i]->lpBuf = lpInputBuffer;
        
        wRtn = midiInOpen((LPHMIDIIN)&hMidiIn[ndev],
              midiinvec[i],
              (DWORD)midiInputHandler,
              (DWORD)lpCallbackInstanceData[ndev],
              CALLBACK_FUNCTION);
        if (wRtn)
        {
            FreeCallbackInstanceData(lpCallbackInstanceData[ndev]);
            msw_midiinerror("midiInOpen: %s\n", wRtn);
        }
        else ndev++;
    }

    /* Start MIDI input.
     */
    for (i=0; i<ndev; i++)
    {
        if (hMidiIn[i])
            midiInStart(hMidiIn[i]);
    }
    wNumDevices = ndev;
}
Beispiel #3
0
int AllocateCircularBuffer(int iCardNo)
{
  ACIRCBUFFER* b;
  int i;

  b = &gpAndorDev[iCardNo].CircBuffer;

  if(b->mPages!=NULL)
    return 0;

  b->mNoPages = (((BUFFER_SIZE << 20)-1) >> PAGE_SHIFT) + 1;

  b->mPages = (unsigned long**)kmalloc(sizeof(unsigned long*)*(b->mNoPages), GFP_KERNEL);
 
  if(b->mPages==NULL){
    printk("<7>andordrvlx: Error Allocating Circular Buffer\n");
    return -EFAULT;
  }
  
  for(i=0; i<b->mNoPages; i++){ //in case a problem arises during allocation 
    b->mPages[i] = NULL;
  }

  for(i=0; i<b->mNoPages; i++){
    b->mPages[i] = (unsigned long*)get_zeroed_page(GFP_KERNEL);
    if(b->mPages[i]==NULL){
      FreeCircularBuffer(iCardNo);
      printk("<7>andordrvlx: Error Allocating Circular Buffer Pages...\n");
      return -EFAULT;
    }
  }

  b->mLastPageToUse = b->mNoPages-1;
  b->mLastPixelToUse = PAGE_SIZE-1;

  b->mCurrentPage = 0;
  b->mCurrentPixel = 0;

  return 0;
}
Beispiel #4
0
int AndorFreeKernelStorage(int iCardNo)
{
  FreeCircularBuffer(iCardNo);

  return 0;
}