示例#1
0
void queryQueues(MidiClient* c)
{
    cout << endl << "ALSA Queues" << endl;    
    cout << "id Queue_Name__________ Timer_Name__________ owner status "
         << "  state PPQ  Tempo BPM   Ticks Time" << endl; 
    QList<int> queues = c->getAvailableQueues();
    foreach( int q, queues ) {
        MidiQueue* queue = new MidiQueue(c, q);
        if (queue != NULL) {
            QueueInfo qinfo = queue->getInfo();
            QueueStatus qsts = queue->getStatus();
            QueueTempo qtmp = queue->getTempo();
            QueueTimer qtmr = queue->getTimer();
            TimerId tid(qtmr.getId());
            QString tname;
            try {
				Timer* timer = new Timer(tid, SND_TIMER_OPEN_NONBLOCK);
				TimerInfo tinfo = timer->getTimerInfo();
				tname = tinfo.getName();
				delete timer;
            } catch (...) {
            	tname = "inaccessible";
            }
			cout << qSetFieldWidth(3)  << left << qinfo.getId()
				 << qSetFieldWidth(20) << qinfo.getName().left(20)
				 << qSetFieldWidth(0)  << " "
				 << qSetFieldWidth(20) << tname.left(20)
				 << qSetFieldWidth(6)  << right << qinfo.getOwner()
				 << qSetFieldWidth(7)  << (qinfo.isLocked() ? "locked" : "free")
				 << qSetFieldWidth(8)  << (qsts.isRunning() ? "running" : "stopped")
				 << qSetFieldWidth(4)  << qtmp.getPPQ()
				 << qSetFieldWidth(7)  << qtmp.getRealBPM()
				 << qSetFieldWidth(4)  << qtmp.getNominalBPM()
				 << qSetFieldWidth(8)  << qsts.getTickTime()
				 << qSetFieldWidth(0)  << " " << qsts.getClockTime()
				 << endl;
            delete queue;
        }
    }