summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-10-25 15:07:02 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 20:26:24 +0100
commit30cf028fb158f08bc01357476f73426c43c35b4e (patch)
tree739ded1e10dda1d91d7cb6e6246a048e84552202 /src
parentacbd998749db4c09801647b21fcb081937160e3a (diff)
Android: fix camera preview showing black frames after restarting it.
Clear the camera preview size when stopping the preview in order to force it to be reset when starting it again. Task-number: QTBUG-34346 Change-Id: I0edf8d996348745b9aa7cf0790c16b6cd813b33b Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp4
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcamerasession.cpp6
-rw-r--r--src/plugins/android/src/wrappers/jcamera.cpp6
3 files changed, 13 insertions, 3 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp b/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp
index 899a3a499..345a29174 100644
--- a/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcamerafocuscontrol.cpp
@@ -238,6 +238,10 @@ void QAndroidCameraFocusControl::updateFocusZones(QCameraFocusZone::FocusZoneSta
return;
QSize viewportSize = m_session->camera()->previewSize();
+
+ if (!viewportSize.isValid())
+ return;
+
QSizeF focusSize(50.f / viewportSize.width(), 50.f / viewportSize.height());
float x = qBound(qreal(0),
m_actualFocusPoint.x() - (focusSize.width() / 2),
diff --git a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
index 75b0c5e9b..075fe78e5 100644
--- a/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcamerasession.cpp
@@ -205,8 +205,11 @@ void QAndroidCameraSession::adjustViewfinderSize(const QSize &captureSize, bool
QSize viewfinderResolution = m_camera->previewSize();
const qreal aspectRatio = qreal(captureSize.width()) / qreal(captureSize.height());
- if (qFuzzyCompare(aspectRatio, qreal(viewfinderResolution.width()) / qreal(viewfinderResolution.height())))
+ if (viewfinderResolution.isValid() &&
+ qFuzzyCompare(aspectRatio,
+ qreal(viewfinderResolution.width()) / viewfinderResolution.height())) {
return;
+ }
QList<QSize> previewSizes = m_camera->getSupportedPreviewSizes();
for (int i = previewSizes.count() - 1; i >= 0; --i) {
@@ -270,6 +273,7 @@ void QAndroidCameraSession::stopPreview()
JMultimediaUtils::enableOrientationListener(false);
m_camera->stopPreview();
+ m_camera->setPreviewSize(QSize());
if (m_videoOutput)
m_videoOutput->stop();
m_previewStarted = false;
diff --git a/src/plugins/android/src/wrappers/jcamera.cpp b/src/plugins/android/src/wrappers/jcamera.cpp
index f858f4702..fc9b18068 100644
--- a/src/plugins/android/src/wrappers/jcamera.cpp
+++ b/src/plugins/android/src/wrappers/jcamera.cpp
@@ -261,8 +261,10 @@ void JCamera::setPreviewSize(const QSize &size)
m_previewSize = size;
- m_parameters.callMethod<void>("setPreviewSize", "(II)V", size.width(), size.height());
- applyParameters();
+ if (m_previewSize.isValid()) {
+ m_parameters.callMethod<void>("setPreviewSize", "(II)V", size.width(), size.height());
+ applyParameters();
+ }
emit previewSizeChanged();
}