Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can QAudioOutput pull data from a QIOdevice, in a thread?

Can QAudioOutput pull data from a QIOdevice, in a thread?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qthreadqaudiooutput
5 Posts 2 Posters 921 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aart
    wrote on 10 Aug 2020, 12:49 last edited by
    #1

    I am writing a low level audio application where i want to use a QAudioOutput in "pull" mode, requesting its samples from a QIODevice. I create a QAudioOutput and QIODevice and have moved both of them to my audioThread. I make sure to call QAudioOutput::start(QIODevice *) on the audio thread. But for some reason when i check from which thread QIODevice::readData is called it is still the main gui thread.

    Is it impossible to use QAudioOutput with pulling from a QIODevice in a thread, or have i forgotten something?
    Thanks in advance for any help!

    A 1 Reply Last reply 10 Aug 2020, 13:09
    0
    • A aart
      10 Aug 2020, 12:49

      I am writing a low level audio application where i want to use a QAudioOutput in "pull" mode, requesting its samples from a QIODevice. I create a QAudioOutput and QIODevice and have moved both of them to my audioThread. I make sure to call QAudioOutput::start(QIODevice *) on the audio thread. But for some reason when i check from which thread QIODevice::readData is called it is still the main gui thread.

      Is it impossible to use QAudioOutput with pulling from a QIODevice in a thread, or have i forgotten something?
      Thanks in advance for any help!

      A Offline
      A Offline
      aart
      wrote on 10 Aug 2020, 13:09 last edited by
      #2

      @aart There seems to be a bug report about this same issue: https://bugreports.qt.io/browse/QTBUG-43690. The solution given here is "It only pulls data in the GUI thread if the QAudioOutput object resides in the GUI thread. It's your responsibility to move the object to another thread if you want it to process data there." However I have checked that the QAudioOutput has been moved to the audio thread, just like the QIOdevice.

      Answer is still unclear.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 10 Aug 2020, 18:43 last edited by
        #3

        Hi,

        Are you using the worker object approach ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aart
          wrote on 11 Aug 2020, 10:18 last edited by
          #4

          so ive been working on this problem a bit more, and i have some suspicion what the problem is. I have also tried using the QAudioOutput in "Push" mode, and i found that the sample writing only happens in the worker thread when i use my own QTimer. If i use the QAudioOutput build-in notify mechanism, everything runs in the gui thread.

          The starnge thing is that i explicitly move the QAudioOutput to the audio thread, i guess for some reason the timer inside responsible for the notify signals is not moved with it? Maybe this also explains why "Pull" mode ran on the wrong thread. i can imagine that Pull uses the internal notify timer.

          last note: I am using Qt 5.12.4, on Windows

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 11 Aug 2020, 11:09 last edited by
            #5

            Can you share the code you are using ?
            Do you get any warning about a timer being in the wrong thread ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            5/5

            11 Aug 2020, 11:09

            • Login

            • Login or register to search.
            5 out of 5
            • First post
              5/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved