Fixes 'Large stack use' 30/263230/3 accepted/tizen/unified/20210830.182700 submit/tizen/20210830.113039
authorJaechul Lee <jcsing.lee@samsung.com>
Mon, 30 Aug 2021 02:29:13 +0000 (11:29 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 30 Aug 2021 06:10:42 +0000 (15:10 +0900)
[Version] 0.0.13
[Issue Type] Coverity

Change-Id: I29bef4c66a1f83caefccde31d2c02a13e2495c91
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
packaging/hal-api-audio.spec
testcase/audio_haltests.cpp

index 6335462bf060f37cc2d6ed0891bb11baa32dffa2..6366983f0d3f83e34957c9555999d81faf1763b7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       hal-api-audio
 Summary:    TIZEN Audio HAL
-Version:    0.0.12
+Version:    0.0.13
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 0392a60c9ed34a7074a387ee622e82a05413b0a0..e246dfa601850a0be3d7899aa524d52b61ddbdb7 100644 (file)
@@ -20,6 +20,7 @@
 #include <iostream>
 #include <fstream>
 #include <array>
+#include <vector>
 
 #include <unistd.h>
 #include <sys/types.h>
@@ -158,9 +159,10 @@ int32_t AudioHalTest::WritePcmFromFile(pcm_handle pcm_h)
        int32_t ret = AUDIO_RET_OK;
        uint32_t avail_frames = 0;
        int bytes_read;
-       char buffer[65536];
 
        const char res_path[] = "/usr/share/testcase/res/audio/test_16le_44100_2ch.raw";
+
+
 #ifdef USE_IFSTREAM
        ifstream fs;
        fs.open(res_path, fstream::in | fstream::binary);
@@ -178,6 +180,8 @@ int32_t AudioHalTest::WritePcmFromFile(pcm_handle pcm_h)
 
        cout << "start to play dtmf+noise sounds ( " << res_path << " ) for 5 sec. " << endl;
 
+       vector<char> buffer(65536);
+
        while (true) {
                ret = hal_audio_pcm_avail(m_h, pcm_h, &avail_frames);
                if (ret == AUDIO_ERR_INTERNAL)
@@ -189,15 +193,15 @@ int32_t AudioHalTest::WritePcmFromFile(pcm_handle pcm_h)
                }
 
 #ifdef USE_IFSTREAM
-               fs.read(buffer, FramesToBytes(avail_frames));
+               fs.read(buffer.data(), FramesToBytes(avail_frames));
                bytes_read = fs.gcount();
 #else
-               bytes_read = read(fd, buffer, FramesToBytes(avail_frames));
+               bytes_read = read(fd, buffer.data(), FramesToBytes(avail_frames));
 #endif
 
                cout << "avail frames : " << avail_frames << ", read_n : " << bytes_read << endl;
 
-               ret = hal_audio_pcm_write(m_h, pcm_h, buffer, BytesToFrames(bytes_read));
+               ret = hal_audio_pcm_write(m_h, pcm_h, buffer.data(), BytesToFrames(bytes_read));
                if (ret == AUDIO_ERR_INTERNAL)
                        break;
 
@@ -232,11 +236,12 @@ int32_t AudioHalTest::ReadPcmFromDevice(pcm_handle pcm_h)
 {
        int32_t ret = AUDIO_RET_OK;
        uint32_t avail_frames = 0;
-       char buffer[65536];
        int iter_left = 100;
 
        cout << "start to record for few seconds..." << endl;
 
+       vector<char> buffer(65536);
+
        do {
                ret = hal_audio_pcm_avail(m_h, pcm_h, &avail_frames);
                if (ret == AUDIO_ERR_INTERNAL)
@@ -247,7 +252,7 @@ int32_t AudioHalTest::ReadPcmFromDevice(pcm_handle pcm_h)
                        continue;
                }
 
-               ret = hal_audio_pcm_read(m_h, pcm_h, buffer, avail_frames);
+               ret = hal_audio_pcm_read(m_h, pcm_h, buffer.data(), avail_frames);
                if (ret == AUDIO_ERR_INTERNAL)
                        break;