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. QAudioOutput in pull mode
Forum Updated to NodeBB v4.3 + New Features

QAudioOutput in pull mode

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 433 Views 1 Watching
  • 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
    Audetto
    wrote on last edited by
    #1

    I am trying to create a QIODevice and pass it to a QAudioOutput->start(&device) (pull mode)

    Then in the QIODevice::readData() method I simply produce 0s and check how much data is read by the Qt framework.
    I initialise a timer on one side and count how many frames are read on the other side.
    I would expect these 2 quantities to move in sync (clearly not exactly the same).

    And it happens exactly that until I resize the main Qt window. Then the amount of data read from the QIODevice slows down.

    I am using Fedora 31 GNOME Wayland, pulse

    Audio format 44100, 1, 16bit Signed Int. (tried different choices, no diff)

    The difference is huge, after 20 seconds and resizing the window I get

    Actual frames read 536576
    Expected frames 848660 (elapsed * frames per ms)

    If I stop resizing, they stabilise.

    To be crystal clear, my dummy readData function always returns in no time all the data required.

    The state changes and some underrun happens, but again, the device is not to be blamed for this.

    The category of the QAudioOutput seems to change a bit ("game" vs other), but in all cases resizing causes havoc.

    Reading other posts in the forum it seems Qt AudioOutput is a dead end road. Not to be used.
    https://forum.qt.io/topic/40026/real-time-audio-processing-with-qt5-general-concept

    Is this true? What is the point of adding this feature if it works that badly?

    aha_1980A 1 Reply Last reply
    0
    • A Audetto

      I am trying to create a QIODevice and pass it to a QAudioOutput->start(&device) (pull mode)

      Then in the QIODevice::readData() method I simply produce 0s and check how much data is read by the Qt framework.
      I initialise a timer on one side and count how many frames are read on the other side.
      I would expect these 2 quantities to move in sync (clearly not exactly the same).

      And it happens exactly that until I resize the main Qt window. Then the amount of data read from the QIODevice slows down.

      I am using Fedora 31 GNOME Wayland, pulse

      Audio format 44100, 1, 16bit Signed Int. (tried different choices, no diff)

      The difference is huge, after 20 seconds and resizing the window I get

      Actual frames read 536576
      Expected frames 848660 (elapsed * frames per ms)

      If I stop resizing, they stabilise.

      To be crystal clear, my dummy readData function always returns in no time all the data required.

      The state changes and some underrun happens, but again, the device is not to be blamed for this.

      The category of the QAudioOutput seems to change a bit ("game" vs other), but in all cases resizing causes havoc.

      Reading other posts in the forum it seems Qt AudioOutput is a dead end road. Not to be used.
      https://forum.qt.io/topic/40026/real-time-audio-processing-with-qt5-general-concept

      Is this true? What is the point of adding this feature if it works that badly?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @Audetto,

      The category of the QAudioOutput seems to change a bit ("game" vs other), but in all cases resizing causes havoc.

      It has been like that on Windows for years. Click on the title bar of a Window, and it stops refreshing its contents. I didn't know that Linux now copies this "feature". Probably your use case is one of the few where a second thread for the audio processing really makes sense.

      Disclaimer: I have not done that so I can't tell you much about this topic.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Audetto
        wrote on last edited by
        #3
        1. Using the 2nd thread is a good suggestion, but the documentation does not say anything about this being valid or not and all the question I saw about this went unanswered

        2. the difference between push and pull is not explained very well I believe. I read the code for the pulseaudio case and I have understood that the only difference is who owns the timer.

        In pull mode, the AudioOutput owns the timer and will call you to get the data. In push mode your application will require a timer (if one is not already present) and will do exactly the same, ie write the data.

        1 Reply Last reply
        0

        • Login

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