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 plays only buffered data on resume
Forum Updated to NodeBB v4.3 + New Features

QAudioOutput plays only buffered data on resume

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.8k 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.
  • G Offline
    G Offline
    grzegorzn
    wrote on last edited by
    #1

    Hello.

    I've written simple .wav player using QAudioOutput class. I've created simple QIODevice class which is used by QAudioOutput object. It works fine except when I want to suspend and resume the playback. After resuming only buffered data are played and then there is silence. The funny thing is that data are still being fetched from QIODevice object (QAudioOutput calls readData() on QIODevice), there is just no sound. Suspending and resuming playback second time brings everything back to normal.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should add which version of Qt you are using on which OS

      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
      • G Offline
        G Offline
        grzegorzn
        wrote on last edited by
        #3

        It's Qt 4.8 on Linux.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Latest 4.8.6 ?

          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
          • G Offline
            G Offline
            grzegorzn
            wrote on last edited by
            #5

            No, I installed Qt from packets and it's version 4.8.2.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then you should get 4.8.6 to check whether you still have that problem

              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
              • G Offline
                G Offline
                grzegorzn
                wrote on last edited by
                #7

                It would be problematic, I would need to install Qt from sources. Moreover I see no point in trying 4.8.6 as there were no changes to Qt Multimedia (pulseaudio part) since 2011 and 4.8.2 was released in 2012.

                The problem is as follows:

                1. playback is resumed
                2. state is changed to Active
                3. there are 2 reads from QIODevice
                4. sound is played for a very short time
                5. there is a buffer underflow
                6. state is changed to Idle
                7. there are still reads from QIODevice but there is no sound. I think this is due to this code from qaudiooutput_pulse.cpp:
                  @
                  l = m_audioSource->read(buffer, m_periodSize);
                  if (l > 0) {
                  if (m_deviceState != QAudio::ActiveState)
                  return true;
                  qint64 bytesWritten = write(buffer, l);
                  Q_UNUSED(bytesWritten);
                  }
                  @

                This explains the funny behaviour when data are read from supplied device but not played back. Once the state is changed to Idle, there is no chance for data to be written to buffer although they are still fetched from QIODevice. Anyway the bigger problem is why there is buffer underflow just after resume although the device always returns 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