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
1=== modified file 'src/aalmediarecordercontrol.cpp'
2--- src/aalmediarecordercontrol.cpp 2014-11-18 18:24:52 +0000
3+++ src/aalmediarecordercontrol.cpp 2014-12-03 22:17:37 +0000
4@@ -63,7 +63,7 @@
5 m_currentState(QMediaRecorder::StoppedState),
6 m_currentStatus(QMediaRecorder::UnloadedStatus),
7 m_recordingTimer(0),
8- m_workerThread(new QThread)
9+ m_workerThread(0)
10 {
11 }
12
13@@ -73,8 +73,6 @@
14 AalMediaRecorderControl::~AalMediaRecorderControl()
15 {
16 delete m_recordingTimer;
17- m_workerThread->deleteLater();
18- m_audioCapture->deleteLater();
19 deleteRecorder();
20 }
21
22@@ -170,6 +168,7 @@
23 m_mediaRecorder = android_media_new_recorder();
24
25 m_audioCapture = new AudioCapture(m_mediaRecorder);
26+ m_workerThread = new QThread;
27
28 if (m_audioCapture == 0) {
29 qWarning() << "Unable to create new audio capture, audio recording won't function";
30@@ -184,7 +183,14 @@
31
32 // Finished signal is for when the workerThread is completed. Important to connect this so that
33 // resources are cleaned up in the proper order and not leaked
34- ret = connect(m_workerThread, SIGNAL(finished()), m_audioCapture, SLOT(deleteLater()));
35+ ret = connect(m_audioCapture, SIGNAL(finished()), m_workerThread, SLOT(quit()));
36+ if (!ret)
37+ qWarning() << "Failed to connect quit() to the m_audioCapture finished signal";
38+ ret = connect(m_audioCapture, SIGNAL(finished()), m_audioCapture, SLOT(deleteLater()));
39+ if (!ret)
40+ qWarning() << "Failed to connect deleteLater() to the m_audioCapture finished signal";
41+ // Clean up the worker thread after we finish recording
42+ ret = connect(m_workerThread, SIGNAL(finished()), m_workerThread, SLOT(deleteLater()));
43 if (!ret)
44 qWarning() << "Failed to connect deleteLater() to the m_workerThread finished signal";
45 // startWorkerThread signal comes from an Android layer callback that resides down in
46
47=== modified file 'src/audiocapture.cpp'
48--- src/audiocapture.cpp 2014-07-31 16:44:03 +0000
49+++ src/audiocapture.cpp 2014-12-03 22:17:37 +0000
50@@ -95,6 +95,13 @@
51 && bytesWritten == readSize
52 && !m_flagExit);
53
54+ // Make sure that Pulse stops reading the microphone when recording stops
55+ if (m_paStream != NULL)
56+ {
57+ pa_simple_free(m_paStream);
58+ m_paStream = NULL;
59+ }
60+
61 Q_EMIT finished();
62 }
63

Subscribers

People subscribed via source and target branches