summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-05-05 09:32:39 +0200
committerAndy Shaw <andy.shaw@qt.io>2017-05-23 10:04:53 +0000
commit6e3d6bf8322efd609d3a3ed33c5101072176ed5a (patch)
treeec3242564f19905088235b5fd6843d9fb970f42b /src
parent247a3250b2d500e37f3ebe06dd51a04a2107055f (diff)
Emit the StoppedState change after the file has finished writing
Where possible, we should be emitting the stateChanged() signal to StoppedState when we know the file is no longer being written to. The finializing status can be used to indicate it is finishing and when it is actually finished then StoppedState should be used. Task-number: QTBUG-50588 Change-Id: Ie3ac1c5cd00a6a36978e72b5485622e3302054ce Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/multimedia/recording/qmediarecorder.cpp4
-rw-r--r--src/plugins/avfoundation/camera/avfmediarecordercontrol.mm10
-rw-r--r--src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm8
3 files changed, 16 insertions, 6 deletions
diff --git a/src/multimedia/recording/qmediarecorder.cpp b/src/multimedia/recording/qmediarecorder.cpp
index d3962b78..3bab3dad 100644
--- a/src/multimedia/recording/qmediarecorder.cpp
+++ b/src/multimedia/recording/qmediarecorder.cpp
@@ -909,6 +909,10 @@ void QMediaRecorder::stop()
\enum QMediaRecorder::State
\value StoppedState The recorder is not active.
+ If this is the state after recording then the actual created recording has
+ finished being written to the final location and is ready on all platforms
+ except on Android. On Android, due to platform limitations, there is no way
+ to be certain that the recording has finished writing to the final location.
\value RecordingState The recording is requested.
\value PausedState The recorder is paused.
*/
diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm
index 79bf2e93..02261027 100644
--- a/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm
+++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol.mm
@@ -306,14 +306,16 @@ void AVFMediaRecorderControl::setState(QMediaRecorder::State state)
} break;
case QMediaRecorder::StoppedState:
{
- m_state = QMediaRecorder::StoppedState;
+ m_lastStatus = QMediaRecorder::FinalizingStatus;
+ Q_EMIT statusChanged(m_lastStatus);
[m_movieOutput stopRecording];
unapplySettings();
}
}
updateStatus();
- Q_EMIT stateChanged(m_state);
+ if (state != m_state)
+ Q_EMIT stateChanged(m_state);
}
void AVFMediaRecorderControl::setMuted(bool muted)
@@ -341,6 +343,10 @@ void AVFMediaRecorderControl::handleRecordingStarted()
void AVFMediaRecorderControl::handleRecordingFinished()
{
m_recordingFinished = true;
+ if (m_state != QMediaRecorder::StoppedState) {
+ m_state = QMediaRecorder::StoppedState;
+ Q_EMIT stateChanged(m_state);
+ }
updateStatus();
}
diff --git a/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm b/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm
index 5f604e9a..d657dc17 100644
--- a/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm
+++ b/src/plugins/avfoundation/camera/avfmediarecordercontrol_ios.mm
@@ -340,7 +340,7 @@ void AVFMediaRecorderControlIOS::assetWriterFinished()
Q_ASSERT(cameraControl);
const QMediaRecorder::Status lastStatus = m_lastStatus;
-
+ const QMediaRecorder::State lastState = m_state;
if (cameraControl->captureMode() & QCamera::CaptureVideo)
m_lastStatus = QMediaRecorder::LoadedStatus;
else
@@ -350,9 +350,11 @@ void AVFMediaRecorderControlIOS::assetWriterFinished()
m_service->videoOutput()->resetCaptureDelegate();
[m_service->session()->captureSession() startRunning];
-
+ m_state = QMediaRecorder::StoppedState;
if (m_lastStatus != lastStatus)
Q_EMIT statusChanged(m_lastStatus);
+ if (m_state != lastState)
+ Q_EMIT stateChanged(m_state);
}
void AVFMediaRecorderControlIOS::captureModeChanged(QCamera::CaptureModes newMode)
@@ -403,10 +405,8 @@ void AVFMediaRecorderControlIOS::cameraStatusChanged(QCamera::Status newStatus)
void AVFMediaRecorderControlIOS::stopWriter()
{
if (m_lastStatus == QMediaRecorder::RecordingStatus) {
- m_state = QMediaRecorder::StoppedState;
m_lastStatus = QMediaRecorder::FinalizingStatus;
- Q_EMIT stateChanged(m_state);
Q_EMIT statusChanged(m_lastStatus);
[m_writer stop];