/* $ g++ -lQtCore -o glibfluid glibfluid.cpp */ #include #include #include #include #include #include class MyThread : public QThread { public: virtual void run() { QProcess p; QStringList args; QString program("/usr/bin/fluidsynth"); args << "-l" << "-a" << "alsa" << "-m" << "alsa_seq" << "/usr/share/sounds/sf2/GeneralUser_GS_FluidSynth.sf2"; p.setProcessChannelMode( QProcess::ForwardedChannels ); p.start(program, args, QIODevice::ReadOnly ); sleep(2); p.terminate(); p.waitForFinished(); } }; int main(int argc, char* argv[]) { int rc; struct sched_param p; QCoreApplication a(argc, argv); MyThread t; ::memset(&p, 0, sizeof(p)); p.sched_priority = 10; rc = ::sched_setscheduler(QCoreApplication::applicationPid(), SCHED_FIFO, &p); if (rc != 0) qWarning() << "sched_setscheduler() with SCHED_FIFO failed, rc=" << rc << ::strerror(rc); else qDebug() << "sched_setscheduler() with realtime priority succeeded!"; t.start(); t.wait(); }