Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. seg fault for qt5+pulseaudio

seg fault for qt5+pulseaudio

Scheduled Pinned Locked Moved Solved Mobile and Embedded
segmentationfaultpulseaudioqtmultimedia
3 Posts 2 Posters 1.7k 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.
  • M Offline
    M Offline
    Mark81
    wrote on 4 May 2016, 05:38 last edited by
    #1

    Hi,
    I'm trying to test the multimedia support for Qt5 with pulseaudio backend. I'm running a custom buildroot environment on an RPi3.
    I have checked the following are working:

    - qt5
    - alsa (aplay / arecord)
    - pulseaudio (paplay / parecord)
    

    This is the code snippet, as found in the docs:

    QFile file(filename);
        file.open(QIODevice::ReadOnly);
        qDebug() << file.size();
    
        QAudioFormat format;
        format.setSampleRate(8000);
        format.setChannelCount(2);
        format.setSampleSize(16);
        format.setCodec("audio/pcm");
        format.setByteOrder(QAudioFormat::LittleEndian);
        format.setSampleType(QAudioFormat::SignedInt);
    
        QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
        if (!info.isFormatSupported(format)) {
            qWarning() << "Raw audio format not supported by backend, cannot play audio.";
            return;
        }
    
        m_audio = new QAudioOutput(format, this);
        m_audio->start(&file);
    

    The file is correctly opened, no sounds is emitted but after few seconds the application crashes due to segmentation fault.
    The debugger shows some disassemled code and the stack calls on thead #1 are these:

    1	QIODevice::read(char *, long long)			0x75efcf48	
    2	QPulseAudioOutput::qt_static_metacall(QObject *, QMetaObject::Call, int, void * *)			0x724cb79c	
    

    What should I do understand the cause of the seg fault?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Paul Colby
      wrote on 4 May 2016, 05:46 last edited by
      #2

      This line:

      m_audio->start(&file);
      

      Is giving m_audio a pointer to the (looks-to-be) local file variable, which won't be valid once file goes out of scope.

      Cheers.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        Mark81
        wrote on 4 May 2016, 05:59 last edited by
        #3

        Yeah. It happens when you copy&paste without double check comments and you're afraid about "it could not work" :)
        Thanks!

        1 Reply Last reply
        0

        3/3

        4 May 2016, 05:59

        • Login

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