mirror of
https://github.com/uowuo/abaddon.git
synced 2025-03-04 03:03:16 -05:00
Merge branch 'master' into classic-channels
This commit is contained in:
commit
cb6436f527
@ -10,7 +10,7 @@ AllowAllParametersOfDeclarationOnNextLine: 'false'
|
||||
AllowShortBlocksOnASingleLine: 'true'
|
||||
AllowShortCaseLabelsOnASingleLine: 'true'
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: 'true'
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
|
@ -50,7 +50,7 @@ file(GLOB_RECURSE ABADDON_SOURCES
|
||||
"src/*.h"
|
||||
"src/*.hpp"
|
||||
"src/*.cpp"
|
||||
)
|
||||
)
|
||||
|
||||
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_gio\\.cpp$")
|
||||
list(FILTER ABADDON_SOURCES EXCLUDE REGEX ".*notifier_fallback\\.cpp$")
|
||||
@ -148,6 +148,12 @@ endif ()
|
||||
|
||||
set(USE_MINIAUDIO FALSE)
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(abaddon "-framework CoreFoundation")
|
||||
target_link_libraries(abaddon "-framework CoreAudio")
|
||||
target_link_libraries(abaddon "-framework AudioToolbox")
|
||||
endif ()
|
||||
|
||||
if (ENABLE_VOICE)
|
||||
target_compile_definitions(abaddon PRIVATE WITH_VOICE)
|
||||
|
||||
@ -194,12 +200,6 @@ if (ENABLE_VOICE)
|
||||
target_link_libraries(abaddon rnnoise::rnnoise)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(abaddon "-framework CoreFoundation")
|
||||
target_link_libraries(abaddon "-framework CoreAudio")
|
||||
target_link_libraries(abaddon "-framework AudioToolbox")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (${ENABLE_NOTIFICATION_SOUNDS})
|
||||
@ -214,12 +214,11 @@ if (USE_MINIAUDIO)
|
||||
PATH_SUFFIXES miniaudio
|
||||
REQUIRED)
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(abaddon "-framework CoreFoundation")
|
||||
target_link_libraries(abaddon "-framework CoreAudio")
|
||||
target_link_libraries(abaddon "-framework AudioToolbox")
|
||||
endif ()
|
||||
|
||||
target_include_directories(abaddon PUBLIC ${MINIAUDIO_INCLUDE_DIR})
|
||||
target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO)
|
||||
endif ()
|
||||
|
||||
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 ()
|
||||
|
@ -25,6 +25,23 @@
|
||||
#include "remoteauth/remoteauthdialog.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
void macOSThemeChanged() {
|
||||
CFPropertyListRef appearanceName = CFPreferencesCopyAppValue(CFSTR("AppleInterfaceStyle"), kCFPreferencesAnyApplication);
|
||||
if (appearanceName != NULL && CFGetTypeID(appearanceName) == CFStringGetTypeID() && CFStringCompare((CFStringRef)appearanceName, CFSTR("Dark"), 0) == kCFCompareEqualTo) {
|
||||
Gtk::Settings::get_default()->set_property("gtk-application-prefer-dark-theme", true);
|
||||
} else {
|
||||
Gtk::Settings::get_default()->set_property("gtk-application-prefer-dark-theme", false);
|
||||
}
|
||||
}
|
||||
|
||||
void macOSThemeChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
|
||||
macOSThemeChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_LIBHANDY
|
||||
#include <handy.h>
|
||||
#endif
|
||||
@ -36,7 +53,8 @@
|
||||
Abaddon::Abaddon()
|
||||
: m_settings(Platform::FindConfigFile())
|
||||
, m_discord(GetSettings().UseMemoryDB) // stupid but easy
|
||||
, m_emojis(GetResPath("/emojis.bin")) {
|
||||
, m_emojis(GetResPath("/emojis.bin"))
|
||||
, m_audio(GetSettings().Backends) {
|
||||
LoadFromSettings();
|
||||
|
||||
// todo: set user agent for non-client(?)
|
||||
@ -331,6 +349,17 @@ int Abaddon::StartGTK() {
|
||||
m_gtk_app->hold();
|
||||
m_main_window->show();
|
||||
|
||||
#if defined(__APPLE__)
|
||||
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
|
||||
NULL,
|
||||
macOSThemeChangedCallback,
|
||||
CFSTR("AppleInterfaceThemeChangedNotification"),
|
||||
NULL,
|
||||
CFNotificationSuspensionBehaviorCoalesce);
|
||||
|
||||
macOSThemeChanged();
|
||||
#endif
|
||||
|
||||
RunFirstTimeDiscordStartup();
|
||||
|
||||
return m_gtk_app->run(*m_main_window);
|
||||
|
@ -85,7 +85,7 @@ void mgr_log_callback(void *pUserData, ma_uint32 level, const char *pMessage) {
|
||||
g_free(msg);
|
||||
}
|
||||
|
||||
AudioManager::AudioManager()
|
||||
AudioManager::AudioManager(const Glib::ustring &backends_string)
|
||||
: m_log(spdlog::stdout_color_mt("miniaudio")) {
|
||||
m_ok = true;
|
||||
|
||||
@ -107,7 +107,19 @@ AudioManager::AudioManager()
|
||||
|
||||
auto ctx_cfg = ma_context_config_init();
|
||||
ctx_cfg.pLog = &m_ma_log;
|
||||
if (ma_context_init(nullptr, 0, &ctx_cfg, &m_context) != MA_SUCCESS) {
|
||||
|
||||
ma_backend *pBackends = nullptr;
|
||||
ma_uint32 backendCount = 0;
|
||||
|
||||
std::vector<ma_backend> backends_vec;
|
||||
if (!backends_string.empty()) {
|
||||
spdlog::get("audio")->debug("Using backends list: {}", std::string(backends_string));
|
||||
backends_vec = ParseBackendsList(backends_string);
|
||||
pBackends = backends_vec.data();
|
||||
backendCount = static_cast<ma_uint32>(backends_vec.size());
|
||||
}
|
||||
|
||||
if (ma_context_init(pBackends, backendCount, &ctx_cfg, &m_context) != MA_SUCCESS) {
|
||||
spdlog::get("audio")->error("failed to initialize context");
|
||||
m_ok = false;
|
||||
return;
|
||||
@ -647,6 +659,28 @@ AudioManager::VADMethod AudioManager::GetVADMethod() const {
|
||||
return m_vad_method;
|
||||
}
|
||||
|
||||
std::vector<ma_backend> AudioManager::ParseBackendsList(const Glib::ustring &list) {
|
||||
auto regex = Glib::Regex::create(";");
|
||||
const std::vector<Glib::ustring> split = regex->split(list);
|
||||
|
||||
std::vector<ma_backend> backends;
|
||||
for (const auto &s : split) {
|
||||
if (s == "wasapi") backends.push_back(ma_backend_wasapi);
|
||||
else if (s == "dsound") backends.push_back(ma_backend_dsound);
|
||||
else if (s == "winmm") backends.push_back(ma_backend_winmm);
|
||||
else if (s == "coreaudio") backends.push_back(ma_backend_coreaudio);
|
||||
else if (s == "sndio") backends.push_back(ma_backend_sndio);
|
||||
else if (s == "audio4") backends.push_back(ma_backend_audio4);
|
||||
else if (s == "oss") backends.push_back(ma_backend_oss);
|
||||
else if (s == "pulseaudio") backends.push_back(ma_backend_pulseaudio);
|
||||
else if (s == "alsa") backends.push_back(ma_backend_alsa);
|
||||
else if (s == "jack") backends.push_back(ma_backend_jack);
|
||||
}
|
||||
backends.push_back(ma_backend_null);
|
||||
|
||||
return backends;
|
||||
}
|
||||
|
||||
#ifdef WITH_RNNOISE
|
||||
float AudioManager::GetCurrentVADProbability() const {
|
||||
return m_vad_prob;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
class AudioManager {
|
||||
public:
|
||||
AudioManager();
|
||||
AudioManager(const Glib::ustring &backends_string);
|
||||
~AudioManager();
|
||||
|
||||
void AddSSRC(uint32_t ssrc);
|
||||
@ -80,6 +80,8 @@ public:
|
||||
void SetVADMethod(VADMethod method);
|
||||
VADMethod GetVADMethod() const;
|
||||
|
||||
static std::vector<ma_backend> ParseBackendsList(const Glib::ustring &list);
|
||||
|
||||
#ifdef WITH_RNNOISE
|
||||
float GetCurrentVADProbability() const;
|
||||
double GetRNNProbThreshold() const;
|
||||
|
@ -129,6 +129,7 @@ void SettingsManager::DefineSettings() {
|
||||
#else
|
||||
AddSetting("voice", "vad", "gate"s, &Settings::VAD);
|
||||
#endif
|
||||
AddSetting("voice", "backends", ""s, &Settings::Backends);
|
||||
}
|
||||
|
||||
void SettingsManager::ReadSettings() {
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
|
||||
// [voice]
|
||||
std::string VAD;
|
||||
std::string Backends;
|
||||
|
||||
// [windows]
|
||||
bool HideConsole;
|
||||
|
Loading…
Reference in New Issue
Block a user