Skip to content

Commit

Permalink
Fix includes, include audio sources only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ryze312 committed Jun 11, 2024
1 parent bd45254 commit 9d5eb73
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 34 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ file(GLOB_RECURSE ABADDON_SOURCES
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_gio\\.cpp$")
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_fallback\\.cpp$")

if (NOT ENABLE_VOICE)
list(FILTER ABADDON_SOURCES EXCLUDE REGEX "src/audio/voice/.*")
endif ()

if (NOT (ENABLE_VOICE OR ENABLE_NOTIFICATION_SOUNDS))
list(FILTER ABADDON_SOURCES EXCLUDE REGEX "src/audio/.*")
endif ()

add_executable(abaddon ${ABADDON_SOURCES})
target_include_directories(abaddon PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_include_directories(abaddon PUBLIC ${PROJECT_BINARY_DIR})
Expand Down Expand Up @@ -216,3 +224,5 @@ set(ABADDON_COMPILER_DEFS "" CACHE STRING "Additional compiler definitions")
foreach (COMPILER_DEF IN LISTS ABADDON_COMPILER_DEFS)
target_compile_definitions(abaddon PRIVATE "${COMPILER_DEF}")
endforeach ()

set_property(TARGET abaddon PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
7 changes: 5 additions & 2 deletions src/abaddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <algorithm>
#include <gtkmm.h>
#include "platform.hpp"
#include "audio/manager.hpp"
#include "discord/discord.hpp"
#include "dialogs/token.hpp"
#include "dialogs/confirm.hpp"
Expand Down Expand Up @@ -50,11 +49,15 @@ void macOSThemeChangedCallback(CFNotificationCenterRef center, void *observer, C
#pragma comment(lib, "crypt32.lib")
#endif

#ifdef WITH_MINIAUDIO
#include "audio/manager.hpp"
#endif

Abaddon::Abaddon()
: m_settings(Platform::FindConfigFile())
, m_discord(GetSettings().UseMemoryDB) // stupid but easy
, m_emojis(GetResPath("/emojis.db"))
#ifdef WITH_VOICE
#ifdef WITH_MINIAUDIO
, m_audio(GetSettings().Backends, m_discord)
#endif
{
Expand Down
12 changes: 8 additions & 4 deletions src/abaddon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
#include "imgmanager.hpp"
#include "emojis.hpp"
#include "notifications/notifications.hpp"

#ifdef WITH_MINIAUDIO
#include "audio/manager.hpp"
#endif

#define APP_TITLE "Abaddon"

class AudioManager;

class Abaddon {
private:
Abaddon();
Expand Down Expand Up @@ -72,7 +73,7 @@ class Abaddon {
ImageManager &GetImageManager();
EmojiResource &GetEmojis();

#ifdef WITH_VOICE
#ifdef WITH_MINIAUDIO
AudioManager &GetAudio();
#endif

Expand Down Expand Up @@ -174,8 +175,11 @@ class Abaddon {
ImageManager m_img_mgr;
EmojiResource m_emojis;

#ifdef WITH_VOICE
#ifdef WITH_MINIAUDIO
AudioManager m_audio;
#endif

#ifdef WITH_VOICE
Gtk::Window *m_voice_window = nullptr;
#endif

Expand Down
3 changes: 0 additions & 3 deletions src/audio/devices.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef WITH_VOICE

// clang-format off

#include "devices.hpp"
Expand Down Expand Up @@ -118,4 +116,3 @@ AudioDevices::CaptureColumns::CaptureColumns() {
add(Name);
add(DeviceID);
}
#endif
2 changes: 0 additions & 2 deletions src/audio/devices.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#ifdef WITH_MINIAUDIO

// clang-format off

Expand Down Expand Up @@ -58,4 +57,3 @@ class AudioDevices {
Gtk::TreeModel::iterator m_active_capture_iter;
Gtk::TreeModel::iterator m_default_capture_iter;
};
#endif
16 changes: 0 additions & 16 deletions src/audio/manager.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
#ifdef WITH_MINIAUDIO
// clang-format off

#ifdef _WIN32
#include <winsock2.h>
#endif

#include "manager.hpp"
#include "abaddon.hpp"
#include <glibmm/main.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <miniaudio.h>
#include <opus.h>
#include <cstring>
// clang-format on

void mgr_log_callback(void *pUserData, ma_uint32 level, const char *pMessage) {
auto *log = static_cast<spdlog::logger *>(pUserData);
Expand Down Expand Up @@ -151,5 +137,3 @@ const AbaddonClient::Audio::VoiceAudio& AudioManager::GetVoice() const noexcept
}

#endif

#endif
11 changes: 4 additions & 7 deletions src/audio/manager.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#pragma once
#ifdef WITH_MINIAUDIO

// clang-format off

#include <gtkmm/treemodel.h>
#include <vector>
#include <miniaudio.h>
#include <opus.h>
#include <sigc++/sigc++.h>
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>

#include "devices.hpp"

#include "audio/context.hpp"

#ifdef WITH_VOICE
#include "voice/voice_audio.hpp"
#endif
Expand Down Expand Up @@ -59,4 +57,3 @@ class AudioManager {

bool m_ok = false;
};
#endif
2 changes: 2 additions & 0 deletions src/audio/miniaudio/ma_pcm_rb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <miniaudio.h>

#include "audio/utils.hpp"

namespace AbaddonClient::Audio::Miniaudio {

class MaPCMRingBuffer {
Expand Down

0 comments on commit 9d5eb73

Please sign in to comment.