PDA

View Full Version : Phonon: Looping, playing multiple sounds at the same time



bmn
26th September 2012, 14:56
Hello,

while I did get Phonon to loop sound from a wav file, I'm observing in the Visual Studio output window that every time the sound is played, 6 threads appear to started and ended (six!). What I'm doing to play back is this:


audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject = new Phonon::MediaObject(this);
Phonon::createPath(mediaObject, audioOutput);
connect(mediaObject, SIGNAL(aboutToFinish()), SLOT(doTheLoop()));
then

mediaObject->stop();
mediaObject->clearQueue();
mediaObject->setCurrentSource(absPath);
mediaObject->play();
and in the doTheLoop slot:

if (m_loop)
mediaObject->enqueue(*m_loop);

Why would it use so many threads, and how can I change that?

Secondly, is it possible to play multiple sounds at the same time?

Context: Qt 4.8.1, Windows 7 x64/86, Visual Studio 2010

d_stranz
26th September 2012, 19:02
Why would it use so many threads, and how can I change that?

Why do you care, and why would you want to change that? If Phonon uses multithreading to load DLLs and play sounds, and if your app is able to do this correctly, what difference does it make how Phonon does what it does? Did you consider that perhaps it does this in a threaded way to avoid locking up your app while the sound is playing?


Secondly, is it possible to play multiple sounds at the same time?

And why on earth would you want to do that? Unless the currently playing Phonon instance forces exclusive access to the audio, it should be possible to create a second Phonon instance to play the second sound at the same time.

d_stranz
27th September 2012, 16:31
And why on earth would you want to do that?

As the OP explained to me in a PM, you might want to play multiple sounds at the same time in an audio or video mixing app, or in a game. That makes perfect sense to me. :o