kopia lustrzana https://gitlab.com/eliggett/wfview
Switch back to using a timer.
rodzic
af2be44919
commit
2b588ffce0
|
@ -31,6 +31,12 @@ audioHandler::~audioHandler()
|
||||||
audioOutput = Q_NULLPTR;
|
audioOutput = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (audioTimer != Q_NULLPTR) {
|
||||||
|
audioTimer->stop();
|
||||||
|
delete audioTimer;
|
||||||
|
audioTimer = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (resampler != Q_NULLPTR) {
|
if (resampler != Q_NULLPTR) {
|
||||||
speex_resampler_destroy(resampler);
|
speex_resampler_destroy(resampler);
|
||||||
|
@ -127,6 +133,9 @@ bool audioHandler::init(audioSetup setupIn)
|
||||||
if (setup.isinput) {
|
if (setup.isinput) {
|
||||||
audioInput = new QAudioInput(setup.port, format, this);
|
audioInput = new QAudioInput(setup.port, format, this);
|
||||||
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Starting audio timer";
|
qDebug(logAudio()) << (setup.isinput ? "Input" : "Output") << "Starting audio timer";
|
||||||
|
audioTimer = new QTimer();
|
||||||
|
audioTimer->setTimerType(Qt::PreciseTimer);
|
||||||
|
connect(audioTimer, &QTimer::timeout, this, &audioHandler::getNextAudioChunk);
|
||||||
|
|
||||||
connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
|
connect(audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
|
||||||
}
|
}
|
||||||
|
@ -186,7 +195,8 @@ void audioHandler::start()
|
||||||
if (setup.isinput) {
|
if (setup.isinput) {
|
||||||
audioDevice = audioInput->start();
|
audioDevice = audioInput->start();
|
||||||
connect(audioInput, &QAudioInput::destroyed, audioDevice, &QIODevice::deleteLater, Qt::UniqueConnection);
|
connect(audioInput, &QAudioInput::destroyed, audioDevice, &QIODevice::deleteLater, Qt::UniqueConnection);
|
||||||
connect(audioDevice, &QIODevice::readyRead, this, &audioHandler::getNextAudioChunk);
|
//connect(audioDevice, &QIODevice::readyRead, this, &audioHandler::getNextAudioChunk);
|
||||||
|
audioTimer->start(setup.blockSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Buffer size must be set before audio is started.
|
// Buffer size must be set before audio is started.
|
||||||
|
|
|
@ -115,6 +115,7 @@ private:
|
||||||
QAudioOutput* audioOutput=Q_NULLPTR;
|
QAudioOutput* audioOutput=Q_NULLPTR;
|
||||||
QAudioInput* audioInput=Q_NULLPTR;
|
QAudioInput* audioInput=Q_NULLPTR;
|
||||||
QIODevice* audioDevice=Q_NULLPTR;
|
QIODevice* audioDevice=Q_NULLPTR;
|
||||||
|
QTimer* audioTimer = Q_NULLPTR;
|
||||||
QAudioFormat format;
|
QAudioFormat format;
|
||||||
QAudioDeviceInfo deviceInfo;
|
QAudioDeviceInfo deviceInfo;
|
||||||
SpeexResamplerState* resampler = Q_NULLPTR;
|
SpeexResamplerState* resampler = Q_NULLPTR;
|
||||||
|
|
Ładowanie…
Reference in New Issue