Merge branch 'tizen' into tizen_line_coverage 90/199690/1 tizen_line_coverage
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 14 Feb 2019 05:27:38 +0000 (14:27 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 14 Feb 2019 05:30:09 +0000 (14:30 +0900)
Change-Id: I2f9d5cbdb39ab3552e1472c27272e5cedf804983

packaging/capi-media-audio-io.spec
src/cpp/CAudioInput.cpp
src/cpp/CAudioOutput.cpp
src/cpp/CPulseAudioClient.cpp
src/cpp/cpp_audio_io.cpp

index 59a599f..1d9ecbf 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.13
+Version:        0.5.15
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index c9f384c..0be4dda 100644 (file)
@@ -62,7 +62,7 @@ void CAudioInput::onStream(CPulseAudioClient* pClient, size_t length) {
      */
     if (__mIsUsedSyncRead == true) {
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-        AUDIO_IO_LOGD("Sync Read Mode! - pClient:[%p], length:[%d]", pClient, length);
+        AUDIO_IO_LOGD("Sync Read Mode! - pClient:[%p], length:[%zu]", pClient, length);
 #endif
         return;
     }
@@ -71,7 +71,7 @@ void CAudioInput::onStream(CPulseAudioClient* pClient, size_t length) {
      * Accrues callback function
      */
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-    AUDIO_IO_LOGD("pClient:[%p], length:[%d]", pClient, length);
+    AUDIO_IO_LOGD("pClient:[%p], length:[%zu]", pClient, length);
 #endif
     CAudioIO::onStream(pClient, length);
 }
@@ -138,6 +138,10 @@ void CAudioInput::prepare() {
         /* Init StreamSpec */
         AUDIO_IO_LOGD("Set Stream Spec : CPulseStreamSpec::STREAM_LATENCY_INPUT_DEFAULT");
         CPulseStreamSpec::EStreamLatency streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_INPUT_DEFAULT;
+        /* Override the default value by audio type */
+        if (audioType == CAudioInfo::EAudioType::AUDIO_IN_TYPE_VOIP)
+            streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_INPUT_VOIP;
+
         CPulseStreamSpec spec(streamSpec, mAudioInfo);
 
         internalLock();
index 996cdc5..fdf70f9 100644 (file)
@@ -58,7 +58,7 @@ void CAudioOutput::onStream(CPulseAudioClient* pClient, size_t length) {
      */
     if (__mIsUsedSyncWrite == true) {
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-        AUDIO_IO_LOGD("Sync Write Mode! - signal! - pClient:[%p], length:[%d]", pClient, length);
+        AUDIO_IO_LOGD("Sync Write Mode! - signal! - pClient:[%p], length:[%zu]", pClient, length);
 #endif
         internalSignal();
         return;
@@ -68,7 +68,7 @@ void CAudioOutput::onStream(CPulseAudioClient* pClient, size_t length) {
      * Accrues callback function
      */
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-    AUDIO_IO_LOGD("pClient:[%p], length:[%d]", pClient, length);
+    AUDIO_IO_LOGD("pClient:[%p], length:[%zu]", pClient, length);
 #endif
     CAudioIO::onStream(pClient, length);
 }
@@ -140,6 +140,10 @@ void CAudioOutput::prepare() {
             streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT_ASYNC;
         }
 #endif
+        /* Override the default value by audio type */
+        if (audioType == CAudioInfo::EAudioType::AUDIO_OUT_TYPE_VOIP)
+            streamSpec = CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_VOIP;
+
         CPulseStreamSpec spec(streamSpec, mAudioInfo);
 
         internalLock();
@@ -272,7 +276,7 @@ size_t CAudioOutput::write(const void* buffer, size_t length) {
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,
                                    "The written result is invalid ret:%d", ret);
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-        AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%d)", buffer, length);
+        AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%zu)", buffer, length);
 #endif
         return length;
     }
@@ -296,7 +300,7 @@ size_t CAudioOutput::write(const void* buffer, size_t length) {
 
             while ((l = mpPulseAudioClient->getWritableSize()) == 0) {
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-                AUDIO_IO_LOGD("writableSize is [%d].. wait", l);
+                AUDIO_IO_LOGD("writableSize is [%zu].. wait", l);
 #endif
                 internalWait();
             }
@@ -305,7 +309,7 @@ size_t CAudioOutput::write(const void* buffer, size_t length) {
                 l = lengthIter;
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-            AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%d)", buffer, l);
+            AUDIO_IO_LOGD("CPulseAudioClient->write(buffer:%p, length:%zu)", buffer, l);
 #endif
 
             int ret = mpPulseAudioClient->write(buffer, l);
index 32a6e85..4423dda 100644 (file)
@@ -186,12 +186,12 @@ void CPulseAudioClient::__streamPlaybackCb(pa_stream* s, size_t length, void* us
 
 #ifndef DISABLE_MOBILE_BACK_COMP
     if (pClient->__mIsInit == false) {
-        AUDIO_IO_LOGD("Occurred this listener when an out stream is on the way to create : Write dummy, length[%d]", length);
+        AUDIO_IO_LOGD("Occurred this listener when an out stream is on the way to create : Write dummy, length[%zu]", length);
         __dummy_write(s, length);
         return;
     }
     if (pClient->isCorked()) {
-        AUDIO_IO_LOGD("Occurred this listener when an out stream is CORKED : Write dummy, length[%d]", length);
+        AUDIO_IO_LOGD("Occurred this listener when an out stream is CORKED : Write dummy, length[%zu]", length);
         __dummy_write(s, length);
         return;
     }
@@ -204,7 +204,7 @@ void CPulseAudioClient::__streamPlaybackCb(pa_stream* s, size_t length, void* us
        then write dummy data to ensure the start */
     if (pClient->__mSpec.getStreamLatency() == CPulseStreamSpec::EStreamLatency::STREAM_LATENCY_OUTPUT_DEFAULT_ASYNC &&
         pClient->__mIsFirstStream) {
-        AUDIO_IO_LOGW("[async] Write dummy of length[%d] since not written in first callback during prepare", length);
+        AUDIO_IO_LOGW("[async] Write dummy of length[%zu] since not written in first callback during prepare", length);
         __dummy_write(s, length);
         pClient->__mIsFirstStream = false;
     }
@@ -553,7 +553,7 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
 
                 if (__mSyncReadLength <= 0) {
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-                    AUDIO_IO_LOGD("readLength(%d byte) is not valid. wait...", __mSyncReadLength);
+                    AUDIO_IO_LOGD("readLength(%zu byte) is not valid. wait...", __mSyncReadLength);
 #endif
                     pa_threaded_mainloop_wait(__mpMainloop);
                 } else if (__mpSyncReadDataPtr == NULL) {
@@ -575,7 +575,7 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
 
             // Copy partial pcm data on out parameter
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-            AUDIO_IO_LOGD("memcpy() that a peeked buffer[0x%x], index[%d], length[%d] on out buffer", (const uint8_t*)(__mpSyncReadDataPtr) + __mSyncReadIndex, __mSyncReadIndex, l);
+            AUDIO_IO_LOGD("memcpy() that a peeked buffer[%p], index[%zu], length[%zu] on out buffer", (const uint8_t*)(__mpSyncReadDataPtr) + __mSyncReadIndex, __mSyncReadIndex, l);
 #endif
             memcpy(buffer, (const uint8_t*)__mpSyncReadDataPtr + __mSyncReadIndex, l);
 
@@ -640,7 +640,7 @@ int CPulseAudioClient::peek(const void** buffer, size_t* length) {
     }
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-    AUDIO_IO_LOGD("buffer[%p], length[%d]", *buffer, *length);
+    AUDIO_IO_LOGD("buffer[%p], length[%zu]", *buffer, *length);
 #endif
 
     if (ret < 0) {
@@ -694,18 +694,24 @@ int CPulseAudioClient::write(const void* data, size_t length) {
     int ret = 0;
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-    AUDIO_IO_LOGD("data[%p], length[%d], First[%d]", data, length, __mIsFirstStream);
+    AUDIO_IO_LOGD("data[%p], length[%zu], First[%d]", data, length, __mIsFirstStream);
 #endif
-    if (pa_stream_is_corked(__mpStream)) {
-        AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
-        pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
-    }
 
     if (isInThread() == false) {
         pa_threaded_mainloop_lock(__mpMainloop);
+        if (pa_stream_is_corked(__mpStream)) {
+            AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
+            pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
+        }
+
         ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
         pa_threaded_mainloop_unlock(__mpMainloop);
     } else {
+        if (pa_stream_is_corked(__mpStream)) {
+            AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
+            pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
+        }
+
         if (__mIsFirstStream) {
             const pa_buffer_attr* attr = pa_stream_get_buffer_attr(__mpStream);
             uint32_t prebuf = attr->prebuf;
@@ -718,7 +724,7 @@ int CPulseAudioClient::write(const void* data, size_t length) {
                 delete [] dummy;
             }
             __mIsFirstStream = false;
-            AUDIO_IO_LOGW("FIRST STREAM CALLBACK : length[%d], prebuf[%d], dummy[%d]",
+            AUDIO_IO_LOGW("FIRST STREAM CALLBACK : length[%zu], prebuf[%d], dummy[%zu]",
                           length, prebuf, (length < prebuf) ? prebuf - length : 0);
         }
         ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
@@ -940,10 +946,10 @@ size_t CPulseAudioClient::getBufferSize() {
 
         if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
             ret = attr->tlength;
-            AUDIO_IO_LOGD("PLAYBACK buffer size[%d]", ret);
+            AUDIO_IO_LOGD("PLAYBACK buffer size[%zu]", ret);
         } else {
             ret = attr->fragsize;
-            AUDIO_IO_LOGD("RECORD buffer size[%d]", ret);
+            AUDIO_IO_LOGD("RECORD buffer size[%zu]", ret);
         }
     } catch (CAudioError& e) {
         if (isInThread() == false) {
index fe55652..3115fda 100644 (file)
@@ -571,7 +571,7 @@ int cpp_audio_in_read(audio_in_h input, void *buffer, unsigned int length) {
         size_t readn = inputHandle->read(buffer, static_cast<size_t>(length));
         ret = static_cast<int>(readn);
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-        AUDIO_IO_LOGD("readn:%d", readn);
+        AUDIO_IO_LOGD("readn:%zu", readn);
 #endif
     } catch (CAudioError& e) {
         AUDIO_IO_LOGE("%s", e.getErrorMsg());
@@ -1073,7 +1073,7 @@ int cpp_audio_out_write(audio_out_h output, void *buffer, unsigned int length) {
         size_t written = outputHandle->write(buffer, static_cast<size_t>(length));
         ret = static_cast<int>(written);
 #ifdef _AUDIO_IO_DEBUG_TIMING_
-        AUDIO_IO_LOGD("written:%d", written);
+        AUDIO_IO_LOGD("written:%zu", written);
 #endif
     } catch (CAudioError& e) {
         AUDIO_IO_LOGE("%s", e.getErrorMsg());