mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(cmake): change folder structure
The new folder structure will be like this: /<module>/CMakeLists.txt /<module>/src/file.cpp /<module>/include/<module>/file.h /<module>/<subdir>/<...>
This commit is contained in:
parent
f3a10815ed
commit
a90f0762d9
|
@ -257,18 +257,6 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|||
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc)
|
||||
|
||||
set(${PROJECT_NAME}_SOURCES
|
||||
src/audio/audio.cpp
|
||||
src/audio/audio.h
|
||||
src/audio/backend/alsink.cpp
|
||||
src/audio/backend/alsink.h
|
||||
src/audio/backend/alsource.cpp
|
||||
src/audio/backend/alsource.h
|
||||
src/audio/backend/openal.cpp
|
||||
src/audio/backend/openal.h
|
||||
src/audio/iaudiosettings.h
|
||||
src/audio/iaudiocontrol.h
|
||||
src/audio/iaudiosink.h
|
||||
src/audio/iaudiosource.h
|
||||
src/chatlog/chatlinecontent.cpp
|
||||
src/chatlog/chatlinecontent.h
|
||||
src/chatlog/chatlinecontentproxy.cpp
|
||||
|
@ -368,7 +356,6 @@ set(${PROJECT_NAME}_SOURCES
|
|||
src/model/group.h
|
||||
src/model/status.cpp
|
||||
src/model/status.h
|
||||
src/model/interface.h
|
||||
src/model/profile/iprofileinfo.h
|
||||
src/model/profile/profileinfo.cpp
|
||||
src/model/profile/profileinfo.h
|
||||
|
@ -659,6 +646,9 @@ MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
|
|||
# the compiler flags for compiling C++ sources
|
||||
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
|
||||
|
||||
add_subdirectory(util)
|
||||
add_subdirectory(audio)
|
||||
|
||||
add_library(${PROJECT_NAME}_static
|
||||
STATIC
|
||||
${${PROJECT_NAME}_FORMS}
|
||||
|
@ -669,6 +659,9 @@ target_link_libraries(${PROJECT_NAME}_static
|
|||
${CMAKE_REQUIRED_LIBRARIES}
|
||||
${ALL_LIBRARIES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}_static util_library)
|
||||
target_link_libraries(${PROJECT_NAME}_static audio_library)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
WIN32
|
||||
MACOSX_BUNDLE
|
||||
|
|
45
audio/CMakeLists.txt
Normal file
45
audio/CMakeLists.txt
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Copyright © 2020 by The qTox Project Contributors
|
||||
#
|
||||
# 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/>
|
||||
|
||||
set(SOURCE_FILES
|
||||
"include/audio/audio.h"
|
||||
"include/audio/iaudiocontrol.h"
|
||||
"include/audio/iaudiosettings.h"
|
||||
"include/audio/iaudiosink.h"
|
||||
"include/audio/iaudiosource.h"
|
||||
"src/audio.cpp"
|
||||
"src/backend/alsink.cpp"
|
||||
"src/backend/alsink.h"
|
||||
"src/backend/alsource.cpp"
|
||||
"src/backend/alsource.h"
|
||||
"src/backend/openal.cpp"
|
||||
"src/backend/openal.h")
|
||||
|
||||
add_library(audio_library STATIC ${SOURCE_FILES})
|
||||
|
||||
qt5_add_resources(
|
||||
audio_library
|
||||
res.qrc
|
||||
OPTIONS ${RCC_OPTIONS}
|
||||
)
|
||||
|
||||
# We need this directory, and users of our library will need it too
|
||||
target_include_directories(audio_library PUBLIC include/)
|
||||
|
||||
target_link_libraries(audio_library util_library)
|
||||
target_link_libraries(audio_library Qt5::Core)
|
||||
target_link_libraries(audio_library ${OPENAL_LIBRARIES})
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
|
||||
#include <QString>
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
|
||||
/**
|
||||
* @brief The IAudioSink class represents an interface to devices that can play audio.
|
8
audio/resources/res.qrc
Normal file
8
audio/resources/res.qrc
Normal file
|
@ -0,0 +1,8 @@
|
|||
<RCC>
|
||||
<qresource prefix="/audio">
|
||||
<file>notification.s16le.pcm</file>
|
||||
<file>ToxIncomingCall.s16le.pcm</file>
|
||||
<file>ToxOutgoingCall.s16le.pcm</file>
|
||||
<file>ToxEndCall.s16le.pcm</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "src/audio/audio.h"
|
||||
#include "src/audio/iaudiosettings.h"
|
||||
#include "src/audio/backend/openal.h"
|
||||
#include "audio/audio.h"
|
||||
#include "audio/iaudiosettings.h"
|
||||
#include "backend/openal.h"
|
||||
|
||||
/**
|
||||
* @brief Select the audio backend
|
||||
|
@ -30,5 +30,5 @@
|
|||
*/
|
||||
std::unique_ptr<IAudioControl> Audio::makeAudio(IAudioSettings& settings)
|
||||
{
|
||||
return std::unique_ptr<IAudioControl>(new OpenAL());
|
||||
return std::unique_ptr<IAudioControl>(new OpenAL(settings));
|
||||
}
|
|
@ -17,8 +17,8 @@
|
|||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "src/audio/backend/alsink.h"
|
||||
#include "src/audio/backend/openal.h"
|
||||
#include "audio/src/backend/alsink.h"
|
||||
#include "audio/src/backend/openal.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMutexLocker>
|
|
@ -22,8 +22,8 @@
|
|||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "src/audio/iaudiosink.h"
|
||||
#include "util/interface.h"
|
||||
#include "audio/iaudiosink.h"
|
||||
|
||||
class OpenAL;
|
||||
class QMutex;
|
|
@ -17,8 +17,8 @@
|
|||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "src/audio/backend/alsource.h"
|
||||
#include "src/audio/backend/openal.h"
|
||||
#include "audio/src/backend/alsource.h"
|
||||
#include "audio/src/backend/openal.h"
|
||||
|
||||
/**
|
||||
* @brief Emits audio frames captured by an input device or other audio source.
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/audio/iaudiosource.h"
|
||||
#include "audio/iaudiosource.h"
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "openal.h"
|
||||
#include "src/persistence/settings.h"
|
||||
|
||||
#include "audio/iaudiosettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
@ -56,8 +57,9 @@ void applyGain(int16_t* buffer, uint32_t bufferSize, qreal gainFactor)
|
|||
static const unsigned int BUFFER_COUNT = 16;
|
||||
static const uint32_t AUDIO_CHANNELS = 2;
|
||||
|
||||
OpenAL::OpenAL()
|
||||
: audioThread{new QThread}
|
||||
OpenAL::OpenAL(IAudioSettings& _settings)
|
||||
: settings{_settings}
|
||||
, audioThread{new QThread}
|
||||
{
|
||||
// initialize OpenAL error stack
|
||||
alGetError();
|
||||
|
@ -370,7 +372,7 @@ void OpenAL::destroySource(AlSource& source)
|
|||
*/
|
||||
bool OpenAL::autoInitInput()
|
||||
{
|
||||
return alInDev ? true : initInput(Settings::getInstance().getInDev());
|
||||
return alInDev ? true : initInput(settings.getInDev());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -380,7 +382,7 @@ bool OpenAL::autoInitInput()
|
|||
*/
|
||||
bool OpenAL::autoInitOutput()
|
||||
{
|
||||
return alOutDev ? true : initOutput(Settings::getInstance().getOutDev());
|
||||
return alOutDev ? true : initOutput(settings.getOutDev());
|
||||
}
|
||||
|
||||
bool OpenAL::initInput(const QString& deviceName)
|
||||
|
@ -390,7 +392,7 @@ bool OpenAL::initInput(const QString& deviceName)
|
|||
|
||||
bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
|
||||
{
|
||||
if (!Settings::getInstance().getAudioInDevEnabled()) {
|
||||
if (!settings.getAudioInDevEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -417,8 +419,8 @@ bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
|
|||
}
|
||||
|
||||
inputBuffer = new int16_t[AUDIO_FRAME_SAMPLE_COUNT_TOTAL];
|
||||
setInputGain(Settings::getInstance().getAudioInGainDecibel());
|
||||
setInputThreshold(Settings::getInstance().getAudioThreshold());
|
||||
setInputGain(settings.getAudioInGainDecibel());
|
||||
setInputThreshold(settings.getAudioThreshold());
|
||||
|
||||
qDebug() << "Opened audio input" << deviceName;
|
||||
alcCaptureStart(alInDev);
|
||||
|
@ -435,7 +437,7 @@ bool OpenAL::initOutput(const QString& deviceName)
|
|||
assert(sinks.size() == 0);
|
||||
|
||||
outputInitialized = false;
|
||||
if (!Settings::getInstance().getAudioOutDevEnabled())
|
||||
if (!settings.getAudioOutDevEnabled())
|
||||
return false;
|
||||
|
||||
qDebug() << "Opening audio output" << deviceName;
|
||||
|
@ -460,7 +462,7 @@ bool OpenAL::initOutput(const QString& deviceName)
|
|||
}
|
||||
|
||||
// init master volume
|
||||
alListenerf(AL_GAIN, Settings::getInstance().getOutVolume() * 0.01f);
|
||||
alListenerf(AL_GAIN, settings.getOutVolume() * 0.01f);
|
||||
checkAlError();
|
||||
|
||||
outputInitialized = true;
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/audio/iaudiocontrol.h"
|
||||
#include "src/audio/backend/alsink.h"
|
||||
#include "src/audio/backend/alsource.h"
|
||||
#include "audio/iaudiocontrol.h"
|
||||
#include "alsink.h"
|
||||
#include "alsource.h"
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
|
@ -44,12 +44,14 @@
|
|||
#include <AL/alext.h>
|
||||
#endif
|
||||
|
||||
class IAudioSettings;
|
||||
|
||||
class OpenAL : public IAudioControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OpenAL();
|
||||
OpenAL(IAudioSettings& _settings);
|
||||
virtual ~OpenAL();
|
||||
|
||||
qreal maxOutputVolume() const
|
||||
|
@ -131,6 +133,7 @@ private:
|
|||
float getVolume();
|
||||
|
||||
protected:
|
||||
IAudioSettings& settings;
|
||||
QThread* audioThread;
|
||||
mutable QMutex audioLock{QMutex::Recursive};
|
||||
QString inDev{};
|
4
res.qrc
4
res.qrc
|
@ -6,10 +6,6 @@
|
|||
<file alias="DejaVuSans.ttf">res/font/DejaVuSans.ttf</file>
|
||||
</qresource>
|
||||
<qresource prefix="/">
|
||||
<file>audio/notification.s16le.pcm</file>
|
||||
<file>audio/ToxIncomingCall.s16le.pcm</file>
|
||||
<file>audio/ToxOutgoingCall.s16le.pcm</file>
|
||||
<file>audio/ToxEndCall.s16le.pcm</file>
|
||||
<file>img/add.svg</file>
|
||||
<file>img/avatar_mask.svg</file>
|
||||
<file>img/contact.svg</file>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "src/model/ibootstraplistgenerator.h"
|
||||
#include "src/nexus.h"
|
||||
#include "src/persistence/profile.h"
|
||||
#include "src/util/strongtype.h"
|
||||
#include "util/strongtype.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "toxid.h"
|
||||
#include "toxpk.h"
|
||||
|
||||
#include "src/util/strongtype.h"
|
||||
#include "util/strongtype.h"
|
||||
#include "src/model/status.h"
|
||||
#include <tox/tox.h>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QNetworkProxy>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/util/strongtype.h"
|
||||
#include "util/strongtype.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <cstdint>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "src/core/toxcall.h"
|
||||
#include "src/audio/audio.h"
|
||||
#include "audio/audio.h"
|
||||
#include "src/core/coreav.h"
|
||||
#include "src/persistence/settings.h"
|
||||
#include "src/video/camerasource.h"
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/audio/iaudiocontrol.h"
|
||||
#include "src/audio/iaudiosink.h"
|
||||
#include "src/audio/iaudiosource.h"
|
||||
#include "audio/iaudiocontrol.h"
|
||||
#include "audio/iaudiosink.h"
|
||||
#include "audio/iaudiosource.h"
|
||||
#include <src/core/toxpk.h>
|
||||
#include <tox/toxav.h>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "src/audio/audio.h"
|
||||
#include "audio/audio.h"
|
||||
#include "src/ipc.h"
|
||||
#include "src/net/toxuri.h"
|
||||
#include "src/nexus.h"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "iaboutfriend.h"
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
#include "src/persistence/ifriendsettings.h"
|
||||
|
||||
#include <QObject>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
#include "src/persistence/ifriendsettings.h"
|
||||
|
||||
#include <QObject>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "src/model/friend.h"
|
||||
#include "src/model/group.h"
|
||||
#include "src/persistence/history.h"
|
||||
#include "src/util/strongtype.h"
|
||||
#include "util/strongtype.h"
|
||||
#include "src/widget/searchtypes.h"
|
||||
|
||||
#include <cassert>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
#include "src/core/toxpk.h"
|
||||
#include "iprofileinfo.h"
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QThread>
|
||||
#include <cassert>
|
||||
#include <src/audio/audio.h>
|
||||
#include "audio/audio.h"
|
||||
#include <vpx/vpx_image.h>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "src/audio/iaudiocontrol.h"
|
||||
#include "audio/iaudiocontrol.h"
|
||||
|
||||
class Widget;
|
||||
class Profile;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/util/strongtype.h"
|
||||
#include "util/strongtype.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMutex>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QFlag>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/audio/iaudiosettings.h"
|
||||
#include "audio/iaudiosettings.h"
|
||||
#include "src/core/icoresettings.h"
|
||||
#include "src/core/toxencrypt.h"
|
||||
#include "src/core/toxfile.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "src/model/interface.h"
|
||||
#include "util/interface.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QRect>
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include <QScreen>
|
||||
#include <QShowEvent>
|
||||
|
||||
#include "src/audio/audio.h"
|
||||
#include "src/audio/iaudiosettings.h"
|
||||
#include "src/audio/iaudiosource.h"
|
||||
#include "audio/audio.h"
|
||||
#include "audio/iaudiosettings.h"
|
||||
#include "audio/iaudiosource.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/core/coreav.h"
|
||||
#include "src/video/cameradevice.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "settingswidget.h"
|
||||
|
||||
#include "src/audio/audio.h"
|
||||
#include "audio/audio.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/core/coreav.h"
|
||||
#include "src/net/updatecheck.h"
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QWindow>
|
||||
#endif
|
||||
|
||||
#include "audio/audio.h"
|
||||
#include "circlewidget.h"
|
||||
#include "contentdialog.h"
|
||||
#include "contentlayout.h"
|
||||
|
@ -47,7 +48,6 @@
|
|||
#include "maskablepixmapwidget.h"
|
||||
#include "splitterrestorer.h"
|
||||
#include "form/groupchatform.h"
|
||||
#include "src/audio/audio.h"
|
||||
#include "src/chatlog/content/filetransferwidget.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/core/coreav.h"
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
#include "genericchatitemwidget.h"
|
||||
|
||||
#include "src/audio/iaudiocontrol.h"
|
||||
#include "src/audio/iaudiosink.h"
|
||||
#include "audio/iaudiocontrol.h"
|
||||
#include "audio/iaudiosink.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/core/groupid.h"
|
||||
#include "src/core/toxfile.h"
|
||||
|
|
25
util/CMakeLists.txt
Normal file
25
util/CMakeLists.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright © 2020 by The qTox Project Contributors
|
||||
#
|
||||
# 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/>
|
||||
|
||||
set(HEADER_LIST
|
||||
"include/util/interface.h"
|
||||
"include/util/strongtype.h")
|
||||
|
||||
add_library(util_library STATIC ${HEADER_LIST})
|
||||
|
||||
# We need this directory, and users of our library will need it too
|
||||
target_include_directories(util_library PUBLIC include/)
|
||||
|
Loading…
Reference in New Issue
Block a user