2 Star 18 Fork 6

TKG/record_qt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
RecordManager.cpp 3.41 KB
一键复制 编辑 原始数据 按行查看 历史
sl 提交于 2020-02-28 17:02 . remove param
#include <QTimer>
#include <QThread>
#include <QDebug>
#include "common/LoopBuffer.h"
#include "AudioDataDispatcher.h"
#ifdef WIN32
#include "render/WinAudioRender.h"
#include "capture/win/WinMediaDevice.h"
#include "capture/win/WinSpeakerRecord.h"
#include "capture/win/WinMicRecord.h"
#else
#include "capture/mac/MacMicRecord.h"
#include "capture/mac/MacMediaDevice.h"
#include "capture/mac/MacMicRecord.h"
#endif
#include "RecordManager.h"
RecordManager::RecordManager(QObject *parent) : QObject(parent)
{
qDebug() << QThread::currentThread();
#ifdef WIN32
/* 此deviceid要求和spk一致 */
QThread *renderThread = new QThread;
WinAudioRender *render = new WinAudioRender(0);
render->moveToThread(renderThread);
renderThread->start();
QTimer *renderTimer = new QTimer;
renderTimer->setSingleShot(true);
connect(renderTimer,&QTimer::timeout,render,&WinAudioRender::run);
renderTimer->start();
QThread * speakerThread = new QThread;
WinSpeakerRecord *speakerThreadObj = new WinSpeakerRecord;
speakerThreadObj->moveToThread(speakerThread);
speakerThread->start();
QTimer *speakerTimer = new QTimer;
speakerTimer->setSingleShot(true);
QObject::connect(speakerTimer,&QTimer::timeout,speakerThreadObj,&WinSpeakerRecord::run);
QThread * micThread = new QThread;
WinMicRecord *micThreadObj = new WinMicRecord;
micThreadObj->moveToThread(micThread);
micThread->start();
QTimer *micTimer = new QTimer;
micTimer->setSingleShot(true);
QObject::connect(micTimer,&QTimer::timeout,micThreadObj,&WinMicRecord::run);
QThread *audioThread = new QThread;
AudioDataDispatcher *audioThreadObj = new AudioDataDispatcher;
audioThreadObj->moveToThread(audioThread);
audioThread->start();
QTimer *mp3Timer = new QTimer;
mp3Timer->setSingleShot(true);
QObject::connect(mp3Timer,&QTimer::timeout,audioThreadObj,&AudioDataDispatcher::run);
QObject::connect(micThreadObj,&WinMicRecord::audioData,audioThreadObj,&AudioDataDispatcher::acceptMicData);
QObject::connect(speakerThreadObj,&WinSpeakerRecord::audioData,audioThreadObj,&AudioDataDispatcher::acceptSpeakerData);
qDebug() << "main thread" << QThread::currentThreadId();
speakerTimer->start(0);
mp3Timer->start(0);
micTimer->start(0);
qDebug() << WinMediaDevice::getDeviceList(WinMediaDevice::MediaDeviceType_Input);
qDebug() << WinMediaDevice::getDeviceList(WinMediaDevice::MediaDeviceType_Output);
#else
qDebug() << MacMediaDevice::getDeviceList(MacMediaDevice::MediaDeviceType_Input);
qDebug() << MacMediaDevice::getDeviceList(MacMediaDevice::MediaDeviceType_Output);
QThread *micThread = new QThread;
MacAudio *record = new MacAudio;
record->setDeviceId("51");
record->moveToThread(micThread);
micThread->start();
QThread *audioThread = new QThread;
AudioDataDispatcher *audioThreadObj = new AudioDataDispatcher;
audioThreadObj->moveToThread(audioThread);
audioThread->start();
QTimer *micTimer = new QTimer;
micTimer->setSingleShot(true);
connect(micTimer,&QTimer::timeout,record,&MacAudio::run);
micTimer->start(0);
QTimer *mp3Timer = new QTimer;
mp3Timer->setSingleShot(true);
QObject::connect(mp3Timer,&QTimer::timeout,audioThreadObj,&AudioDataDispatcher::run);
connect(record,&MacAudio::GotAVFrame,audioThreadObj,&AudioDataDispatcher::acceptMacMicData);
mp3Timer->start();
#endif
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/slcode/record_qt.git
git@gitee.com:slcode/record_qt.git
slcode
record_qt
record_qt
master

搜索帮助