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. QByteArray AudioOutput Example

QByteArray AudioOutput Example

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 368 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.
  • PsnarfP Offline
    PsnarfP Offline
    Psnarf
    wrote on last edited by
    #1

    Re: https://doc.qt.io/qt-5/qtmultimedia-multimedia-audiooutput-example.html (Linux)
    Generator::generateData() declares "qint64 length" but then calls QByteArray::resize(length), which takes an int, which apparently is the maximum size of a QByteArray. I found a 2012 response suggesting sizeof(int) was big enough. My 2017 laptop came with 16Gb, so I can easily allocate a contiguous block larger than 2Gb. That's not the issue, should not the example use a qint32 instead of a qint64? For example, a debug run with a breakpoint after the length calc returns length=88200. Methinks, perhaps qint64 is overkill?

    P.S. The Q_UNUSED macros should not be terminated with a semi-colon in writedata().
    BTW, I can easily send the example into underrun. I'm still studying the code as I convert it to use a Designer Dialog form. Don't understand where the underruns are coming from, yet. Click push/pull going back and forth between alsa and pulse does it.

    ALSA lib pcm.c:8432:(snd_pcm_recover) underrun occurred

    JonBJ 1 Reply Last reply
    0
    • PsnarfP Psnarf

      Re: https://doc.qt.io/qt-5/qtmultimedia-multimedia-audiooutput-example.html (Linux)
      Generator::generateData() declares "qint64 length" but then calls QByteArray::resize(length), which takes an int, which apparently is the maximum size of a QByteArray. I found a 2012 response suggesting sizeof(int) was big enough. My 2017 laptop came with 16Gb, so I can easily allocate a contiguous block larger than 2Gb. That's not the issue, should not the example use a qint32 instead of a qint64? For example, a debug run with a breakpoint after the length calc returns length=88200. Methinks, perhaps qint64 is overkill?

      P.S. The Q_UNUSED macros should not be terminated with a semi-colon in writedata().
      BTW, I can easily send the example into underrun. I'm still studying the code as I convert it to use a Designer Dialog form. Don't understand where the underruns are coming from, yet. Click push/pull going back and forth between alsa and pulse does it.

      ALSA lib pcm.c:8432:(snd_pcm_recover) underrun occurred

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Psnarf
      Don't understand your question. Assuming you are now compiling 64-bit (right? and that's perhaps unlike in 2012), then sizeof(qint64) == sizeof(int). It will only resize to the value specified, even if the variable could hold a huge number. If the length is only 88K that's what it will resize to, regardless of the type of the variable.

      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