Revise dummy stream write function using anonymous vector objects 40/191640/7 accepted/tizen/unified/20200415.121418 submit/tizen/20200414.034149
authorSeungbae Shin <seungbae.shin@samsung.com>
Fri, 19 Oct 2018 11:00:28 +0000 (20:00 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Fri, 10 Apr 2020 10:54:13 +0000 (19:54 +0900)
In addition, remove explicit c++ mode flag

[Version] 0.5.27
[Issue Type] Revise

Change-Id: I81e4481e9030d1dda006947e9a36884ba0f6304a

CMakeLists.txt
packaging/capi-media-audio-io.spec
src/cpp/CPulseAudioClient.cpp

index 3026dc5..02254b4 100644 (file)
@@ -22,7 +22,7 @@ ENDFOREACH(flag)
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -fPIC -Wall -Werror -std=c++14")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -fPIC -Wall -Werror")
 SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
 
 IF("${ARCH}" STREQUAL "arm")
index 2fef947..f995fa6 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.26
+Version:        0.5.27
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index 5c434cf..9b05a55 100644 (file)
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <assert.h>
 #include <algorithm>
+#include <vector>
 
 #ifdef ENABLE_DPM
 #include <dpm/restriction.h>
@@ -160,14 +161,9 @@ void CPulseAudioClient::__streamCaptureCb(pa_stream* s, size_t length, void* use
     pClient->__mpListener->onStream(pClient, length);
 }
 
-#ifndef DISABLE_MOBILE_BACK_COMP
 static void __dummy_write(pa_stream* s, size_t length) {
-    char* dummy = new char[length];
-    memset(dummy, 0, length);
-    pa_stream_write(s, dummy, length, NULL, 0LL, PA_SEEK_RELATIVE);
-    delete [] dummy;
+    pa_stream_write(s, std::vector<char>(length).data(), length, NULL, 0LL, PA_SEEK_RELATIVE);
 }
-#endif
 
 void CPulseAudioClient::__streamPlaybackCb(pa_stream* s, size_t length, void* user_data) {
     assert(s);
@@ -689,12 +685,9 @@ int CPulseAudioClient::write(const void* data, size_t length) {
             uint32_t prebuf = attr->prebuf;
             // Compensate amount of prebuf in first stream callback when audio-io use prebuf(-1)
             // Because a stream will never start when an application wrote less than prebuf at first
-            if (length < prebuf) {
-                char* dummy = new char[prebuf - length];
-                memset(dummy, 0, prebuf - length);
-                pa_stream_write(__mpStream, dummy, prebuf - length, NULL, 0LL, PA_SEEK_RELATIVE);
-                delete [] dummy;
-            }
+            if (length < prebuf)
+                __dummy_write(__mpStream, prebuf - length);
+
             __mIsFirstStream = false;
             AUDIO_IO_LOGW("FIRST STREAM CALLBACK : length[%zu], prebuf[%d], dummy[%zu]",
                           length, prebuf, (length < prebuf) ? prebuf - length : 0);
@@ -1039,4 +1032,4 @@ void CPulseAudioClient::applyRecordVolume(double volume) {
             pa_threaded_mainloop_unlock(__mpMainloop);
         throw;
     }
-}
\ No newline at end of file
+}