Revise CPulseAudioClient::finalize() to free all the resources which have been alread... 27/170927/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 15 Jan 2018 08:02:59 +0000 (17:02 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Fri, 23 Feb 2018 07:41:46 +0000 (16:41 +0900)
A failure can be happened during initialize(), we do not lean on the __mIsInit member variable
which is only set on the last stage of the initialize() function.

[Version] 0.5.1
[Issue Type] Bug Fix

Change-Id: I906365647ea08fd27e5c72562fb59f94c2b77b96
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-audio-io.spec
src/cpp/CPulseAudioClient.cpp

index 3af7e2a..3cfb628 100644 (file)
@@ -1,6 +1,6 @@
 Name:           capi-media-audio-io
 Summary:        An Audio Input & Audio Output library in Tizen Native API
-Version:        0.5.0
+Version:        0.5.1
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index bd123bb..288a02e 100644 (file)
@@ -446,22 +446,21 @@ void CPulseAudioClient::initialize() {
 
 void CPulseAudioClient::finalize() {
     AUDIO_IO_LOGD("");
-    if (__mIsInit == false) {
-        return;
-    }
 
-    if (isInThread() == false)
+    if (__mpMainloop && isInThread() == false)
         pa_threaded_mainloop_lock(__mpMainloop);
 
     /* clear callbacks */
-    if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK)
-        pa_stream_set_write_callback(__mpStream, NULL, NULL);
-    else
-        pa_stream_set_read_callback(__mpStream, NULL, NULL);
-    pa_stream_set_latency_update_callback(__mpStream, NULL, NULL);
-    pa_stream_set_event_callback(__mpStream, NULL, NULL);
-
-    if (isInThread() == false)
+    if (__mpStream) {
+        if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK)
+            pa_stream_set_write_callback(__mpStream, NULL, NULL);
+        else
+            pa_stream_set_read_callback(__mpStream, NULL, NULL);
+        pa_stream_set_latency_update_callback(__mpStream, NULL, NULL);
+        pa_stream_set_event_callback(__mpStream, NULL, NULL);
+    }
+
+    if (__mpMainloop && isInThread() == false)
         pa_threaded_mainloop_unlock(__mpMainloop);
 
     /* Wait for drain complete if draining before finalize */