Merge lp:~jhodapp/qtubuntu-camera/fix-1398861 into lp:qtubuntu-camera

Proposed by Jim Hodapp
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 124
Merged at revision: 126
Proposed branch: lp:~jhodapp/qtubuntu-camera/fix-1398861
Merge into: lp:qtubuntu-camera
Diff against target: 62 lines (+17/-4)
2 files modified
src/aalmediarecordercontrol.cpp (+10/-4)
src/audiocapture.cpp (+7/-0)
To merge this branch: bzr merge lp:~jhodapp/qtubuntu-camera/fix-1398861
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+243563@code.launchpad.net

Commit message

Make sure that Pulse stops reading the microphone stream when recording stops. Also make sure that the microphone reading worker thread stops cleanly on app termination.

Description of the change

Make sure that Pulse stops reading the microphone stream when recording stops. Also make sure that the microphone reading worker thread stops cleanly on app termination.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
123. By Jim Hodapp

Don't comment out updateAspectRatio in chooseOptimalSize()

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
124. By Jim Hodapp

Make sure we can still record more than one video by making sure we always have a valid m_workerThread instance.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

LGTM, works as expected.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/aalmediarecordercontrol.cpp'
--- src/aalmediarecordercontrol.cpp 2014-11-18 18:24:52 +0000
+++ src/aalmediarecordercontrol.cpp 2014-12-03 22:17:37 +0000
@@ -63,7 +63,7 @@
63 m_currentState(QMediaRecorder::StoppedState),63 m_currentState(QMediaRecorder::StoppedState),
64 m_currentStatus(QMediaRecorder::UnloadedStatus),64 m_currentStatus(QMediaRecorder::UnloadedStatus),
65 m_recordingTimer(0),65 m_recordingTimer(0),
66 m_workerThread(new QThread)66 m_workerThread(0)
67{67{
68}68}
6969
@@ -73,8 +73,6 @@
73AalMediaRecorderControl::~AalMediaRecorderControl()73AalMediaRecorderControl::~AalMediaRecorderControl()
74{74{
75 delete m_recordingTimer;75 delete m_recordingTimer;
76 m_workerThread->deleteLater();
77 m_audioCapture->deleteLater();
78 deleteRecorder();76 deleteRecorder();
79}77}
8078
@@ -170,6 +168,7 @@
170 m_mediaRecorder = android_media_new_recorder();168 m_mediaRecorder = android_media_new_recorder();
171169
172 m_audioCapture = new AudioCapture(m_mediaRecorder);170 m_audioCapture = new AudioCapture(m_mediaRecorder);
171 m_workerThread = new QThread;
173172
174 if (m_audioCapture == 0) {173 if (m_audioCapture == 0) {
175 qWarning() << "Unable to create new audio capture, audio recording won't function";174 qWarning() << "Unable to create new audio capture, audio recording won't function";
@@ -184,7 +183,14 @@
184183
185 // Finished signal is for when the workerThread is completed. Important to connect this so that184 // Finished signal is for when the workerThread is completed. Important to connect this so that
186 // resources are cleaned up in the proper order and not leaked185 // resources are cleaned up in the proper order and not leaked
187 ret = connect(m_workerThread, SIGNAL(finished()), m_audioCapture, SLOT(deleteLater()));186 ret = connect(m_audioCapture, SIGNAL(finished()), m_workerThread, SLOT(quit()));
187 if (!ret)
188 qWarning() << "Failed to connect quit() to the m_audioCapture finished signal";
189 ret = connect(m_audioCapture, SIGNAL(finished()), m_audioCapture, SLOT(deleteLater()));
190 if (!ret)
191 qWarning() << "Failed to connect deleteLater() to the m_audioCapture finished signal";
192 // Clean up the worker thread after we finish recording
193 ret = connect(m_workerThread, SIGNAL(finished()), m_workerThread, SLOT(deleteLater()));
188 if (!ret)194 if (!ret)
189 qWarning() << "Failed to connect deleteLater() to the m_workerThread finished signal";195 qWarning() << "Failed to connect deleteLater() to the m_workerThread finished signal";
190 // startWorkerThread signal comes from an Android layer callback that resides down in196 // startWorkerThread signal comes from an Android layer callback that resides down in
191197
=== modified file 'src/audiocapture.cpp'
--- src/audiocapture.cpp 2014-07-31 16:44:03 +0000
+++ src/audiocapture.cpp 2014-12-03 22:17:37 +0000
@@ -95,6 +95,13 @@
95 && bytesWritten == readSize95 && bytesWritten == readSize
96 && !m_flagExit);96 && !m_flagExit);
9797
98 // Make sure that Pulse stops reading the microphone when recording stops
99 if (m_paStream != NULL)
100 {
101 pa_simple_free(m_paStream);
102 m_paStream = NULL;
103 }
104
98 Q_EMIT finished();105 Q_EMIT finished();
99}106}
100107

Subscribers

People subscribed via source and target branches