summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@qt.io>2016-07-28 12:06:45 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-08-12 12:00:33 +0000
commitb69862eb2ac587d75580d80b293042e9fdb3bb1c (patch)
treec0b85bdfc00310df1d7e313d5aafb5ab6beb351e
parentcf439602fd6a9d2a62924087499cbd621fbf7585 (diff)
AVFoundation: fix mediaStatus and state changes
When both state and mediaStatus are updated at the same time, make sure both variables are updated before emitting the corresponding signals. Also, always emit mediaStatusChanged() signals before stateChanged() to make sure mediaStatus changes are not cancelled by some action resulting from a state change. Task-number: QTBUG-49578 Change-Id: I0caea8261120595227834dbac7fed286d125bcab Reviewed-by: Christian Stromme <christian.stromme@qt.io>
-rw-r--r--src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
index 53cdebd8..d3ec2ff9 100644
--- a/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
+++ b/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
@@ -458,15 +458,19 @@ void AVFMediaPlayerSession::setMedia(const QMediaContent &content, QIODevice *st
m_requestedPosition = -1;
Q_EMIT positionChanged(position());
- QMediaPlayer::MediaStatus oldMediaStatus = m_mediaStatus;
+ const QMediaPlayer::MediaStatus oldMediaStatus = m_mediaStatus;
+ const QMediaPlayer::State oldState = m_state;
if (content.isNull() || content.canonicalUrl().isEmpty()) {
m_mediaStatus = QMediaPlayer::NoMedia;
- if (m_state != QMediaPlayer::StoppedState)
- Q_EMIT stateChanged(m_state = QMediaPlayer::StoppedState);
+ m_state = QMediaPlayer::StoppedState;
if (m_mediaStatus != oldMediaStatus)
Q_EMIT mediaStatusChanged(m_mediaStatus);
+
+ if (m_state != oldState)
+ Q_EMIT stateChanged(m_state);
+
return;
} else {
@@ -777,14 +781,15 @@ void AVFMediaPlayerSession::processEOS()
#endif
Q_EMIT positionChanged(position());
m_mediaStatus = QMediaPlayer::EndOfMedia;
+ m_state = QMediaPlayer::StoppedState;
// At this point, frames should not be rendered anymore.
// Clear the output layer to make sure of that.
if (m_videoOutput)
m_videoOutput->setLayer(0);
- Q_EMIT stateChanged(m_state = QMediaPlayer::StoppedState);
Q_EMIT mediaStatusChanged(m_mediaStatus);
+ Q_EMIT stateChanged(m_state);
}
void AVFMediaPlayerSession::processLoadStateChange()
@@ -864,7 +869,11 @@ void AVFMediaPlayerSession::processMediaLoadError()
m_requestedPosition = -1;
Q_EMIT positionChanged(position());
}
+
+ m_mediaStatus = QMediaPlayer::InvalidMedia;
+ m_state = QMediaPlayer::StoppedState;
+
Q_EMIT error(QMediaPlayer::FormatError, tr("Failed to load media"));
- Q_EMIT mediaStatusChanged(m_mediaStatus = QMediaPlayer::InvalidMedia);
- Q_EMIT stateChanged(m_state = QMediaPlayer::StoppedState);
+ Q_EMIT mediaStatusChanged(m_mediaStatus);
+ Q_EMIT stateChanged(m_state);
}