Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. Stuttering audio that hangs: QSoundEffect and QMediaPlayer

Stuttering audio that hangs: QSoundEffect and QMediaPlayer

Scheduled Pinned Locked Moved Solved QtonPi
4 Posts 2 Posters 4.2k Views 2 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.
  • J Offline
    J Offline
    JHBR
    wrote on last edited by
    #1

    Hi

    For a long time now I've been struggling with getting an application to run smoothly on my RPi3. The issue is when playing audio. The application uses QMediaPlayer to stream mp3-files, while at the same time playing wav-files with QSoundEffect when certain buttons are pressed, events happen etc.

    The QSoundEffect sounds stutters a lot, sometimes halting all audio playback (even the concurrently streaming mp3) until I trigger another QSoundEffect, after which the "queued" sounds all come "stumbling" at once and the mp3 resumes, albeit usually with a lot of stuttering.

    If I try to run the application without pulseaudio running, I get the following error:

    xcb_connection_has_error() returned true
    PulseAudioService: pa_context_connect() failed
    xcb_connection_has_error() returned true
    PulseAudioService: pa_context_connect() failed
    Assertion 'pthread_mutex_unlock(&m->mutex) == 0' failed at pulsecore/mutex-posix.c:110, function pa_mutex_unlock(). Aborting.
    

    However, if I also don't use QSoundEffect, the application runs perfectly without pulseaudio. So I assume QSoundEffect is dependant on pulseaudio, while QMediaPlayer is not.

    With pulsaudio running, even if I don't use QSoundEffect, the mp3 playback still has a tendency to stutter, especially when I toggle quickly to the next/previous track (I use QMediaPlaylist together with QMediaPlayer). Interestingly, however, without pulseaudio running, the mp3-streaming with QMediaPlayer is perfectly smooth, with less delay and no stuttering.

    This is on a Raspberry Pi 3 with Qt 5.8 (both native build and cross-compiled on Ubuntu).
    I initially tried it on Qt 5.7, experiencing the same issues, but I was hoping Qt 5.8, with its transfer from Gstreamer0.10 to Gstreamer1.0 as a backend, would perform better. Alas, the same issue remains.

    The application audio works perfectly with Qt 5.7 on Windows 8.1 and with Qt 5.8 on Unbuntu 16.04.

    Any help or tips would be greatly appreciated!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JHBR
      wrote on last edited by
      #2

      If of any interest, this is the config.summary from cross-compiling Qt 5.8 for the RPi3:

      Building on: linux-g++ (x86_64, CPU features: mmx sse sse2)
      Building for: devices/linux-rpi3-g++ (arm, CPU features: neon)
      Configuration: cross_compile compile_examples enable_new_dtags largefile neon precompile_header shared rpath accessibility release c++11 concurrent dbus mremap reduce_exports stl
      Build options:
        Mode ................................... release
        Building shared libraries .............. yes
        Using C++ standard ..................... C++11
        Using gold linker ...................... no
        Using new DTAGS ........................ yes
        Using precompiled headers .............. yes
        Using LTCG ............................. no
        Target compiler supports:
          NEON ................................. yes
        Build parts ............................ libs
      Qt modules and options:
        Qt Concurrent .......................... yes
        Qt D-Bus ............................... yes
        Qt D-Bus directly linked to libdbus .... yes
        Qt Gui ................................. yes
        Qt Network ............................. yes
        Qt Sql ................................. yes
        Qt Testlib ............................. yes
        Qt Widgets ............................. yes
        Qt Xml ................................. yes
      Support enabled for:
        Accessibility .......................... yes
        Using pkg-config ....................... yes
        QML debugging .......................... yes
        udev ................................... yes
        Using system zlib ...................... yes
      Qt Core:
        DoubleConversion ....................... yes
          Using system DoubleConversion ........ no
        GLib ................................... yes
        iconv .................................. yes
        ICU .................................... no
        Logging backends:
          journald ............................. no
          syslog ............................... no
          slog2 ................................ no
        Using system PCRE ...................... no
      Qt Network:
        getaddrinfo() .......................... yes
        getifaddrs() ........................... yes
        IPv6 ifname ............................ yes
        libproxy ............................... no
        OpenSSL ................................ yes
          Qt directly linked to OpenSSL ........ no
        SCTP ................................... no
        Use system proxies ..................... yes
      Qt Sql:
        DB2 (IBM) .............................. no
        InterBase .............................. no
        MySql .................................. no
        OCI (Oracle) ........................... no
        ODBC ................................... yes
        PostgreSQL ............................. yes
        SQLite2 ................................ yes
        SQLite ................................. yes
          Using system provided SQLite ......... no
        TDS (Sybase) ........................... yes
      Qt Gui:
        FreeType ............................... yes
          Using system FreeType ................ yes
        HarfBuzz ............................... yes
          Using system HarfBuzz ................ no
        Fontconfig ............................. yes
        Image formats:
          GIF .................................. yes
          ICO .................................. yes
          JPEG ................................. yes
            Using system libjpeg ............... yes
          PNG .................................. yes
            Using system libpng ................ yes
        OpenGL:
          EGL .................................. yes
          Desktop OpenGL ....................... no
          OpenGL ES 2.0 ........................ yes
          OpenGL ES 3.0 ........................ no
          OpenGL ES 3.1 ........................ no
        Session Management ..................... yes
      Features used by QPA backends:
        evdev .................................. yes
        libinput ............................... yes
        mtdev .................................. yes
        tslib .................................. yes
        xkbcommon-evdev ........................ yes
      QPA backends:
        DirectFB ............................... no
        EGLFS .................................. yes
        EGLFS details:
          EGLFS i.Mx6 .......................... no
          EGLFS i.Mx6 Wayland .................. no
          EGLFS EGLDevice ...................... no
          EGLFS GBM ............................ yes
          EGLFS Mali ........................... no
          EGLFS Raspberry Pi ................... yes
          EGL on X11 ........................... no
        LinuxFB ................................ yes
        Mir client ............................. no
        X11:
          Using system provided XCB libraries .. yes
          EGL on X11 ........................... no
          Xinput2 .............................. yes
          XCB XKB .............................. yes
          XLib ................................. yes
          XCB render ........................... yes
          XCB GLX .............................. yes
          XCB Xlib ............................. yes
          Using system-provided xkbcommon ...... no
      Qt Widgets:
        GTK+ ................................... no
        Styles ................................. Fusion Windows
      Qt PrintSupport:
        CUPS ................................... yes
      QtXmlPatterns:
        XML schema support ..................... yes
      Qt QML:
        QML interpreter ........................ yes
        QML network support .................... yes
      Qt Quick:
        Direct3D 12 ............................ no
        AnimatedImage item ..................... yes
        Canvas item ............................ yes
        Support for Quick Designer ............. yes
        Flipable item .......................... yes
        GridView item .......................... yes
        ListView item .......................... yes
        Path support ........................... yes
        PathView item .......................... yes
        Positioner items ....................... yes
        ShaderEffect item ...................... yes
        Sprite item ............................ yes
      Qt Gamepad:
        SDL2 ................................... no
      Qt 3D:
        System Assimp .......................... no
      Qt Bluetooth:
        BlueZ .................................. no
        BlueZ Low Energy ....................... no
        Linux Crypto API ....................... no
      Qt Sensors:
        sensorfw ............................... no
      Qt Multimedia:
        ALSA ................................... yes
        GStreamer 1.0 .......................... yes
        GStreamer 0.10 ......................... no
        Video for Linux ........................ yes
        OpenAL ................................. no
        PulseAudio ............................. yes
        Resource Policy (libresourceqt5) ....... no
        DirectShow ............................. no
        Windows Media Foundation ............... no
      Qt Location:
        Gypsy GPS Daemon ....................... no
        WinRT Geolocation API .................. no
      
      Note: Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx
      
      Note: PKG_CONFIG_LIBDIR automatically set to /home/jhbr/raspi/sysroot/usr/lib/pkgconfig:/home/jhbr/raspi/sysroot/usr/share/pkgconfig:/home/jhbr/raspi/sysroot/usr/lib/arm-linux-gnueabihf/pkgconfig
      
      Note: PKG_CONFIG_SYSROOT_DIR automatically set to /home/jhbr/raspi/sysroot
      
      Note: Dropped compiler flags '-pthread' when detecting library 'glib'.
      
      Note: Dropped compiler flags '-pthread' when detecting library 'gstreamer'.
      
      Note: Dropped compiler flags '-pthread' when detecting library 'gstreamer_app'.
      

      And among others, I have installed the following relevant dependencies on the RPi3:

      DEPS+=" libasound2-dev"
      DEPS+=" libpulse-dev"
      DEPS+=" libavcodec-dev"
      DEPS+=" libavformat-dev"
      DEPS+=" libswscale-dev"
      DEPS+=" gstreamer-tools"
      DEPS+=" libgstreamer1.0-dev"
      DEPS+=" libgstreamer-plugins-base1.0-dev"
      DEPS+=" gstreamer1.0-omx"
      DEPS+=" gstreamer1.0-plugins-good"
      DEPS+=" gstreamer1.0-plugins-bad"
      DEPS+=" gstreamer1.0-plugins-ugly"
      DEPS+=" gstreamer1.0-libav"
      DEPS+=" gstreamer1.0-clutter"
      DEPS+=" gstreamer1.0-fluendo-mp3"
      DEPS+=" gstreamer1.0-pulseaudio"
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        StoatPatronus
        wrote on last edited by
        #3

        I realize that this topic is older (2 months at the time I'm writing this) but I stumbled across it when I was having a similar issue with QSound and QSoundEffect. My solution was to uninstall PulseAudio from my Pi, and install libasound2-dev. Then I rebuilt Qt with -no-pulseaudio -alsa configure options. My QSound and QSoundEffect programs work great now.

        J 1 Reply Last reply
        1
        • S StoatPatronus

          I realize that this topic is older (2 months at the time I'm writing this) but I stumbled across it when I was having a similar issue with QSound and QSoundEffect. My solution was to uninstall PulseAudio from my Pi, and install libasound2-dev. Then I rebuilt Qt with -no-pulseaudio -alsa configure options. My QSound and QSoundEffect programs work great now.

          J Offline
          J Offline
          JHBR
          wrote on last edited by
          #4

          Thank you, @StoatPatronus , that seemed to do the trick for me too!

          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