Reputation: 31951
I am playing sound for user interactions in C++ using QT's Phonon component. After a lot of testing I can confirm that a queued sound will only start playing when the main thread returns to the main message loop. For long processing code this introduces a delay in sound playback. I need to find a way to avoid that delay.
I've tried doing the sound in a separate thread, but a defect in Phonon prevents some of the objects from being created in that thread. Thus some signals are always stuck in the main thread.
Simply returning to the event loop quickly is not an option for a few reasons:
I'm just looking to cover the most basic use case for a sound API: play a sound when a user does something (like click a button) and have that sound play immediately. Surely that must be covered somehow in Phonon?
Upvotes: 1
Views: 1691
Reputation: 9764
I haven't looked if phonon in qt 4.7 has been improved but I considered using it for a similar purpose (in qt 4.6) and rejected it because it could not play/mix two sounds at the same time. I did not even get to any run time testing. I went with SDL Audio, specifically SDL Mixer it has low latency on playing and you can play multiple sounds at the same time.
Upvotes: 1