QAudioDecoder not emitting signals
-
On Windows (under which QAudioDecoder is supposed to work), i call a background thread via boost::threads, and in that thread i create a QAudioDecoder, connect EVERY signal it provides to a slot-handler, load it up with an mp3 file, and play it, then poll for events while in an "audio-pump" loop. The only signals i get are:
14: Signal: Source Changed 14: Signal: State Changed: Decoding
I don't receive any other signals, significantly i get no
bufferReady()
signal, therefore i get no audio.The documentation states this: "If a
QObject
has no thread affinity (that is, if thread() returns zero), or if it lives in a thread that has no running event loop, then it cannot receive queued signals or posted events"To be clear, i have called
this->thread()
and it does indeed return non-null, and during my audio-pump loop, i do callprocessEvents()
which should allow the decoding and its signals right?I could not find example code of a working QAudioDecoder.
-
okay turns out i wasn't creating the thread correctly.
when i switched to "worker thread" style as explained here, it all started working.
:)
-
Hi,
Your thread does not have an event loop running. You are likely calling your QApplication processEvent method which lies in a different thread and is not related to the one where your QAudioDecoder lies.
Why not use a QThread for that ?
-
okay turns out i wasn't creating the thread correctly.
when i switched to "worker thread" style as explained here, it all started working.
:)