Android: Release the surface texture when not in use

With some Android versions the preview texture is released when the
application is suspended. If we don't release the texture in our
code, the preview will be empty when the application resumes.

Task-number: QTBUG-38165

Change-Id: I72244727081d8f94ee5f6cb0ab660ca59f4bb2de
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Christian Strømme
2014-04-07 14:04:49 +02:00
committed by The Qt Project
parent 8a047ef087
commit b33e6d4672

View File

@@ -286,8 +286,10 @@ void QAndroidCameraSession::close()
void QAndroidCameraSession::setVideoPreview(QObject *videoOutput)
{
if (m_videoOutput)
if (m_videoOutput) {
m_videoOutput->stop();
m_videoOutput->reset();
}
if (videoOutput) {
connect(videoOutput, SIGNAL(readyChanged(bool)), this, SLOT(onVideoOutputReady(bool)));
@@ -368,8 +370,12 @@ void QAndroidCameraSession::stopPreview()
m_camera->stopPreview();
m_camera->setPreviewSize(QSize());
if (m_videoOutput)
m_camera->setPreviewTexture(0);
if (m_videoOutput) {
m_videoOutput->stop();
m_videoOutput->reset();
}
m_previewStarted = false;
}