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. Unable to play a wav file with Audio component

Unable to play a wav file with Audio component

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
qt5.5.1colibri-t20
35 Posts 4 Posters 16.3k 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.
  • zyendZ Offline
    zyendZ Offline
    zyend
    wrote on last edited by A Former User
    #1

    Hi all,

    Now 3 days I'm stuck with a tricky issue!
    I've built an image for my embedded device based on a Colibri T20 board, using Yocto.
    I"ve added Qt5, using X11 (because Tegra20 drivers from nvidia support hw accel only with X11...).
    At this point, everything works fine.
    I've also generated the respective SDK to build application for the respective platform..
    Works fine.

    I wrote a simple application to play audio file, very basic...just to play wav files...
    It does not work. No sound output.

    import QtMultimedia 5.5

    Item {
    
    ...
    Audio {
     id: audioPlayer
    source: "file:///opt/track.wav"
    }
    ..
    onClick() {
      idPlayer.play()
    }
    
    }
    

    This code works fine on my host linux.
    But not on my Colibri.
    Qt 5.5.1 was firstly built with ALSA, pulseaudio (gstreamer plugins...).
    No outpût.

    But in the linux, I can play the wav file using:

    aplay /opt/track.wav
    

    So I assume that my alsa driver are up-to-date.

    Then, I 've recompiled Qt 5.5.1 without pulseaudio....
    It does not work better :(

    To be honnest, I'm not very experienced with alsa and pulseaudio matter. I'm very fustrated bzecause I don't understand what's happening under the abstracted layer of QtMultuimedia.

    Any suggestion is welcome...This issue is simply driving me mad ;)

    K.

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

      Hi,

      Do you see any error message on the console ?

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

        SGaist,

        Before recompîling Qt5.51 without pulseaudio, I had the following message in the console:

        PulseAudioService: pa_context_connect() failed
        

        Unfortunately, recompiling without pulseaudio doesnot display the message anymore...but it doesn't fix anything. I can't hear anything :(

        K.

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

          Do you have Pulseaudio running on your device ?

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

            No.
            I've removed "pulseaudio" from the Yocto generated Distro.

            But the command line:

            aplay /opt/track.wav
            

            still works though...

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

              Because it's using ALSA directly.

              Did you try to build the ALSA backend for Qt Multimedia ?

              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
              1
              • zyendZ Offline
                zyendZ Offline
                zyend
                wrote on last edited by
                #7

                Yes, I think so.

                I can find libqtaudio_alsa.so in /usr/lib/qt/plugins.

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

                  Start your application with QT_DEBUG_PLUGINS=1 to see if there's a problem when loading the plugin.

                  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
                  1
                  • zyendZ Offline
                    zyendZ Offline
                    zyend
                    wrote on last edited by
                    #9

                    At first glance, the plugins get loaded.

                    Got keys from plugin meta data ("alsa")
                    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/qt5/plugins/audio/libqtaudio_alsa.so.new"
                    Found metadata in lib /usr/lib/qt5/plugins/audio/libqtaudio_alsa.so.new, metadata=
                    {
                        "IID": "org.qt-project.qt.audiosystemfactory/5.0",
                        "MetaData": {
                            "Keys": [
                                "alsa"
                            ]
                        },
                        "className": "QAlsaPlugin",
                        "debug": false,
                        "version": 328961
                    }
                    
                    
                    Got keys from plugin meta data ("alsa")
                    QFactoryLoader::QFactoryLoader() checking directory path "/opt/pga/audio" ...
                    loaded library "/usr/lib/qt5/plugins/audio/libqtaudio_alsa.so"
                    

                    :(

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

                      Looks good on that point.

                      Did you check which output QtMultimedia sees as available ?

                      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
                      • zyendZ Offline
                        zyendZ Offline
                        zyend
                        wrote on last edited by
                        #11

                        What do you mean exactly ?

                        Yesterday, in the main.cpp, I dumped the

                        QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)
                        

                        Is that what you meant ? And yes, it dumps the same devices as with

                        aplay -L
                        
                        O 1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          That's that yes and the result also looks good.

                          Did you check whether the element raises an error ?

                          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
                          • zyendZ Offline
                            zyendZ Offline
                            zyend
                            wrote on last edited by
                            #13

                            No error raised.

                            However, in the onClick() handler where idPlay->play() is launched (see code snippet above..),
                            I traced the values of some properties of tha Audio component.

                            qml: status =  2
                            qml: playvolume =  1
                            qml: muted =  false
                            qml: error code =  0 , string=
                            qml: src =  file:///opt/pga/track00.wav
                            qml: availability =  0
                            qml: duration =  -1
                            qml: hasAudio =  false
                            

                            Weird. duration = -1, hasAudio = false and however, no error code / string...

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

                              The path to the file looks different from your QML sample code.

                              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
                              • zyendZ Offline
                                zyendZ Offline
                                zyend
                                wrote on last edited by
                                #15

                                Yes, because I changed the path between my tests, but the paths are valids.

                                I really don't understand why Qt does not raise any error.
                                Everything looks correct.
                                status = 2, that is: "the Media has been loaded".

                                So it looks like a final phase is not complete. Isn't it ?

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

                                  Can you test the functionality with C++ ?

                                  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
                                  • zyendZ Offline
                                    zyendZ Offline
                                    zyend
                                    wrote on last edited by zyend
                                    #17

                                    I've put this sample code in the C++ side:

                                    init()
                                    {
                                    ...
                                     connect(&m_player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(on_mediaPlayer_error(QMediaPlayer::Error)));^
                                     connect(&m_player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(on_mediaPlayer_stateChanged(QMediaPlayer::State)));^
                                     connect(&m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, 
                                    SLOT(on_mediaPlayer_mediaStatusChanged(QMediaPlayer::MediaStatus)));
                                    
                                    qDebug() << "Attempt to read mediacontent";
                                    QMediaContent content(QUrl::fromLocalFile("/opt/pga/track00.wav"));
                                    qDebug() << "MediaContent: isNull = " << content.isNull();
                                    m_player.setMedia(content);
                                    m_player.play();
                                    }
                                    

                                    Each of the slots above print the value of their respective parameter in stdout.

                                    Output from my host linux:

                                    Attempt to read mediacontent
                                    MediaContent: isNull =  false
                                    <MainWindow::on_mediaPlayer_mediaStatusChanged> status =  QMediaPlayer::LoadingMedia
                                    <MainWindow::on_mediaPlayer_stateChanged> state =  QMediaPlayer::PlayingState
                                    <MainWindow::on_mediaPlayer_mediaStatusChanged> status =  QMediaPlayer::BufferedMedia
                                    

                                    Output from my colibri-t20:

                                    Attempt to read mediacontent
                                    MediaContent: isNull =  false
                                    <MainWindow::on_mediaPlayer_mediaStatusChanged> status =  QMediaPlayer::LoadingMedia
                                    

                                    It's stuck on LoadingMedia.
                                    No more.

                                    :(

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

                                      Ok...

                                      You should rebuilt the plugin uncommenting the DEBUG_AUDIO define to see if it gives you more information about what is happening.

                                      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
                                      • zyendZ Offline
                                        zyendZ Offline
                                        zyend
                                        wrote on last edited by
                                        #19

                                        Hi,

                                        Unfortunately it doesn't trace more information at all...

                                        Found metadata in lib /usr/lib/qt5/plugins/audio/libqtaudio_alsa.so, metadata=
                                        {
                                            "IID": "org.qt-project.qt.audiosystemfactory/5.0",
                                            "MetaData": {
                                                "Keys": [
                                                    "alsa"
                                                ]
                                            },
                                            "className": "QAlsaPlugin",
                                            "debug": false,
                                            "version": 328961
                                        }
                                        
                                        
                                        Got keys from plugin meta data ("alsa")
                                        QFactoryLoader::QFactoryLoader() checking directory path "/opt/pga/audio" ...
                                        loaded library "/usr/lib/qt5/plugins/audio/libqtaudio_alsa.so"
                                        DeviceInfo name =  "sysdefault:CARD=colibrit20wm971" , codecs =  "audio/pcm"
                                        DeviceInfo name =  "default:CARD=colibrit20wm971" , codecs =  "audio/pcm"
                                        DeviceInfo name =  "default" , codecs =  "audio/pcm"
                                        Default OutputDevice:  "sysdefault:CARD=colibrit20wm971"
                                        Attempt to read mediacontent
                                        MediaContent: isNull =  false
                                        <MainWindow::on_mediaPlayer_mediaStatusChanged> status =  QMediaPlayer::LoadingMedia , bufferStatus =  0
                                        <MainWindow::initialize()> : bufferStatus =  0
                                        screen dpi =  96.1517
                                        screen geo =  QRect(0,0 480x800)
                                        QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/qt5/plugins/accessiblebridge" ...
                                        QFactoryLoader::QFactoryLoader() checking directory path "/opt/pga/accessiblebridge" ...
                                        QSGContext::initialize: stencil buffer support missing, expect rendering errors
                                        Updating catalog.
                                        <MediaCatalog::roleNames() > called.
                                        qml: size of catalog:  3
                                        qml: playlaunched...status =  1
                                        qml: playvolume =  1
                                        qml: muted =  false
                                        qml: error code =  0 , string=
                                        qml: src =
                                        qml: availability =  0
                                        qml: duration =  -1
                                        qml: hasAudio =  false
                                        
                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #20

                                          Does the device info look correct for your system ?
                                          Can you compare with that aplay uses ?

                                          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

                                          • Login

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