25 lines
813 B
C++
25 lines
813 B
C++
#include "BoostLog.h"
|
|
#include "DateTime.h"
|
|
#include "main.h"
|
|
#include <filesystem>
|
|
#include <sstream>
|
|
|
|
void RecorderTask::run() {
|
|
std::ostringstream oss;
|
|
oss << DumpPath << "/" << DateTime::currentDateTime().toString("%Y%m%d%H%M%S") << ".pcm";
|
|
auto filePath = oss.str();
|
|
m_ofs = std::make_shared<std::ofstream>(filePath, std::ofstream::binary);
|
|
|
|
RkAudio::Format format;
|
|
format.channels = 2;
|
|
format.period = 64;
|
|
m_input = std::make_shared<RkAudio::Input>();
|
|
m_input->setDataCallback(
|
|
[this](const RkAudio::Frame &frame) { m_ofs->write(reinterpret_cast<const char *>(frame.data), frame.byteSize); });
|
|
|
|
if (m_input->open(format, false)) {
|
|
LOG(info) << "open record succeed, path: " << filePath;
|
|
} else {
|
|
LOG(info) << "open record failed.";
|
|
}
|
|
} |