virtual void Run()
  {
    fPlaying = true;
    fPos = 0;
    MIDIEvent *ev = fEvs;

    uint32 startTime = B_NOW;
    while (KeepRunning())
    {
      if (!ev) {
        if (fLoops && fEvs) {
          --fLoops;
          fPos = 0;
          ev = fEvs;
        } else
          break;
      }
      SprayEvent(ev, ev->time + startTime);
      ev = ev->next;
      fPos++;
    }
    fPos = fTotal;
    fPlaying = false;
  }
Пример #2
0
void* 
StatisticsKeeper::run_undetached(void* /*arg*/)
{
    unsigned long sleepTime = fMilliseconds * 1000;
    time_t        startTime = time(NULL);
    time_t        usedTime; 

    unsigned long qlen    ;
    unsigned long killed  ;
    unsigned long total   ;
    unsigned long stored  ;
    unsigned long skipped ;
    unsigned long msgerror;
    unsigned long done    ;
    float precentage_done ;
    char  percentage[100] ;
    unsigned long bytesReceived;
    unsigned long bytesSent;
    unsigned long avgBytesReceivedPerSecond;

    while (KeepRunning())
    {
        omni_thread::sleep(0,sleepTime);
        if(valuesModified)
        {
            qlen    = GetNumericValue("Command Queue Length");
            killed  = GetNumericValue("Articles Killed");
            total   = GetNumericValue("Articles Present");
            stored  = GetNumericValue("Articles Written");
            skipped = GetNumericValue("Articles Skipped");
            msgerror= GetNumericValue("Articles ERROR");
            done    = killed+stored+skipped+msgerror;

            precentage_done = 
                (total==0?0.0:(((float)(done))/((float)total))*100.0);

            // I couldn't get the stream formatting to do what I wanted
            // So let's do this the traditional way.
            sprintf(percentage,"%3.0f",precentage_done);

            Lstatus 
                << "MSGS:"  << setw(4) << total      <<","    // Total
                << "TODO:"  << setw(4) << qlen       <<","    // Queue length
                << "DONE:"             << percentage << "%={" 
                << "STOR:"  << setw(4) << stored     <<","    // Stored
                << "SKIP:"  << setw(4) << skipped    <<","    // Skipped
                << "KILL:"  << setw(4) << killed     <<","    // Killed
                << "ERROR:" << setw(4) << msgerror   <<"} \r" // Error
                << flush;

            bytesReceived = GetNumericValue("Socket Received Bytes");
                    
            usedTime = time(NULL) - startTime;
            if (usedTime==0)
                avgBytesReceivedPerSecond = bytesReceived; // assume 1 second
            else
                avgBytesReceivedPerSecond = (bytesReceived)/(usedTime);

            SetProcTitle("%3d%% (%4d/%4d) @ Average %6d bytes/second.    ",
                    (unsigned long)precentage_done,done,total,
                    avgBytesReceivedPerSecond);
            
            valuesModified = false;
        }
    }

    Linfo << endl << flush;

    // ----------------------------
    // Print the overall statistics
    bytesSent     = GetNumericValue("Socket Send Bytes");
    bytesReceived = GetNumericValue("Socket Received Bytes");
    
    usedTime = time(NULL) - startTime;
    if (usedTime==0)
        avgBytesReceivedPerSecond = bytesReceived; // assume 1 second
    else
        avgBytesReceivedPerSecond = (bytesReceived)/(usedTime);

    Linfo << "Overall : ";
    Linfo << "OUT: " << setw(7) << bytesSent << " bytes, " 
          << "IN: " << setw(9) <<  bytesReceived << " bytes, "
          << "AVG: " << setw(7) << avgBytesReceivedPerSecond << " bytes/second" 
          << endl << flush;

    return NULL;
}
Пример #3
0
void 
BMidiText::Run()
{
	while (KeepRunning())
		snooze(50000);
}