1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

CppCheck, some video perf improvements

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-01-29 21:23:33 +01:00 committed by Dubslow
parent 64bd3b7b47
commit c32eb98e6c
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
23 changed files with 64 additions and 48 deletions

View File

@ -1251,8 +1251,6 @@ bool Core::loadConfiguration(QString path)
// tox core is already decrypted
if (Settings::getInstance().getEnableLogging() && Settings::getInstance().getEncryptLogs())
{
bool error = true;
// get salt
QFile file(HistoryKeeper::getHistoryPath());
file.open(QIODevice::ReadOnly);
@ -1266,6 +1264,7 @@ bool Core::loadConfiguration(QString path)
}
else
{
bool error = true;
do
{
while (!pwsaltedkeys[ptHistory])

View File

@ -26,7 +26,7 @@
ToxCall Core::calls[TOXAV_MAX_CALLS];
#ifdef QTOX_FILTER_AUDIO
AudioFilterer * Core::filterer[TOXAV_MAX_CALLS] { nullptr};
AudioFilterer * Core::filterer[TOXAV_MAX_CALLS] {nullptr};
#endif
const int Core::videobufsize{TOXAV_MAX_VIDEO_WIDTH * TOXAV_MAX_VIDEO_HEIGHT * 4};
uint8_t* Core::videobuf;
@ -252,10 +252,11 @@ void Core::sendCallAudio(int callId, ToxAv* toxav)
const int framesize = (calls[callId].codecSettings.audio_frame_duration * calls[callId].codecSettings.audio_sample_rate) / 1000 * av_DefaultSettings.audio_channels;
const int bufsize = framesize * 2 * av_DefaultSettings.audio_channels;
uint8_t buf[bufsize], dest[bufsize];
uint8_t buf[bufsize];
if (Audio::tryCaptureSamples(buf, framesize))
{
uint8_t dest[bufsize];
int r;
if ((r = toxav_prepare_audio_frame(toxav, callId, dest, framesize*2, (int16_t*)buf, framesize)) < 0)
{
@ -625,9 +626,8 @@ void Core::sendGroupCallAudio(int groupId, ToxAv* toxav)
if (Audio::tryCaptureSamples(buf, framesize))
{
int r;
if ((r = toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf,
framesize, av_DefaultSettings.audio_channels, av_DefaultSettings.audio_sample_rate)) < 0)
if (toxav_group_send_audio(toxav_get_tox(toxav), groupId, (int16_t*)buf,
framesize, av_DefaultSettings.audio_channels, av_DefaultSettings.audio_sample_rate) < 0)
{
qDebug() << "Core: toxav_group_send_audio error";
groupCalls[groupId].sendAudioTimer->start();

View File

@ -23,6 +23,13 @@ bool ToxFile::open(bool write)
return write ? file->open(QIODevice::ReadWrite) : file->open(QIODevice::ReadOnly);
}
ToxID::ToxID(const ToxID& other)
{
publicKey = other.publicKey;
noSpam = other.noSpam;
checkSum = other.checkSum;
}
QString ToxID::toString() const
{
return publicKey + noSpam + checkSum;

View File

@ -16,6 +16,9 @@ enum class Status : int {Online = 0, Away, Busy, Offline};
struct ToxID
{
ToxID()=default;
ToxID(const ToxID& other);
QString publicKey;
QString noSpam;
QString checkSum;

View File

@ -23,12 +23,11 @@
#include "src/misc/settings.h"
Friend::Friend(int FriendId, const ToxID &UserId)
: friendId(FriendId)
: userName{Core::getInstance()->getPeerName(UserId)},
userID{UserId}, friendId{FriendId}
{
hasNewEvents = 0;
friendStatus = Status::Offline;
userID = UserId;
userName = Core::getInstance()->getPeerName(UserId);
if (userName.size() == 0)
userName = UserId.publicKey;

View File

@ -27,7 +27,9 @@ struct Friend
{
public:
Friend(int FriendId, const ToxID &UserId);
Friend(const Friend& other)=delete;
~Friend();
Friend& operator=(const Friend& other)=delete;
void setName(QString name);
void setAlias(QString name);

View File

@ -63,10 +63,10 @@ private:
void updateAliases();
QPair<int, ChatType> getChatID(const QString &id_str, ChatType ct);
int getAliasID(const QString &id_str);
QString wrapMessage(const QString &str);
QString unWrapMessage(const QString &str);
ChatType convertToChatType(int);
static QString wrapMessage(const QString &str);
static QString unWrapMessage(const QString &str);
static ChatType convertToChatType(int);
GenericDdInterface *db;
QMap<QString, int> aliases;

View File

@ -36,7 +36,7 @@ uint8_t* CData::data()
return cData;
}
uint16_t CData::size()
uint16_t CData::size() const
{
return cDataSize;
}

View File

@ -24,11 +24,13 @@ class CData
{
public:
uint8_t* data();
uint16_t size();
uint16_t size() const;
protected:
explicit CData(const QString& data, uint16_t byteSize);
CData(const CData& other)=delete;
virtual ~CData();
CData& operator=(const CData& other)=delete;
static QString toString(const uint8_t* cData, const uint16_t cDataSize);

View File

@ -46,7 +46,7 @@ uint8_t* CString::data()
return cString;
}
uint16_t CString::size()
uint16_t CString::size() const
{
return cStringSize;
}

View File

@ -31,7 +31,7 @@ public:
~CString();
uint8_t* data();
uint16_t size();
uint16_t size() const;
static QString toString(const uint8_t* cMessage, const uint16_t cMessageSize);
static uint16_t fromString(const QString& message, uint8_t* cMessage);

View File

@ -99,7 +99,7 @@ double Camera::getProp(Camera::Prop prop)
return worker->getProp(int(prop));
}
void Camera::onNewFrameAvailable(const VideoFrame frame)
void Camera::onNewFrameAvailable(const VideoFrame &frame)
{
emit frameAvailable(frame);

View File

@ -79,7 +79,7 @@ private:
CameraWorker* worker;
private slots:
void onNewFrameAvailable(const VideoFrame frame);
void onNewFrameAvailable(const VideoFrame& frame);
};

View File

@ -29,6 +29,12 @@ CameraWorker::CameraWorker(int index)
qRegisterMetaType<QList<QSize>>();
}
CameraWorker::~CameraWorker()
{
if (clock)
delete clock;
}
void CameraWorker::onStart()
{
clock = new QTimer(this);

View File

@ -34,6 +34,7 @@ class CameraWorker : public QObject
Q_OBJECT
public:
CameraWorker(int index);
~CameraWorker();
void doWork();
void suspend();
@ -48,7 +49,7 @@ public slots:
signals:
void started();
void newFrameAvailable(const VideoFrame frame);
void newFrameAvailable(const VideoFrame& frame);
void resProbingFinished(QList<QSize> res);
void propProbingFinished(int prop, double val);

View File

@ -19,7 +19,7 @@
#include "videosource.h"
class vpx_image;
struct vpx_image;
class NetVideoSource : public VideoSource
{

View File

@ -32,7 +32,7 @@ public:
virtual void unsubscribe() = 0;
signals:
void frameAvailable(const VideoFrame frame);
void frameAvailable(const VideoFrame& frame);
};

View File

@ -28,7 +28,8 @@
const QString TabCompleter::nickSuffix = QString(": ");
TabCompleter::TabCompleter(ChatTextEdit* msgEdit, Group* group)
: QObject(msgEdit), msgEdit(msgEdit), group(group), enabled(false)
: QObject{msgEdit}, msgEdit{msgEdit}, group{group},
enabled{false}, lastCompletionLength{0}
{
}

View File

@ -40,7 +40,7 @@ public slots:
private:
struct SortableString {
inline SortableString(const QString &n) { contents = n; }
inline SortableString(const QString &n) : contents{n} {}
bool operator<(const SortableString &other) const;
QString contents;
};

View File

@ -99,16 +99,9 @@ void GroupWidget::updateStatusLight()
Group *g = GroupList::findGroup(groupId);
if (!g->getEventFlag())
{
statusPic.setPixmap(QPixmap(":img/status/dot_online.png"));
}
else
{
if (!g->getMentionedFlag())
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
else
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
}
statusPic.setPixmap(QPixmap(":img/status/dot_online_notification.png"));
}
void GroupWidget::setChatForm(Ui::MainWindow &ui)

View File

@ -29,7 +29,8 @@ class ChatAction : public QObject
{
Q_OBJECT
public:
ChatAction(const bool &me, const QString &author, const QString &date) : isMe(me), name(author), date(date) {;}
ChatAction(const bool &me, const QString &author, const QString &date)
: isMe{me}, name{author}, date{date}, textTable{nullptr}, textEdit{nullptr} {;}
virtual ~ChatAction(){;}
void assignPlace(QTextTable *position, QTextEdit* te);

View File

@ -23,12 +23,14 @@
VideoSurface::VideoSurface(QWidget* parent)
: QGLWidget(QGLFormat(QGL::SingleBuffer), parent)
, source(nullptr)
, source{nullptr}
, pbo{nullptr, nullptr}
, textureId(0)
, pboAllocSize(0)
, hasSubscribed(false)
, pboIndex(0)
, bgrProgramm{nullptr}
, yuvProgramm{nullptr}
, textureId{0}
, pboAllocSize{0}
, hasSubscribed{false}
, pboIndex{0}
{
}
@ -180,14 +182,6 @@ void VideoSurface::paintGL()
pbo[nextPboIndex]->release();
}
// render pbo
static float values[] = {
-1, -1,
1, -1,
-1, 1,
1, 1
};
// background
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
@ -220,6 +214,14 @@ void VideoSurface::paintGL()
if (programm)
{
// render pbo
static float values[] = {
-1, -1,
1, -1,
-1, 1,
1, 1
};
programm->bind();
programm->setAttributeArray(0, GL_FLOAT, values, 2);
programm->enableAttributeArray(0);
@ -259,7 +261,7 @@ void VideoSurface::unsubscribe()
}
}
void VideoSurface::onNewFrameAvailable(const VideoFrame newFrame)
void VideoSurface::onNewFrameAvailable(const VideoFrame& newFrame)
{
mutex.lock();
frame = newFrame;

View File

@ -44,7 +44,7 @@ protected:
void unsubscribe();
private slots:
void onNewFrameAvailable(const VideoFrame newFrame);
void onNewFrameAvailable(const VideoFrame &newFrame);
private:
VideoSource* source;