From badecdbc46df6ada383f1dfd006fa3dfff1706c6 Mon Sep 17 00:00:00 2001
From: James McDonnell <jmcdonnell@blackberry.com>
Date: Thu, 6 Apr 2017 16:40:23 -0400
Subject: [PATCH] Remove m_stopEventsToIgnore

6.6.0 and 7.0.0 mm-renderer don't appear to produce spurious stopped
state updates.  From the MMR_STOPPED in one of the comments, it looks
like this was a problem with the BlackBerry mm-renderer.

Change-Id: Ia336195b48df342c376b7fb3c8eb2a65ef748032
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
---
 .../mediaplayer/mmrenderermediaplayercontrol.cpp  | 15 ++-------------
 .../mediaplayer/mmrenderermediaplayercontrol.h    |  1 -
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
index ad84a8a7e..0350958de 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.cpp
@@ -71,7 +71,6 @@ MmRendererMediaPlayerControl::MmRendererMediaPlayerControl(QObject *parent)
       m_mediaStatus(QMediaPlayer::NoMedia),
       m_playAfterMediaLoaded(false),
       m_inputAttached(false),
-      m_stopEventsToIgnore(0),
       m_bufferLevel(0)
 {
     m_loadingTimer.setSingleShot(true);
@@ -114,11 +113,8 @@ void MmRendererMediaPlayerControl::handleMmStopped()
 {
     // Only react to stop events that happen when the end of the stream is reached and
     // playback is stopped because of this.
-    // Ignore other stop event sources, souch as calling mmr_stop() ourselves and
-    // mmr_input_attach().
-    if (m_stopEventsToIgnore > 0) {
-        --m_stopEventsToIgnore;
-    } else {
+    // Ignore other stop event sources, such as calling mmr_stop() ourselves.
+    if (m_state != QMediaPlayer::StoppedState) {
         setMediaStatus(QMediaPlayer::EndOfMedia);
         stopInternal(IgnoreMmRenderer);
     }
@@ -207,11 +203,6 @@ void MmRendererMediaPlayerControl::attach()
         return;
     }
 
-    // For whatever reason, the mmrenderer sends out a MMR_STOPPED event when calling
-    // mmr_input_attach() above. Ignore it, as otherwise we'll trigger stopping right after we
-    // started.
-    m_stopEventsToIgnore++;
-
     m_inputAttached = true;
     setMediaStatus(QMediaPlayer::LoadedMedia);
 
@@ -348,7 +339,6 @@ void MmRendererMediaPlayerControl::stopInternal(StopCommand stopCommand)
     if (m_state != QMediaPlayer::StoppedState) {
 
         if (stopCommand == StopMmRenderer) {
-            ++m_stopEventsToIgnore;
             mmr_stop(m_context);
         }
 
@@ -521,7 +511,6 @@ void MmRendererMediaPlayerControl::play()
         return;
     }
 
-    m_stopEventsToIgnore = 0;    // once playing, stop events must be proccessed
     setState( QMediaPlayer::PlayingState);
 }
 
diff --git a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
index 8815926fd..655570656 100644
--- a/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
+++ b/src/plugins/qnx/mediaplayer/mmrenderermediaplayercontrol.h
@@ -162,7 +162,6 @@ private:
     QMediaPlayer::MediaStatus m_mediaStatus;
     bool m_playAfterMediaLoaded;
     bool m_inputAttached;
-    int m_stopEventsToIgnore;
     int m_bufferLevel;
     QTimer m_loadingTimer;
 };
-- 
GitLab