mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Remove all AudioBuffer code
This commit is contained in:
parent
77843b14cc
commit
28b1678a88
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
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();
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2014 by Project Tox <https://tox.im>
|
||||
|
||||
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 <QIODevice>
|
||||
#include <QByteArray>
|
||||
#include <QMutex>
|
||||
|
||||
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
|
1
core.cpp
1
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);});
|
||||
|
|
3
core.h
3
core.h
|
@ -17,8 +17,6 @@
|
|||
#ifndef CORE_HPP
|
||||
#define CORE_HPP
|
||||
|
||||
#include "audiobuffer.h"
|
||||
|
||||
#include <tox/tox.h>
|
||||
#include <tox/toxav.h>
|
||||
|
||||
|
@ -99,7 +97,6 @@ struct ToxFile
|
|||
struct ToxCall
|
||||
{
|
||||
public:
|
||||
AudioBuffer audioBuffer;
|
||||
QAudioInput* audioInput;
|
||||
QIODevice* audioInputDevice;
|
||||
ToxAvCSettings codecSettings;
|
||||
|
|
|
@ -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)
|
||||
|
|
2
qtox.pro
2
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 \
|
||||
|
|
Loading…
Reference in New Issue
Block a user