Skip drain when stream is not started yet 24/181124/1 accepted/tizen/unified/20180612.044139 submit/tizen/20180611.055237
authorSeungbae Shin <seungbae.shin@samsung.com>
Fri, 8 Jun 2018 09:17:48 +0000 (18:17 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Fri, 8 Jun 2018 09:17:48 +0000 (18:17 +0900)
[Version] 0.5.8
[Issue Type] Bug Fix

Change-Id: I741348f3ed8fe082d6734dd91d8e79533af1c865

include/CPulseAudioClient.h
packaging/capi-media-audio-io.spec
src/cpp/CPulseAudioClient.cpp

index d68e02c..13b4a1a 100644 (file)
@@ -100,6 +100,7 @@ namespace tizen_media_audio {
         bool                  __mIsUsedSyncRead;
         bool                  __mIsFirstStream;
         bool                  __mIsDraining;
+        bool                  __mIsStarted;
 
         /* Static Methods */
 
index f154e90..18656f6 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.7
+Version:        0.5.8
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index 288a02e..a877c72 100644 (file)
@@ -52,7 +52,8 @@ CPulseAudioClient::CPulseAudioClient(
     __mSyncReadLength(0),
     __mIsUsedSyncRead(false),
     __mIsFirstStream(false),
-    __mIsDraining(false) {
+    __mIsDraining(false),
+    __mIsStarted(false) {
 }
 
 CPulseAudioClient::~CPulseAudioClient() {
@@ -223,6 +224,8 @@ void CPulseAudioClient::__streamStartedCb(pa_stream* s, void* user_data) {
     CPulseAudioClient* pClient = static_cast<CPulseAudioClient*>(user_data);
 
     AUDIO_IO_LOGD("stream %p started.", pClient);
+
+    pClient->__mIsStarted = true;
 }
 
 void CPulseAudioClient::__streamUnderflowCb(pa_stream* s, void* user_data) {
@@ -232,6 +235,8 @@ void CPulseAudioClient::__streamUnderflowCb(pa_stream* s, void* user_data) {
     CPulseAudioClient* pClient = static_cast<CPulseAudioClient*>(user_data);
 
     AUDIO_IO_LOGD("stream %p UnderFlow...", pClient);
+
+    pClient->__mIsStarted = false;
 }
 
 void CPulseAudioClient::__streamEventCb(pa_stream* s, const char *name, pa_proplist *pl, void *user_data) {
@@ -379,7 +384,7 @@ void CPulseAudioClient::initialize() {
         if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
             pa_stream_set_started_callback(__mpStream, __streamStartedCb, this);
             pa_stream_set_underflow_callback(__mpStream, __streamUnderflowCb, this);
-               }
+        }
 
         // Connect stream with PA Server
 
@@ -782,6 +787,11 @@ bool CPulseAudioClient::drain() {
         return true;
     }
 
+    if (!__mIsStarted) {
+        AUDIO_IO_LOGW("stream not started yet...skip drain");
+        return true;
+    }
+
     if (isInThread() == false) {
         AUDIO_IO_LOGD("drain");
         pa_threaded_mainloop_lock(__mpMainloop);
@@ -792,6 +802,7 @@ bool CPulseAudioClient::drain() {
         }
         pa_operation_unref(o);
         pa_threaded_mainloop_unlock(__mpMainloop);
+        AUDIO_IO_LOGD("drain done");
     } else {
         AUDIO_IO_LOGD("drain in thread");
         pa_operation_unref(pa_stream_drain(__mpStream, __successDrainCbInThread, this));