add workaround for compiling with spdlog and incompatible libfmt (fixes #214)

This commit is contained in:
ouwou 2023-08-25 20:13:37 -04:00
parent 2378c781d1
commit eea5987f37
5 changed files with 19 additions and 13 deletions

View File

@ -79,7 +79,8 @@ AudioManager::AudioManager() {
return;
}
spdlog::get("audio")->info("Audio backend: {}", ma_get_backend_name(m_context.backend));
const auto backend_name = ma_get_backend_name(m_context.backend);
spdlog::get("audio")->info("Audio backend: {}", backend_name);
Enumerate();

View File

@ -182,7 +182,8 @@ void DiscordVoiceClient::Start() {
void DiscordVoiceClient::Stop() {
if (!IsConnected() && !IsConnecting()) {
m_log->warn("Requested stop while not connected (from {})", GetStateName(m_state));
const auto state_name = GetStateName(m_state);
m_log->warn("Requested stop while not connected (from {})", state_name);
return;
}
@ -264,7 +265,8 @@ void DiscordVoiceClient::OnGatewayMessage(const std::string &str) {
HandleGatewaySpeaking(msg);
break;
default:
m_log->warn("Unhandled opcode: {}", static_cast<int>(msg.Opcode));
const auto opcode_int = static_cast<int>(msg.Opcode);
m_log->warn("Unhandled opcode: {}", opcode_int);
}
}
@ -318,7 +320,8 @@ void DiscordVoiceClient::HandleGatewayReady(const VoiceGatewayMessage &m) {
void DiscordVoiceClient::HandleGatewaySessionDescription(const VoiceGatewayMessage &m) {
VoiceSessionDescriptionData d = m.Data;
m_log->debug("Received session description (mode: {}) (key: {:ns}) ", d.Mode, spdlog::to_hex(d.SecretKey.begin(), d.SecretKey.end()));
const auto key_hex = spdlog::to_hex(d.SecretKey.begin(), d.SecretKey.end());
m_log->debug("Received session description (mode: {}) (key: {:ns}) ", d.Mode, key_hex);
VoiceSpeakingMessage msg;
msg.Delay = 0;
@ -379,7 +382,7 @@ void DiscordVoiceClient::Discovery() {
m_udp.Send(payload.data(), payload.size());
constexpr int MAX_TRIES = 100;
for (int i = 0; i < MAX_TRIES; i++) {
for (int i = 1; i <= MAX_TRIES; i++) {
const auto response = m_udp.Receive();
if (response.size() >= 74 && response[0] == 0x00 && response[1] == 0x02) {
const char *ip = reinterpret_cast<const char *>(response.data() + 8);
@ -388,7 +391,7 @@ void DiscordVoiceClient::Discovery() {
SelectProtocol(ip, port);
break;
} else {
m_log->error("Received non-discovery packet after sending request (try {}/{})", i + 1, MAX_TRIES);
m_log->error("Received non-discovery packet after sending request (try {}/{})", i, MAX_TRIES);
}
}
}
@ -451,7 +454,8 @@ void DiscordVoiceClient::KeepaliveThread() {
}
void DiscordVoiceClient::SetState(State state) {
m_log->debug("Changing state to {}", GetStateName(state));
const auto state_name = GetStateName(state);
m_log->debug("Changing state to {}", state_name);
m_state = state;
m_signal_state_update.emit(state);
}

View File

@ -74,7 +74,8 @@ void Websocket::OnMessage(const ix::WebSocketMessagePtr &msg) {
m_open_dispatcher.emit();
} break;
case ix::WebSocketMessageType::Close: {
m_log->debug("Received close frame, dispatching. {} ({}){}", msg->closeInfo.code, msg->closeInfo.reason, msg->closeInfo.remote ? " Remote" : "");
const auto remote = msg->closeInfo.remote ? " Remote" : "";
m_log->debug("Received close frame, dispatching. {} ({}){}", msg->closeInfo.code, msg->closeInfo.reason, remote);
m_close_info = msg->closeInfo;
m_close_dispatcher.emit();
} break;

View File

@ -111,9 +111,10 @@ void RemoteAuthClient::HandleGatewayPendingTicket(const nlohmann::json &j) {
const auto encrypted_payload = Glib::Base64::decode(j.at("encrypted_user_payload").get<std::string>());
const auto payload = Decrypt(reinterpret_cast<const unsigned char *>(encrypted_payload.data()), encrypted_payload.size());
m_log->trace("User payload: {}", std::string(payload.begin(), payload.end()));
const auto payload_str = std::string(payload.begin(), payload.end());
m_log->trace("User payload: {}", payload_str);
const std::vector<Glib::ustring> user_info = Glib::Regex::split_simple(":", std::string(payload.begin(), payload.end()));
const std::vector<Glib::ustring> user_info = Glib::Regex::split_simple(":", payload_str);
Snowflake user_id;
std::string discriminator;
std::string avatar_hash;
@ -140,7 +141,8 @@ void RemoteAuthClient::HandleGatewayCancel(const nlohmann::json &j) {
void RemoteAuthClient::OnRemoteAuthLoginResponse(const std::optional<std::string> &encrypted_token, DiscordError err) {
if (!encrypted_token.has_value()) {
m_log->error("Remote auth login failed: {}", static_cast<int>(err));
const auto err_int = static_cast<int>(err);
m_log->error("Remote auth login failed: {}", err_int);
if (err == DiscordError::CAPTCHA_REQUIRED) {
m_signal_error.emit("Discord is requiring a captcha. You must use a web browser to log in.");
} else {

View File

@ -35,7 +35,6 @@ VoiceSettingsWindow::VoiceSettingsWindow()
m_encoding_mode.signal_changed().connect([this]() {
const auto mode = m_encoding_mode.get_active_text();
auto &audio = Abaddon::Get().GetAudio();
spdlog::get("audio")->debug("Chose encoding mode: {}", mode.c_str());
if (mode == "Voice") {
audio.SetEncodingApplication(OPUS_APPLICATION_VOIP);
} else if (mode == "Music") {
@ -67,7 +66,6 @@ VoiceSettingsWindow::VoiceSettingsWindow()
m_signal.signal_changed().connect([this]() {
const auto signal = m_signal.get_active_text();
auto &audio = Abaddon::Get().GetAudio();
spdlog::get("audio")->debug("Chose signal hint: {}", signal.c_str());
if (signal == "Auto") {
audio.SetSignalHint(OPUS_AUTO);
} else if (signal == "Voice") {