mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix some A/V bugs
This commit is contained in:
parent
58cfae38ab
commit
73e3afe932
19
core.cpp
19
core.cpp
|
@ -37,7 +37,6 @@ ToxCall Core::calls[TOXAV_MAX_CALLS];
|
|||
Core::Core(Camera* cam) :
|
||||
tox(nullptr), camera(cam)
|
||||
{
|
||||
qDebug() << "A NEW CORE HAS STARTED !";
|
||||
toxTimer = new QTimer(this);
|
||||
toxTimer->setSingleShot(true);
|
||||
saveTimer = new QTimer(this);
|
||||
|
@ -1185,22 +1184,26 @@ void Core::cleanupCall(int callId)
|
|||
{
|
||||
qDebug() << QString("Core: cleaning up call %1").arg(callId);
|
||||
calls[callId].active = false;
|
||||
disconnect(&calls[callId].playAudioTimer,0,0,0);
|
||||
disconnect(&calls[callId].sendAudioTimer,0,0,0);
|
||||
disconnect(&calls[callId].playVideoTimer,0,0,0);
|
||||
disconnect(&calls[callId].sendVideoTimer,0,0,0);
|
||||
calls[callId].playAudioTimer.stop();
|
||||
calls[callId].sendAudioTimer.stop();
|
||||
calls[callId].playVideoTimer.stop();
|
||||
calls[callId].sendVideoTimer.stop();
|
||||
if (calls[callId].audioOutput != nullptr)
|
||||
{
|
||||
delete calls[callId].audioOutput;
|
||||
calls[callId].audioOutput = nullptr;
|
||||
disconnect(&calls[callId].playAudioTimer,0,0,0);
|
||||
}
|
||||
if (calls[callId].audioInput != nullptr)
|
||||
{
|
||||
delete calls[callId].audioInput;
|
||||
calls[callId].audioInput = nullptr;
|
||||
disconnect(&calls[callId].sendAudioTimer,0,0,0);
|
||||
}
|
||||
if (calls[callId].videoEnabled)
|
||||
Widget::getInstance()->getCamera()->unsuscribe();
|
||||
disconnect(&calls[callId].playVideoTimer,0,0,0);
|
||||
disconnect(&calls[callId].sendVideoTimer,0,0,0);
|
||||
calls[callId].audioBuffer.clear();
|
||||
}
|
||||
|
||||
|
@ -1224,13 +1227,12 @@ void Core::playCallAudio(int callId, ToxAv* toxav)
|
|||
}
|
||||
if (len == 0)
|
||||
{
|
||||
if (calls[callId].audioBuffer.bufferSize() >= framesize*2)
|
||||
calls[callId].playAudioTimer.start();
|
||||
calls[callId].playAudioTimer.start();
|
||||
return;
|
||||
}
|
||||
//qDebug() << QString("Core: Received %1 bytes, %2 audio bytes free, %3 core buffer size")
|
||||
// .arg(len*2).arg(calls[callId].audioOutput->bytesFree()).arg(calls[callId].audioBuffer.bufferSize());
|
||||
calls[callId].audioBuffer.writeData((char*)buf, len*2);
|
||||
calls[callId].audioBuffer.write((char*)buf, len*2);
|
||||
int state = calls[callId].audioOutput->state();
|
||||
if (state != QAudio::ActiveState)
|
||||
{
|
||||
|
@ -1242,7 +1244,6 @@ void Core::playCallAudio(int callId, ToxAv* toxav)
|
|||
if (error != QAudio::NoError)
|
||||
qWarning() << QString("Core::playCallAudio: Error: %1").arg(error);
|
||||
|
||||
|
||||
calls[callId].playAudioTimer.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -177,10 +177,12 @@ QImage Camera::getLastImage()
|
|||
|
||||
vpx_image Camera::getLastVPXImage()
|
||||
{
|
||||
vpx_image img;
|
||||
if (!lastFrame.isValid())
|
||||
return img;
|
||||
lastFrame.map(QAbstractVideoBuffer::ReadOnly);
|
||||
int w = lastFrame.width(), h = lastFrame.height();
|
||||
int bpl = lastFrame.bytesPerLine();
|
||||
vpx_image img;
|
||||
vpx_img_alloc(&img, VPX_IMG_FMT_I420, w, h, 1); // I420 == YUV420P, same as YV12 with U and V switched
|
||||
|
||||
if (frameFormat == QVideoFrame::Format_YUV420P)
|
||||
|
|
Loading…
Reference in New Issue
Block a user