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