FaceAccess/Record/EchoRecord.cpp

31 lines
869 B
C++
Raw Normal View History

2024-09-04 17:57:23 +08:00
#include "BoostLog.h"
#include "main.h"
#include <memory>
void EchoRecordTask::setVqeEnabled(bool enabled) {
if (m_vqeEnabled != enabled) {
m_vqeEnabled = enabled;
}
}
void EchoRecordTask::setChannels(int channels) {
if (m_channels != channels) {
m_channels = channels;
}
}
void EchoRecordTask::run() {
RkAudio::Format format;
format.channels = m_channels;
format.period = 64;
m_output = std::make_shared<RkAudio::Output>();
if (!m_output->open(sizeof(uint16_t), format.sampleRate, format.channels, format.period, m_vqeEnabled)) {
LOG(error) << "audio output open failed.";
return;
}
m_input = std::make_shared<RkAudio::Input>();
m_input->setDataCallback([this](const RkAudio::Frame &frame) { m_output->write(frame.data, frame.byteSize); });
m_input->open(format, m_vqeEnabled);
}