AVFoundation: Fix broken requestControl logic

AVFMediaPlayerService::requestControl was returning the video output
control after the video output was created, and this could result in
unexpected behavior, as well as prematurely calling releaseControl on
the video output.  This should fix the "player" example on OS X.

Change-Id: Ie23b1176272a1f9daa5edeec856141ac52a450c7
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Andy Nichols
2012-11-20 12:48:09 +01:00
committed by The Qt Project
parent 78ce69d3dd
commit 748684b357

View File

@@ -84,18 +84,22 @@ QMediaControl *AVFMediaPlayerService::requestControl(const char *name)
if (qstrcmp(name, QMetaDataReaderControl_iid) == 0)
return m_playerMetaDataControl;
if (!m_videoOutput) {
if (qstrcmp(name, QVideoRendererControl_iid) == 0)
if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
if (!m_videoOutput)
m_videoOutput = new AVFVideoRendererControl(this);
#ifndef QT_NO_WIDGETS
if (qstrcmp(name, QVideoWidgetControl_iid) == 0)
m_videoOutput = new AVFVideoWidgetControl(this);
#endif
}
if (m_videoOutput) {
m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
return m_videoOutput;
}
#ifndef QT_NO_WIDGETS
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
if (!m_videoOutput)
m_videoOutput = new AVFVideoWidgetControl(this);
m_session->setVideoOutput(qobject_cast<AVFVideoOutput*>(m_videoOutput));
return m_videoOutput;
}
#endif
return 0;
}