diff --git a/audiobuffer.cpp b/audiobuffer.cpp deleted file mode 100644 index 9ca0960bb..000000000 --- a/audiobuffer.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2014 by Project Tox - - This file is part of qTox, a Qt-based graphical interface for Tox. - - This program is libre software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the COPYING file for more details. -*/ - -#include "audiobuffer.h" - -AudioBuffer::AudioBuffer() : - QIODevice(0) -{ - open(QIODevice::ReadWrite); -} - -AudioBuffer::~AudioBuffer() -{ - close(); -} - -qint64 AudioBuffer::readData(char *data, qint64 len) -{ - qint64 total; - bufferMutex.lock(); - try { - total = qMin((qint64)buffer.size(), len); - memcpy(data, buffer.constData(), total); - buffer = buffer.mid(total); - } - catch (...) - { - bufferMutex.unlock(); - return 0; - } - bufferMutex.unlock(); - return total; -} - -qint64 AudioBuffer::writeData(const char* data, qint64 len) -{ - bufferMutex.lock(); - try { - buffer.append(data, len); - } - catch (...) - { - bufferMutex.unlock(); - return 0; - } - bufferMutex.unlock(); - return len; -} - -qint64 AudioBuffer::bytesAvailable() const -{ - bufferMutex.lock(); - long long size = buffer.size() + QIODevice::bytesAvailable(); - bufferMutex.unlock(); - return size; -} - -qint64 AudioBuffer::bufferSize() const -{ - bufferMutex.lock(); - long long size = buffer.size(); - bufferMutex.unlock(); - return size; -} - -void AudioBuffer::clear() -{ - bufferMutex.lock(); - buffer.clear(); - bufferMutex.unlock(); -} diff --git a/audiobuffer.h b/audiobuffer.h deleted file mode 100644 index e94b70447..000000000 --- a/audiobuffer.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2014 by Project Tox - - This file is part of qTox, a Qt-based graphical interface for Tox. - - This program is libre software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the COPYING file for more details. -*/ - -#ifndef AUDIOBUFFER_H -#define AUDIOBUFFER_H - -#include -#include -#include - -class AudioBuffer : public QIODevice -{ - Q_OBJECT -public: - explicit AudioBuffer(); - ~AudioBuffer(); - - qint64 readData(char *data, qint64 maxlen); - qint64 writeData(const char *data, qint64 len); - qint64 bytesAvailable() const; - qint64 bufferSize() const; - void clear(); - -private: - QByteArray buffer; - mutable QMutex bufferMutex; -}; - -#endif // AUDIOBUFFER_H diff --git a/core.cpp b/core.cpp index 7ad6d0a3c..5c4b16537 100644 --- a/core.cpp +++ b/core.cpp @@ -60,7 +60,6 @@ Core::Core(Camera* cam, QThread *coreThread) : { calls[i].sendAudioTimer = new QTimer(); calls[i].sendVideoTimer = new QTimer(); - calls[i].audioBuffer.moveToThread(coreThread); calls[i].sendAudioTimer->moveToThread(coreThread); calls[i].sendVideoTimer->moveToThread(coreThread); connect(calls[i].sendVideoTimer, &QTimer::timeout, [this,i](){sendCallVideo(i);}); diff --git a/core.h b/core.h index 454be391e..3a44d8f3c 100644 --- a/core.h +++ b/core.h @@ -17,8 +17,6 @@ #ifndef CORE_HPP #define CORE_HPP -#include "audiobuffer.h" - #include #include @@ -99,7 +97,6 @@ struct ToxFile struct ToxCall { public: - AudioBuffer audioBuffer; QAudioInput* audioInput; QIODevice* audioInputDevice; ToxAvCSettings codecSettings; diff --git a/coreav.cpp b/coreav.cpp index 628442eaa..550383273 100644 --- a/coreav.cpp +++ b/coreav.cpp @@ -170,12 +170,9 @@ void Core::cleanupCall(int callId) calls[callId].sendAudioTimer->stop(); calls[callId].sendVideoTimer->stop(); if (calls[callId].audioInput != nullptr) - { calls[callId].audioInput->stop(); - } if (calls[callId].videoEnabled) Widget::getInstance()->getCamera()->unsuscribe(); - calls[callId].audioBuffer.clear(); } void Core::playCallAudio(ToxAv*, int32_t callId, int16_t *data, int samples, void *user_data) diff --git a/qtox.pro b/qtox.pro index fdc562a09..544a4d815 100644 --- a/qtox.pro +++ b/qtox.pro @@ -79,7 +79,6 @@ HEADERS += widget/form/addfriendform.h \ friendlist.h \ cdata.h \ cstring.h \ - audiobuffer.h \ widget/selfcamview.h \ widget/videosurface.h \ widget/camera.h \ @@ -117,7 +116,6 @@ SOURCES += \ settings.cpp \ cdata.cpp \ cstring.cpp \ - audiobuffer.cpp \ widget/selfcamview.cpp \ widget/videosurface.cpp \ widget/camera.cpp \