#include <iostream>
#include <fstream>
#include <array>
+#include <vector>
#include <unistd.h>
#include <sys/types.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);
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)
}
#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;
{
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)
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;