diff options
author | Yoann Lopes <yoann.lopes@digia.com> | 2014-03-13 16:28:57 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-17 13:48:38 +0100 |
commit | 8463aae9c0adba2a9d76db14d2e6938e1fed53fc (patch) | |
tree | 251f9e53802f0cb77b9c476f9a7f4c91d1fb2c18 /src | |
parent | cd0533166f29d8ad49ad9ebc35e040f66ab127eb (diff) | |
download | qtmultimedia-8463aae9c0adba2a9d76db14d2e6938e1fed53fc.tar.gz |
Android: restart camera viewfinder after a recorder error.
Change-Id: I33f083fda5c10cfb997a21100c0ec3d4a314aee0
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/android/src/mediacapture/qandroidcapturesession.cpp | 23 | ||||
-rw-r--r-- | src/plugins/android/src/mediacapture/qandroidcapturesession.h | 1 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp index 3e5c261a6..008ebc7d5 100644 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp +++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp @@ -225,13 +225,13 @@ bool QAndroidCaptureSession::start() if (!m_mediaRecorder->prepare()) { emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder.")); - setStatus(QMediaRecorder::UnloadedStatus); + restartViewfinder(); return false; } if (!m_mediaRecorder->start()) { emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder.")); - setStatus(QMediaRecorder::UnloadedStatus); + restartViewfinder(); return false; } @@ -258,17 +258,15 @@ void QAndroidCaptureSession::stop(bool error) updateDuration(); m_elapsedTime.invalidate(); - if (m_cameraSession) { - m_cameraSession->camera()->reconnect(); - // Viewport needs to be restarted - m_cameraSession->camera()->startPreview(); - m_cameraSession->setReadyForCapture(true); - } - m_mediaRecorder->release(); delete m_mediaRecorder; m_mediaRecorder = 0; + if (m_cameraSession) { + // Viewport needs to be restarted after recording + restartViewfinder(); + } + if (!error) { // if the media is saved into the standard media location, register it // with the Android media scanner so it appears immediately in apps @@ -426,6 +424,13 @@ void QAndroidCaptureSession::updateViewfinder() m_resolutionDirty = false; } +void QAndroidCaptureSession::restartViewfinder() +{ + m_cameraSession->camera()->reconnect(); + m_cameraSession->camera()->startPreview(); + m_cameraSession->setReadyForCapture(true); +} + void QAndroidCaptureSession::updateDuration() { if (m_elapsedTime.isValid()) diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.h b/src/plugins/android/src/mediacapture/qandroidcapturesession.h index fc8300d4a..32ca9d1ae 100644 --- a/src/plugins/android/src/mediacapture/qandroidcapturesession.h +++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.h @@ -144,6 +144,7 @@ private: void setStatus(QMediaRecorder::Status status); void updateViewfinder(); + void restartViewfinder(); JMediaRecorder *m_mediaRecorder; QAndroidCameraSession *m_cameraSession; |