Exemple #1
0
void PollThread(void *dummy)
#endif
{
    unsigned c;
    
    dummy = dummy;

    while ( !stopPoll )
    {
        c = GetCycleCount();
        if ( !MIDASpoll() )
            MIDASerror();
        c = GetCycleCount() - c;
        if ( pollCount > 100 )
        {
            if ( c < pollMin )
                pollMin = c;
            if ( c > pollMax )
                pollMax = c;
            pollTotal += c;
        }
        pollCount++;
        Sleep(rand() % 40);
        if ( (rand() % 8) < 3 )
            RandomPriority();
    }

    stopPoll = 0;

    _endthread();
}
Exemple #2
0
int RainCommand(int command,int param1,int param2,int param3,
                 char *filename,int fileofs,int filesize)
{
    int result=0;
    int i;
    if (command==CMD_PLAY)
        _bprintf(hint,hintlen,"%s,%i,%i",filename,fileofs,filesize);
    else
        _bprintf(hint,hintlen,"%i(%i,%i)",command,param1,param2);
    switch (command)
    {
        case CMD_NONE:
            RainFreeStopped();
            MIDASpoll();
            break;
        case CMD_PLAY:
            rainhandles++;
            if (sounds<SOUNDS)
            {
                sound[sounds].type=None;
                sound[sounds].rainhandle=rainhandles;
                sound[sounds].datahandle=0;
                sound[sounds].playhandle=0;
                soundPlay(&sound[sounds],filename,fileofs,filesize,param1);
                soundSetVolume(&sound[sounds],param2);
                soundSetPanning(&sound[sounds],param3);
                sounds++;
            }
            result=rainhandles;
            break;
        case CMD_VOL:
            for(i=0;i<sounds;i++)
              if(sound[i].rainhandle==param1)
              {
                  soundSetVolume(&sound[i],param2);
              }
            break;
        case CMD_PAN:
            for(i=0;i<sounds;i++)
              if(sound[i].rainhandle==param1)
              {
                  soundSetPanning(&sound[i],param2);
              }
            break;
        case CMD_STOP:
            for(i=0;i<sounds;i++)
              if(sound[i].rainhandle==param1)
              {
                  soundStop(&sound[i]);
                  sound[i--]=sound[--sounds];
              }
            break;
        case CMD_AMPLIFY:
            MIDASsetAmplification(AMPLIFY_ALL*AMPLIFY_MP3*param1);
            break;
        default:
            _bprintf(errBuf,errBufLen," Unknown command %i.",command);
            errAdd(errBuf);
    }
    MIDASreportErr();
    return result;
}