In my QT gui i need to handle specific events with an audio alert and I have determined my only real option is with QTMultiMedia/ QAudioOutput due to system limitations. I am trying to devise a plan on how to best write this and would like some feedback on an efficient approach to take.

Basically I have 2 alert wav files, Alert A is .75 seconds long and Alert B is 1.9 seconds long. When my gui receives notice to play Alert A it should repeat for 5 seconds and stop. Alert B should play 10 seconds. If an alert is already playing when a new one is received it should start its 5 or 10 second clock immediately, but only play once any previous alerts have completed with any remaining time it has left.

I can think of two approaches to handle this.

Both scenarios would require first creating a QAudioOutput with the full buffer size for its 5 or 10 second alert duration, then:

1. Create a handler class with one instance that will create a new QAudioOutput instance for each active alert and if another alert is currently playing, set volume to 0 and place it in a queue. When a previous alert receives a QAudio::StoppedState change notice, turn the volume up on the next item in the list and remove the dead alert.

2. create a handler class witch will manage playing an alert by waiting to play an alert until its time, and set a single shot timer for every alert received to let it know when to end if it hasn't reached the end of its buffer yet.

Which approach do you think works best with QTs framework? Or maybe you have a better idea? should I create a new thread for each alert or will it naturally work itself out?Any useful examples you can point me to, to help code this?