Unsolved QAudioOutput: incorrectly emits an accumulated number of signal notify() after resume form suspend
-
I want to use the notify signal emitted once for every second of audio played to keep track of when it is time to restart the audio file playback.
The audio is constantly suspended and resumed.
My problem is that if I have set the setNotifyInterval to 1000ms and suspend the audio stream for 5 seconds I will get 5 consecutive notify() in a row when resuming the playback.
If I play without suspending I get as expected one notify() per second.
My understanding is that I should get notified once for every second of processed audio buffer is setting the interval to 1000.I'm using QtCreator 4.14.0 and Qt 5.12.2
Am I missing something or is Qt not behaving as expected?
Any suggestions of workarounds or how I should do this correctly? -
Hi and welcome to devnet,
Which OS are you running ?
Can you share a minimal compilable example that shows this behaviour ? -
@SGaist
Hello and thank you for your warm welcome :o)I'm running Windows 10 pro but not the latest 2020 H2 version.
I have stripped my design to a minimum to demonstrate my problem.
In the debug text window I print a line every time an event is emitted from the QAudioOutput which is supposed to happen for each second of playing time.Description of the program
The program plays a tone from a buffer as long as the Key button is pressed down.
When the key button is released the audio is suspended, i.e. paused.
When the key button is pressed the audio is resumed.
When the program starts I start playing the stream and emediately suspend it.
The buffer only holds about 2 minutes of audio and I need to know when to restart playing the buffer from beginning before I run out of audio...
The reason for this implementation is that I need to play a sinus when key is pressed with as little latency as possible. Maybe I could solve the sinus play without latency in another way but this should also work.
The full program is a morse key remote controller and need an audio feedback of the key button.To repeat my problem:
If you start the program and immediately click the large Key button and hold it down you'll get events once every second as expected but if you wait for a few seconds before you click the button you will get the number of events equal to the number of seconds since the program started or since you last pressed the button.I understand the behaviour as if the event is constantly going on counting time but only sending the accumulated events when the stream actually is playing.
I have no idea how to attach a file here so I put the example on:
https://easyupload.io/qa7n6oEnough information to understand my problem and perhaps repeat it at your side?