Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77155

QMediaPlayer hangs in state LoadedMedia

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3: Somewhat important
    • None
    • 5.12.4, 5.12.5, 5.12.6
    • Multimedia
    • None
    • Linux/Other display system

    Description

      I have a custom AudioQueue class, that can add new files to the playlist, or throw everything away if the end of the playlist is reached. The latter is done by waiting for currentIndexChanged signal sending -1. Since this sometimes just doesn't progress anymore I have the following debug code added:

      connect(m_MediaPlayer, &QMediaPlayer::stateChanged, [] (auto s) { qDebug() << __PRETTY_FUNCTION__ << s; });
      connect(m_MediaPlayer, &QMediaPlayer::mediaStatusChanged, [] (auto s) { qDebug() << __PRETTY_FUNCTION__ << s; });
      

      Another function dumppl() will dump the playlist contents and player state at several points. Now the following sequence happens:

      Thread 0x7fffd8d38700 (LWP 2753) exited]
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::LoadingMedia
      [New Thread 0x7fffd8d38700 (LWP 2754)]
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::BufferedMedia
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::EndOfMedia
      void AudioQueue::playlistIndexChanged(int) 7
      7 QMediaPlayer::StoppedState QMediaPlayer::EndOfMedia QUrl("file:///mnt/Data/tfi3_0.wav")
      void dumppl(const QMediaPlayer*) 6 QUrl("file:///mnt/Data/tfi3_0.wav")
      void dumppl(const QMediaPlayer*) 7 QUrl("file:///mnt/Data/tfi2_0.wav")
      void dumppl(const QMediaPlayer*) 8 QUrl("file:///mnt/Data/tfi5_0.wav")
      void dumppl(const QMediaPlayer*) 9 QUrl("file:///mnt/Data/tfi4_0.wav")
      
      // this is the last "good" transition, i.e. the next song is actually played
      
      [Thread 0x7fffd8d38700 (LWP 2754) exited]
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::LoadingMedia
      [New Thread 0x7fffd8d38700 (LWP 2755)]
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::BufferedMedia
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::EndOfMedia
      void AudioQueue::playlistIndexChanged(int) 8
      8 QMediaPlayer::StoppedState QMediaPlayer::EndOfMedia QUrl("file:///mnt/Data/tfi2_0.wav")
      void dumppl(const QMediaPlayer*) 7 QUrl("file:///mnt/Data/tfi2_0.wav")
      void dumppl(const QMediaPlayer*) 8 QUrl("file:///mnt/Data/tfi5_0.wav")
      void dumppl(const QMediaPlayer*) 9 QUrl("file:///mnt/Data/tfi4_0.wav")
      void dumppl(const QMediaPlayer*) 10 QUrl("file:///mnt/Data/tfi2_0.wav")
      
      // this happens when the song finished playing, but nothing happens here anymore
      
      [Thread 0x7fffd8d38700 (LWP 2755) exited]
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::LoadingMedia
      [New Thread 0x7fffd8d38700 (LWP 2756)]
      AudioQueue::AudioQueue(QObject*)::<lambda(auto:3)> [with auto:3 = QMediaPlayer::MediaStatus] QMediaPlayer::LoadedMedia
      
      // now a different caller comes and checks if the queue is empty, and since it is not, does not modify it
      
      bool AudioQueue::empty() const
      8 QMediaPlayer::PlayingState QMediaPlayer::LoadedMedia QUrl("file:///mnt/Data/tfi5_0.wav")
      void dumppl(const QMediaPlayer*) 7 QUrl("file:///mnt/Data/tfi2_0.wav")
      void dumppl(const QMediaPlayer*) 8 QUrl("file:///mnt/Data/tfi5_0.wav")
      void dumppl(const QMediaPlayer*) 9 QUrl("file:///mnt/Data/tfi4_0.wav")
      void dumppl(const QMediaPlayer*) 10 QUrl("file:///mnt/Data/tfi2_0.wav")
      

      dumppl() looks like this, I have only truncated the lists above for sanity:

      static void dumppl(const QMediaPlayer *p)
      {
      	qDebug() << p->playlist()->currentIndex() << p->state() << p->mediaStatus() << p->currentMedia().canonicalUrl();
      	auto &&pl = p->playlist();
      	for (int i = 0; i < pl->mediaCount(); i++)
      		qDebug() << __PRETTY_FUNCTION__ << i << pl->media(i).canonicalUrl();
      }
      

      Reproducing takes some time, i.e. I have to put things in the queue, let it run empty and so on, but after ~2 minutes I get to break it usually. The WAV files used here play only for a few seconds.

      Attachments

        1. AudioQueue.cpp
          2 kB
        2. AudioQueue.h
          0.5 kB
        3. debug.diff
          2 kB
        4. gst.log.xz
          90 kB
        5. main.cpp
          1 kB
        6. sound
          165 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            rebemlix Rolf Eike Beer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes