QProcess running aplay
-
Hi,
I'm using qt4.7.4 on an embedded Linux target.
I'm trying to add a sound when my touch panel is activated.
When a button is clicked I call the following:
@if (QFile::exists(s))
{
cout << "close" << endl;
soundProcess->close();
cout << "start" << endl;
soundProcess->start("aplay "+s);
soundProcess->waitForFinished();
cout << "done" << endl;
}@
soundProcess is a class variable of type QProcess* and is opened on class instantiation.
I have tried far more than above, this is the simplest.
This works fine for a varying number of key clicks with about 1ms reported between "close" and "start" and 220ms between "start" and "done" (i.e. the length of the sound) until at some point I start getting about 30 seconds between "start" and "done" - which obviously kills my gui.
Anyone got any idea what might be going on - or any better ideas to achieve this?
I thank you in advance.
-
Why do you wait for it to finish at all? If it's just a sound for touch feedback then you don't need to establish an input/output channel or keep track of the process. Wouldn't it be better with a "fire and forget" style, i.e. "QProcess:startDetached":http://qt-project.org/doc/qt-5/qprocess.html#startDetached ?
-
Hi,
msue - thanks for reply. Tried startDetached and it returns immediately as you suggested. After a number of 'plays' though I then get the error 'audio open error: Device or resource busy'.
In fact Chris, I started with your approach as this is what I want to end up with. I put the 30 second 'hang' down to the sound system being busy or something so thought I'd try waiting for it to complete as a test.
No nearer a solution yet but thanks...