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

refactor(filter_audio): completely remove filter_audio dependency

The filter_audio API is not working for qTox/Tox and thus disabled by default via compiler switch. In current qTox UI, it is not configurable, even when this switch is enabled. According to issue #3194 the library is no longer maintained as well. I don't see any reason to keep it in qTox.
This commit is contained in:
Nils Fenner 2016-06-04 22:12:27 +02:00
parent a77afca1ec
commit 792103f8b0
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C
17 changed files with 5 additions and 368 deletions

View File

@ -60,12 +60,6 @@ cd ffmpeg*
make -j$(nproc)
make install
cd ../../
# filter_audio
git clone https://github.com/irungentoo/filter_audio
cd filter_audio
make -j$(nproc)
sudo make install
cd ..
# libsodium
git clone git://github.com/jedisct1/libsodium.git
cd libsodium
@ -96,6 +90,6 @@ make -j10
# clean it up, and build normal version
make clean
echo '*** BUILDING "FULL" VERSION ***'
qmake qtox.pro QMAKE_CC="$CC" QMAKE_CXX="$CXX" DISABLE_FILTER_AUDIO=NO
qmake qtox.pro QMAKE_CC="$CC" QMAKE_CXX="$CXX"
# ↓ with $(nproc) fails, since travis gives 32 threads, and it leads to OOM
make -j10

View File

@ -29,7 +29,6 @@
- [openSUSE](#opensuse-toxcore)
- [Slackware](#slackware-toxcore)
- [Ubuntu >=15.04](#ubuntu-toxcore)
- [filter_audio](#filter_audio)
- [sqlcipher](#sqlcipher)
- [Compile toxcore](#compile-toxcore)
- [Compile qTox](#compile-qtox)
@ -46,7 +45,6 @@
| toxcore | most recent | core, av |
| FFmpeg | >= 2.6.0 | avformat, avdevice, avcodec, avutil, swscale |
| OpenAL Soft | >= 1.16.0 | |
| filter_audio | most recent | |
| qrencode | >= 3.0.3 | |
| sqlcipher | >= 3.2.0 | |
| libXScrnSaver | >= 1.2 | |
@ -298,28 +296,6 @@ libopus-dev libvpx-dev libsodium-dev
```
### filter_audio
This step is best done before compiling toxcore.
Now you can either follow the instructions at
https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#unix or use the
[`bootstrap.sh`](/bootstrap.sh) script. The script will automatically download
and install `toxcore` and `libfilteraudio`:
```bash
## in qTox directory
./bootstrap.sh # use -h or --help for more information
```
If you've used script, you can skip directly to [compiling qTox](#compile-qtox).
If you want to compile and install it manually:
```bash
git clone https://github.com/irungentoo/filter_audio
cd filter_audio
make -j$(nproc)
sudo make install
```
### sqlcipher
If you are not using Fedora, skip this section, and go directly to compiling
@ -459,15 +435,6 @@ brew install git ffmpeg qrencode libtool automake autoconf check qt5 libvpx \
opus sqlcipher libsodium
```
Next, install [filter_audio](https://github.com/irungentoo/filter_audio) (you
may delete the directory it creates afterwards):
```bash
git clone https://github.com/irungentoo/filter_audio.git
cd filter_audio
sudo make install
cd ../
```
Next, install
[toxcore](https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#osx)

View File

@ -39,12 +39,10 @@ BASE_DIR=${SCRIPT_DIR}/${INSTALL_DIR}
# directory names of cloned repositories
TOX_CORE_DIR=libtoxcore-latest
FILTER_AUDIO_DIR=libfilteraudio-latest
SQLCIPHER_DIR=sqlcipher-stable
# default values for user given parameters
INSTALL_TOX=true
INSTALL_FILTER_AUDIO=true
INSTALL_SQLCIPHER=false
SYSTEM_WIDE=true
KEEP_BUILD_FILES=false
@ -63,12 +61,6 @@ while [ $# -ge 1 ] ; do
elif [ ${1} = "--without-tox" ] ; then
INSTALL_TOX=false
shift
elif [ ${1} = "--with-filter-audio" ] ; then
INSTALL_FILTER_AUDIO=true
shift
elif [ ${1} = "--without-filter-audio" ] ; then
INSTALL_FILTER_AUDIO=false
shift
elif [ ${1} = "--with-sqlcipher" ] ; then
INSTALL_SQLCIPHER=true
shift
@ -88,7 +80,7 @@ while [ $# -ge 1 ] ; do
fi
# print help
echo "Use this script to install/update libtoxcore and libfilteraudio"
echo "Use this script to install/update libtoxcore"
echo ""
echo "usage:"
echo " ${0} PARAMETERS"
@ -96,8 +88,6 @@ while [ $# -ge 1 ] ; do
echo "parameters:"
echo " --with-tox : install/update libtoxcore"
echo " --without-tox : do not install/update libtoxcore"
echo " --with-filter-audio : install/update libfilteraudio"
echo " --without-filter-audio : do not install/update libfilteraudio"
echo " --with-sqlcipher : install/update sqlcipher"
echo " --without-sqlcipher : do not install/update sqlcipher"
echo " -h|--help : displays this help"
@ -105,7 +95,7 @@ while [ $# -ge 1 ] ; do
echo " -k|--keep : keep build files after installation/update"
echo ""
echo "example usages:"
echo " ${0} -- install libtoxcore and libfilteraudio"
echo " ${0} -- install libtoxcore"
exit 1
fi
done
@ -113,7 +103,6 @@ done
############ print debug output ############
echo "with tox : ${INSTALL_TOX}"
echo "with filter-audio : ${INSTALL_FILTER_AUDIO}"
echo "with sqlcipher : ${INSTALL_SQLCIPHER}"
echo "install system-wide : ${SYSTEM_WIDE}"
echo "keep build files : ${KEEP_BUILD_FILES}"
@ -127,7 +116,6 @@ mkdir -p ${BASE_DIR}
# remove not needed dirs
remove_build_dirs() {
rm -rf ${BASE_DIR}/${TOX_CORE_DIR}
rm -rf ${BASE_DIR}/${FILTER_AUDIO_DIR}
rm -rf ${BASE_DIR}/${SQLCIPHER_DIR}
}
@ -176,24 +164,6 @@ if [[ $INSTALL_TOX = "true" ]]; then
popd
fi
#install libfilteraudio
if [[ $INSTALL_FILTER_AUDIO = "true" ]]; then
git clone https://github.com/irungentoo/filter_audio.git \
${BASE_DIR}/${FILTER_AUDIO_DIR} --depth 1
pushd ${BASE_DIR}/${FILTER_AUDIO_DIR}
if [[ $SYSTEM_WIDE = "false" ]]; then
PREFIX=${BASE_DIR} make -j$(nproc)
PREFIX=${BASE_DIR} make install
else
make -j$(nproc)
sudo make install
sudo ldconfig
fi
popd
fi
#install sqlcipher
if [[ $INSTALL_SQLCIPHER = "true" ]]; then

View File

@ -39,7 +39,6 @@ MACDEPLOYQT="${QT_DIR_VER}/bin/macdeployqt" # Don't change
TOXCORE_DIR="${MAIN_DIR}/toxcore" # Change to Git location
FA_DIR="${MAIN_DIR}/filter_audio"
LIB_INSTALL_PREFIX="${QTOX_DIR}/libs"
if [[ ! -e "${LIB_INSTALL_PREFIX}" ]]; then
@ -139,18 +138,6 @@ function install() {
git clone https://github.com/tux3/qTox.git
fi
fi
# filter_audio
if [[ -e $FA_DIR/.git/index ]]; then # Check if this exists
fcho "Filter_Audio git repo already in place !"
cd $FA_DIR
git pull
else
fcho "Cloning Filter_Audio git ... "
git clone https://github.com/irungentoo/filter_audio.git
cd $FA_DIR
fi
fcho "Installing filter_audio."
make install PREFIX="${LIB_INSTALL_PREFIX}"
# toxcore build
if [[ $TRAVIS = true ]]; then #travis check
@ -231,11 +218,6 @@ function bootstrap() {
fcho "------------------------------"
fcho "starting bootstrap process ..."
# filter_audio
cd $FA_DIR
fcho "Installing filter_audio."
make install PREFIX="${LIB_INSTALL_PREFIX}"
#Toxcore
build_toxcore

View File

@ -68,21 +68,12 @@ contains(DISABLE_PLATFORM_EXT, YES) {
DEFINES += QTOX_PLATFORM_EXT
}
contains(DISABLE_FILTER_AUDIO, NO) {
DEFINES += QTOX_FILTER_AUDIO
}
contains(JENKINS,YES) {
INCLUDEPATH += ./libs/include/
} else {
INCLUDEPATH += libs/include
}
contains(DEFINES, QTOX_FILTER_AUDIO) {
HEADERS += src/audio/audiofilterer.h
SOURCES += src/audio/audiofilterer.cpp
}
contains(DEFINES, QTOX_PLATFORM_EXT) {
HEADERS += src/platform/timer.h
SOURCES += src/platform/timer_osx.cpp \
@ -103,13 +94,6 @@ win32 {
LIBS += -lqrencode -lsqlcipher -lcrypto
LIBS += -lopengl32 -lole32 -loleaut32 -lvfw32 -lws2_32 -liphlpapi -lgdi32 -lshlwapi -luuid
LIBS += -lstrmiids # For DirectShow
contains(DEFINES, QTOX_FILTER_AUDIO) {
contains(STATICPKG, YES) {
LIBS += -Wl,-Bstatic -lfilteraudio
} else {
LIBS += -lfilteraudio
}
}
} else {
macx {
BUNDLEID = chat.tox.qtox
@ -120,7 +104,6 @@ win32 {
LIBS += -framework AVFoundation -framework Foundation -framework CoreMedia -framework ApplicationServices
LIBS += -lqrencode -lsqlcipher
contains(DEFINES, QTOX_PLATFORM_EXT) { LIBS += -framework IOKit -framework CoreFoundation }
contains(DEFINES, QTOX_FILTER_AUDIO) { LIBS += -lfilteraudio }
#Files to be includes into the qTox.app/Contents/Resources folder
#OSX-Migrater.sh part of migrateProfiles() compatabilty code
APP_RESOURCE.files = img/icons/qtox_profile.icns OSX-Migrater.sh
@ -167,16 +150,8 @@ win32 {
LIBS += -lX11 -lXss
}
contains(DEFINES, QTOX_FILTER_AUDIO) {
contains(STATICPKG, YES) {
LIBS += -Wl,-Bstatic -lfilteraudio
} else {
LIBS += -lfilteraudio
}
}
contains(JENKINS, YES) {
LIBS = ./libs/lib/libtoxav.a ./libs/lib/libvpx.a ./libs/lib/libopus.a ./libs/lib/libtoxdns.a ./libs/lib/libtoxencryptsave.a ./libs/lib/libtoxcore.a ./libs/lib/libopenal.a ./libs/lib/libsodium.a ./libs/lib/libfilteraudio.a ./libs/lib/libavdevice.a ./libs/lib/libavformat.a ./libs/lib/libavcodec.a ./libs/lib/libavutil.a ./libs/lib/libswscale.a ./libs/lib/libqrencode.a -ldl -lX11 -lXss
LIBS = ./libs/lib/libtoxav.a ./libs/lib/libvpx.a ./libs/lib/libopus.a ./libs/lib/libtoxdns.a ./libs/lib/libtoxencryptsave.a ./libs/lib/libtoxcore.a ./libs/lib/libopenal.a ./libs/lib/libsodium.a ./libs/lib/libavdevice.a ./libs/lib/libavformat.a ./libs/lib/libavcodec.a ./libs/lib/libavutil.a ./libs/lib/libswscale.a ./libs/lib/libqrencode.a -ldl -lX11 -lXss
contains(ENABLE_SYSTRAY_UNITY_BACKEND, YES) {
LIBS += -lgobject-2.0 -lappindicator -lgtk-x11-2.0
}

View File

@ -32,10 +32,6 @@
#include <cassert>
#ifdef QTOX_FILTER_AUDIO
#include "audiofilterer.h"
#endif
/**
@internal
@ -108,10 +104,6 @@ Audio::Audio()
moveToThread(audioThread);
#ifdef QTOX_FILTER_AUDIO
filterer.startFilter(AUDIO_SAMPLE_RATE);
#endif
connect(&captureTimer, &QTimer::timeout, this, &Audio::doCapture);
captureTimer.setInterval(AUDIO_FRAME_DURATION/2);
captureTimer.setSingleShot(false);
@ -128,9 +120,6 @@ Audio::~Audio()
audioThread->wait();
cleanupInput();
cleanupOutput();
#ifdef QTOX_FILTER_AUDIO
filterer.closeFilter();
#endif
delete d;
}
@ -580,17 +569,6 @@ void Audio::doCapture()
int16_t buf[AUDIO_FRAME_SAMPLE_COUNT * AUDIO_CHANNELS];
alcCaptureSamples(alInDev, buf, AUDIO_FRAME_SAMPLE_COUNT);
#ifdef QTOX_FILTER_AUDIO
if (Settings::getInstance().getFilterAudio())
{
#ifdef ALC_LOOPBACK_CAPTURE_SAMPLES
// compatibility with older versions of OpenAL
getEchoesToFilter(filterer, AUDIO_FRAME_SAMPLE_COUNT * AUDIO_CHANNELS);
#endif
filterer.filterAudio(buf, AUDIO_FRAME_SAMPLE_COUNT * AUDIO_CHANNELS);
}
#endif
for (quint32 i = 0; i < AUDIO_FRAME_SAMPLE_COUNT * AUDIO_CHANNELS; ++i)
{
// gain amplification with clipping to 16-bit boundaries
@ -698,18 +676,3 @@ void Audio::stopLoop()
alSourcei(alMainSource, AL_LOOPING, AL_FALSE);
alSourceStop(alMainSource);
}
#if defined(QTOX_FILTER_AUDIO) && defined(ALC_LOOPBACK_CAPTURE_SAMPLES)
void Audio::getEchoesToFilter(AudioFilterer* filterer, int samples)
{
ALint samples;
alcGetIntegerv(&alOutDev, ALC_LOOPBACK_CAPTURE_SAMPLES, sizeof(samples), &samples);
if (samples >= samples)
{
int16_t buf[samples];
alcCaptureSamplesLoopback(&alOutDev, buf, samples);
filterer->passAudioOutput(buf, samples);
filterer->setEchoDelayMs(5); // This 5ms is configurable I believe
}
}
#endif

View File

@ -42,9 +42,6 @@
#include <AL/alext.h>
#endif
#ifdef QTOX_FILTER_AUDIO
#include "audiofilterer.h"
#endif
// Public default audio settings
static constexpr uint32_t AUDIO_SAMPLE_RATE = 48000; ///< The next best Opus would take is 24k
@ -115,9 +112,7 @@ private:
void playMono16SoundCleanup();
/// Called on the captureTimer events to capture audio
void doCapture();
#if defined(QTOX_FILTER_AUDIO) && defined(ALC_LOOPBACK_CAPTURE_SAMPLES)
void getEchoesToFilter(AudioFilterer* filter, int samples);
#endif
private:
Private* d;
@ -137,9 +132,6 @@ private:
bool outputInitialized;
QList<ALuint> outSources;
#ifdef QTOX_FILTER_AUDIO
AudioFilterer filterer;
#endif
};
#endif // AUDIO_H

View File

@ -1,69 +0,0 @@
/*
Copyright © 2014-2015 by The qTox Project
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox 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.
qTox 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef QTOX_FILTER_AUDIO
#include "audiofilterer.h"
extern "C"{
#include <filter_audio.h>
}
void AudioFilterer::startFilter(uint32_t fs)
{
closeFilter();
filter = new_filter_audio(fs);
}
void AudioFilterer::closeFilter()
{
if (filter)
kill_filter_audio(filter);
filter = nullptr;
}
bool AudioFilterer::filterAudio(int16_t* data, unsigned int samples)
{
return filter && 0 == filter_audio(filter, data, samples);
}
/* Enable/disable filters. 1 to enable, 0 to disable. */
bool AudioFilterer::enableDisableFilters(int echo, int noise, int gain, int vad)
{
return filter && 0 == enable_disable_filters(filter, echo, noise, gain, vad);
}
/* Give the audio output from your software to this function so it knows what echo to cancel from the frame */
bool AudioFilterer::passAudioOutput(const int16_t *data, int samples)
{
return filter && 0 == pass_audio_output(filter, data, samples);
}
/* Tell the echo canceller how much time in ms it takes for audio to be played and recorded back after. */
bool AudioFilterer::setEchoDelayMs(int16_t msInSndCardBuf)
{
return filter && 0 == set_echo_delay_ms(filter, msInSndCardBuf);
}
AudioFilterer::~AudioFilterer()
{
closeFilter();
}
#endif // QTOX_FILTER_AUDIO

View File

@ -1,55 +0,0 @@
/*
Copyright © 2014-2015 by The qTox Project
This file is part of qTox, a Qt-based graphical interface for Tox.
qTox 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.
qTox 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef QTOX_FILTER_AUDIO
#ifndef AUDIOFILTERER_H
#define AUDIOFILTERER_H
#include <cstdint>
#ifndef _FILTER_AUDIO
typedef struct Filter_Audio Filter_Audio;
#endif
class AudioFilterer
{
public:
explicit AudioFilterer() = default;
explicit AudioFilterer(const AudioFilterer&) = delete;
~AudioFilterer();
AudioFilterer operator=(const AudioFilterer) = delete;
void startFilter(uint32_t fs);
void closeFilter();
/* Enable/disable filters. 1 to enable, 0 to disable. */
bool enableDisableFilters(int echo, int noise, int gain, int vad);
bool filterAudio(int16_t* data, unsigned int samples);
/* Give the audio output from your software to this function so it knows what echo to cancel from the frame */
bool passAudioOutput(const int16_t *data, int samples);
/* Tell the echo canceller how much time in ms it takes for audio to be played and recorded back after. */
bool setEchoDelayMs(int16_t msInSndCardBuf);
private:
struct Filter_Audio* filter{nullptr};
};
#endif // AUDIOFILTERER_H
#endif // QTOX_FILTER_AUDIO

View File

@ -31,10 +31,6 @@
#include <QCoreApplication>
#include <QtConcurrent/QtConcurrentRun>
#ifdef QTOX_FILTER_AUDIO
#include "src/audio/audiofilterer.h"
#endif
IndexedList<ToxFriendCall> CoreAV::calls;
IndexedList<ToxGroupCall> CoreAV::groupCalls;
@ -251,30 +247,6 @@ bool CoreAV::sendCallAudio(uint32_t callId, const int16_t *pcm, size_t samples,
return true;
}
#if 0
#ifdef QTOX_FILTER_AUDIO
if (Settings::getInstance().getFilterAudio())
{
if (!call.filterer)
{
call.filterer = new AudioFilterer();
call.filterer->startFilter(AUDIO_SAMPLE_RATE);
}
#ifdef ALC_LOOPBACK_CAPTURE_SAMPLES
// compatibility with older versions of OpenAL
Audio::getInstance().getEchoesToFilter(call.filterer, AUDIO_FRAME_SAMPLE_COUNT * AUDIO_CHANNELS);
#endif
call.filterer->filterAudio(buf, AUDIO_FRAME_SAMPLE_COUNT * AUDIO_CHANNELS);
}
else if (call.filterer)
{
delete call.filterer;
call.filterer = nullptr;
}
#endif
#endif
// TOXAV_ERR_SEND_FRAME_SYNC means toxav failed to lock, retry 5 times in this case
TOXAV_ERR_SEND_FRAME err;
int retries = 0;

View File

@ -27,10 +27,6 @@
#include "src/core/toxcall.h"
#include <tox/toxav.h>
#ifdef QTOX_FILTER_AUDIO
class AudioFilterer;
#endif
class QTimer;
class QThread;
class CoreVideoSource;

View File

@ -7,10 +7,6 @@
#include <QTimer>
#include <QtConcurrent/QtConcurrent>
#ifdef QTOX_FILTER_AUDIO
#include "src/audio/audiofilterer.h"
#endif
using namespace std;
ToxCall::ToxCall(uint32_t CallId)

View File

@ -238,7 +238,6 @@ void Settings::loadGlobal()
outDev = s.value("outDev", "").toString();
audioInGainDecibel = s.value("inGain", 0).toReal();
outVolume = s.value("outVolume", 100).toInt();
filterAudio = s.value("filterAudio", false).toBool();
s.endGroup();
s.beginGroup("Video");
@ -469,7 +468,6 @@ void Settings::saveGlobal()
s.setValue("outDev", outDev);
s.setValue("inGain", audioInGainDecibel);
s.setValue("outVolume", outVolume);
s.setValue("filterAudio", filterAudio);
s.endGroup();
s.beginGroup("Video");
@ -1414,19 +1412,6 @@ void Settings::setOutVolume(int volume)
outVolume = volume;
}
bool Settings::getFilterAudio() const
{
QMutexLocker locker{&bigLock};
// temporary disable filteraudio, as it doesn't work as expected
return false;
}
void Settings::setFilterAudio(bool newValue)
{
QMutexLocker locker{&bigLock};
filterAudio = newValue;
}
QSize Settings::getCamVideoRes() const
{
QMutexLocker locker{&bigLock};

View File

@ -187,9 +187,6 @@ public:
int getOutVolume() const;
void setOutVolume(int volume);
bool getFilterAudio() const;
void setFilterAudio(bool newValue);
QString getVideoDev() const;
void setVideoDev(const QString& deviceSpecifier);
@ -434,7 +431,6 @@ private:
QString outDev;
qreal audioInGainDecibel;
int outVolume;
bool filterAudio;
// Video
QString videoDev;

View File

@ -407,11 +407,6 @@ void AVForm::onOutDevChanged(QString deviceDescriptor)
bodyUI->playbackSlider->setSliderPosition(qRound(audio.outputVolume() * 100.0));
}
void AVForm::onFilterAudioToggled(bool filterAudio)
{
Settings::getInstance().setFilterAudio(filterAudio);
}
void AVForm::onPlaybackValueChanged(int value)
{
Settings::getInstance().setOutVolume(value);

View File

@ -56,7 +56,6 @@ private slots:
// audio
void onInDevChanged(QString deviceDescriptor);
void onOutDevChanged(QString deviceDescriptor);
void onFilterAudioToggled(bool filterAudio);
void onPlaybackValueChanged(int value);
void onMicrophoneValueChanged(int value);

View File

@ -29,27 +29,6 @@ if [ ! -d "include/tox" ]; then
fi
## filter_audio
if [ ! -d $QTOX_DIR/libs/filter_audio ]; then
git clone https://github.com/irungentoo/filter_audio.git $QTOX_DIR/libs/filter_audio
rm bin/libfilteraudio.dll
else
pushd $QTOX_DIR/libs/filter_audio
git pull
popd
fi
if [ ! -f "bin/libfilteraudio.dll" ]; then
pushd $QTOX_DIR/libs/filter_audio
PREFIX="$QTOX_DIR/libs" CC="gcc.exe" make install
mv libfilteraudio.dll.a $QTOX_DIR/libs/lib
popd
if [ -f "lib/libfilteraudio.dll" ]; then
mv lib/libfilteraudio.dll bin/
fi
fi
## qrencode
if [ ! -f "qrencode-3.4.4.tar.gz" ]; then
wget http://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz