PDA

View Full Version : phonon queue problem



Lykurg
25th December 2008, 10:27
Hi,

I have trouble to clear the queue of a Phonon::MediaObject definitely. I have a "global":

Phonon::MediaObject *phononSound;
phononSound = Phonon::createPlayer(Phonon::MusicCategory);
and a function which can be triggered by the user.

phononSound->clearQueue();
QList<Phonon::MediaSource> soundfiles;
// here soundfiles are filed with 0 to 3 wav files.
if (!soundfiles.isEmpty())
{
phononSound->setCurrentSource(soundfiles.takeFirst());
phononSound->enqueue(soundfiles);
phononSound->play();
}
else
phononSound->stop();

Now following output occurs:
function called 1st: 2 wav files
-> played 1st wav of 1st call
function called again: 1 wav file
-> played (1st) wav of 2nd call (debug at the end of the 2nd call says that the queue is empty)
-> played 2nd wav of the 1st function call. ???

Why the queue isn't cleared correctly? What's wrong? Various placed phononSound->stop() on different places wont change anything.

Thanks
Lykurg

muellerp
25th December 2008, 14:20
You enqueued 2 files.
They are played one after each other.

For any call mediaObject->stop you should wait until the mediaObject receives the stateChanged signal with stoped state before assuming it will do something different.

Phonon is asynchronous and state based.
mediaObject->stop() returns imidiately, but at this point in time it is not yet stopped.