mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Add unicode font, fix mem corruption
Or at least, make the memory corruption so hard to reproduce that I wasn't able to run into it even after trying really hard.
This commit is contained in:
parent
a63da505ec
commit
2efe9ac269
|
@ -20,7 +20,7 @@
|
|||
|
||||
CData::CData(const QString &data, uint16_t byteSize)
|
||||
{
|
||||
cData = new uint8_t[byteSize];
|
||||
cData = new uint8_t[byteSize+1];
|
||||
cDataSize = fromString(data, cData);
|
||||
}
|
||||
|
||||
|
|
27
core.cpp
27
core.cpp
|
@ -1116,8 +1116,13 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled
|
|||
|
||||
// Go
|
||||
/// BUG: TODO: Memory corryption and crashes atexit when playCallAudio is threaded
|
||||
if (calls[callId].audioOutput != nullptr)
|
||||
calls[callId].playFuture = QtConcurrent::run(playCallAudio, callId, toxav);
|
||||
//if (calls[callId].audioOutput != nullptr)
|
||||
// calls[callId].playFuture = QtConcurrent::run(playCallAudio, callId, toxav);
|
||||
|
||||
calls[callId].playAudioTimer.setInterval(5);
|
||||
calls[callId].playAudioTimer.setSingleShot(true);
|
||||
connect(&calls[callId].playAudioTimer, &QTimer::timeout, [=](){playCallAudio(callId,toxav);});
|
||||
calls[callId].playAudioTimer.start();
|
||||
if (calls[callId].audioInput != nullptr)
|
||||
calls[callId].recordFuture = QtConcurrent::run(sendCallAudio, callId, toxav);
|
||||
calls[callId].active = true;
|
||||
|
@ -1138,8 +1143,8 @@ void Core::cleanupCall(int callId)
|
|||
|
||||
void Core::playCallAudio(int callId, ToxAv* toxav)
|
||||
{
|
||||
while (calls[callId].active)
|
||||
{
|
||||
if (!calls[callId].active)
|
||||
return;
|
||||
int framesize = (calls[callId].codecSettings.audio_frame_duration * calls[callId].codecSettings.audio_sample_rate) / 1000;
|
||||
uint8_t buf[framesize*2];
|
||||
int len = toxav_recv_audio(toxav, callId, framesize, (int16_t*)buf);
|
||||
|
@ -1151,13 +1156,13 @@ void Core::playCallAudio(int callId, ToxAv* toxav)
|
|||
return;
|
||||
}
|
||||
qDebug() << QString("Core::playCallAudio: Error receiving audio: %1").arg(len);
|
||||
QThread::msleep(5);
|
||||
continue;
|
||||
calls[callId].playAudioTimer.start();
|
||||
return;
|
||||
}
|
||||
if (len == 0)
|
||||
{
|
||||
QThread::msleep(5); /// BUG: Another thread crashed with corruption while we slept here
|
||||
continue;
|
||||
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());
|
||||
|
@ -1166,15 +1171,15 @@ void Core::playCallAudio(int callId, ToxAv* toxav)
|
|||
if (state != QAudio::ActiveState)
|
||||
{
|
||||
qDebug() << QString("Core: Audio state is %1").arg(state);
|
||||
if (state == 3)
|
||||
if (state == 3 && calls[callId].audioBuffer.bytesAvailable() >= framesize*2)
|
||||
calls[callId].audioOutput->start(&calls[callId].audioBuffer);
|
||||
}
|
||||
int error = calls[callId].audioOutput->error();
|
||||
if (error != QAudio::NoError)
|
||||
qWarning() << QString("Core::playCallAudio: Error: %1").arg(error);
|
||||
|
||||
QThread::msleep(5);
|
||||
}
|
||||
|
||||
calls[callId].playAudioTimer.start();
|
||||
}
|
||||
|
||||
void Core::sendCallAudio(int callId, ToxAv* toxav)
|
||||
|
|
1
core.h
1
core.h
|
@ -93,6 +93,7 @@ public:
|
|||
QAudioInput* audioInput;
|
||||
QIODevice* audioInputDevice;
|
||||
ToxAvCodecSettings codecSettings;
|
||||
QTimer playAudioTimer, sendAudioTimer;
|
||||
int callId;
|
||||
int friendId;
|
||||
bool videoEnabled;
|
||||
|
|
5
main.cpp
5
main.cpp
|
@ -1,11 +1,16 @@
|
|||
#include "widget/widget.h"
|
||||
#include <QApplication>
|
||||
#include <QFontDatabase>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
a.setApplicationName("Toxgui");
|
||||
a.setOrganizationName("Tox");
|
||||
|
||||
// install Unicode 6.1 supporting font
|
||||
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
||||
|
||||
Widget* w = Widget::getInstance();
|
||||
w->show();
|
||||
|
||||
|
|
3
res.qrc
3
res.qrc
|
@ -2,4 +2,7 @@
|
|||
<qresource prefix="/conf">
|
||||
<file alias="settings.ini">res/settings.ini</file>
|
||||
</qresource>
|
||||
<qresource prefix="/font">
|
||||
<file alias="DejaVuSans.ttf">res/DejaVuSans.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
res/DejaVuSans.ttf
Normal file
BIN
res/DejaVuSans.ttf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user