summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@theqtcompany.com>2015-04-27 16:24:18 +0200
committerChristian Stromme <christian.stromme@theqtcompany.com>2015-04-30 22:48:01 +0000
commit0559f645bbe928e9a54666356409fce444e80c57 (patch)
tree5281b51c865255ec52cbf9b81c7988ddb9e940d8 /src/plugins
parentd910b6d63ff0ca74b5af004a83c437fa4db190c0 (diff)
downloadqtmultimedia-0559f645bbe928e9a54666356409fce444e80c57.tar.gz
qtmultimedia-0559f645bbe928e9a54666356409fce444e80c57.tar.bz2
qtmultimedia-0559f645bbe928e9a54666356409fce444e80c57.zip
Android: Don't delete the media recorder object twice.
In QAndroidCaptureSession::stop() we call restartViewFinder() which eventually calls QAndroidCaptureSession::stop() again, but this time the media recorder object is already released. Task-number: QTBUG-45637 Change-Id: I943c423398a99d98ccda1063fc16e47cba470deb Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcapturesession.cpp28
-rw-r--r--src/plugins/android/src/mediacapture/qandroidcapturesession.h2
2 files changed, 13 insertions, 17 deletions
diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp
index ae6991a3..3e3b17c7 100644
--- a/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp
+++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.cpp
@@ -151,23 +151,19 @@ void QAndroidCaptureSession::setState(QMediaRecorder::State state)
stop();
break;
case QMediaRecorder::RecordingState:
- if (!start())
- return;
+ start();
break;
case QMediaRecorder::PausedState:
// Not supported by Android API
qWarning("QMediaRecorder::PausedState is not supported on Android");
- return;
+ break;
}
-
- m_state = state;
- emit stateChanged(m_state);
}
-bool QAndroidCaptureSession::start()
+void QAndroidCaptureSession::start()
{
if (m_state == QMediaRecorder::RecordingState || m_status != QMediaRecorder::LoadedStatus)
- return false;
+ return;
setStatus(QMediaRecorder::StartingStatus);
@@ -225,13 +221,13 @@ bool QAndroidCaptureSession::start()
if (!m_mediaRecorder->prepare()) {
emit error(QMediaRecorder::FormatError, QLatin1String("Unable to prepare the media recorder."));
restartViewfinder();
- return false;
+ return;
}
if (!m_mediaRecorder->start()) {
emit error(QMediaRecorder::FormatError, QLatin1String("Unable to start the media recorder."));
restartViewfinder();
- return false;
+ return;
}
m_elapsedTime.start();
@@ -241,22 +237,21 @@ bool QAndroidCaptureSession::start()
if (m_cameraSession)
m_cameraSession->setReadyForCapture(false);
- return true;
+ m_state = QMediaRecorder::RecordingState;
+ emit stateChanged(m_state);
}
void QAndroidCaptureSession::stop(bool error)
{
- if (m_state == QMediaRecorder::StoppedState)
+ if (m_state == QMediaRecorder::StoppedState || m_mediaRecorder == 0)
return;
setStatus(QMediaRecorder::FinalizingStatus);
m_mediaRecorder->stop();
-
m_notifyTimer.stop();
updateDuration();
m_elapsedTime.invalidate();
-
m_mediaRecorder->release();
delete m_mediaRecorder;
m_mediaRecorder = 0;
@@ -279,6 +274,9 @@ void QAndroidCaptureSession::stop(bool error)
m_actualOutputLocation = m_usedOutputLocation;
emit actualLocationChanged(m_actualOutputLocation);
}
+
+ m_state = QMediaRecorder::StoppedState;
+ emit stateChanged(m_state);
}
void QAndroidCaptureSession::setStatus(QMediaRecorder::Status status)
@@ -541,8 +539,6 @@ void QAndroidCaptureSession::onError(int what, int extra)
Q_UNUSED(what)
Q_UNUSED(extra)
stop(true);
- m_state = QMediaRecorder::StoppedState;
- emit stateChanged(m_state);
emit error(QMediaRecorder::ResourceError, QLatin1String("Unknown error."));
}
diff --git a/src/plugins/android/src/mediacapture/qandroidcapturesession.h b/src/plugins/android/src/mediacapture/qandroidcapturesession.h
index f96e9766..c17f081d 100644
--- a/src/plugins/android/src/mediacapture/qandroidcapturesession.h
+++ b/src/plugins/android/src/mediacapture/qandroidcapturesession.h
@@ -130,7 +130,7 @@ private:
CaptureProfile getProfile(int id);
- bool start();
+ void start();
void stop(bool error = false);
void setStatus(QMediaRecorder::Status status);