summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2025-05-03 18:33:06 +0200
committerGitHub <noreply@github.com>2025-05-03 18:33:06 +0200
commitffd78711beda9aa79046fc04e747a91f49cb4e3c (patch)
treea715ed12bdfa23c06e486c5b23eb4723efd7ad47 /Source/Core
parenta736d2ed5f570f818d71968cc17511e27972af6f (diff)
parent06826319c74f6b5a860431ad50af442de474228c (diff)
Merge pull request #13618 from jordan-woyak/cubeb-logging
AudioCommon/CubebUtils: Fix logged file name.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/AudioCommon/CubebUtils.cpp20
-rw-r--r--Source/Core/AudioCommon/CubebUtils.h1
2 files changed, 5 insertions, 16 deletions
diff --git a/Source/Core/AudioCommon/CubebUtils.cpp b/Source/Core/AudioCommon/CubebUtils.cpp
index 75b78f687f..6ad94f612c 100644
--- a/Source/Core/AudioCommon/CubebUtils.cpp
+++ b/Source/Core/AudioCommon/CubebUtils.cpp
@@ -4,20 +4,15 @@
#include "AudioCommon/CubebUtils.h"
#include <cstdarg>
-#include <cstddef>
#include <cstring>
-#include <thread>
+#include <string_view>
-#include "Common/Assert.h"
-#include "Common/CommonPaths.h"
#include "Common/Logging/Log.h"
#include "Common/Logging/LogManager.h"
#include "Common/StringUtil.h"
#include <cubeb/cubeb.h>
-static ptrdiff_t s_path_cutoff_point = 0;
-
static void LogCallback(const char* format, ...)
{
auto* instance = Common::Log::LogManager::GetInstance();
@@ -31,7 +26,10 @@ static void LogCallback(const char* format, ...)
va_list args;
va_start(args, format);
- const char* filename = va_arg(args, const char*) + s_path_cutoff_point;
+ const char* filename = va_arg(args, const char*);
+ const auto last_slash = std::string_view(filename).find_last_of("/\\");
+ if (last_slash != std::string_view::npos)
+ filename = filename + last_slash + 1;
const int lineno = va_arg(args, int);
const std::string adapted_format(StripWhitespace(format + strlen("%s:%d:")));
const std::string message = StringFromFormatV(adapted_format.c_str(), args);
@@ -58,14 +56,6 @@ std::shared_ptr<cubeb> CubebUtils::GetContext()
if (shared)
return shared;
- const char* filename = __FILE__;
- const char* match_point = strstr(filename, DIR_SEP "Source" DIR_SEP "Core" DIR_SEP);
- if (!match_point)
- match_point = strstr(filename, R"(\Source\Core\)");
- if (match_point)
- {
- s_path_cutoff_point = match_point - filename + strlen(DIR_SEP "Externals" DIR_SEP);
- }
if (cubeb_set_log_callback(CUBEB_LOG_NORMAL, LogCallback) != CUBEB_OK)
{
ERROR_LOG_FMT(AUDIO, "Error setting cubeb log callback");
diff --git a/Source/Core/AudioCommon/CubebUtils.h b/Source/Core/AudioCommon/CubebUtils.h
index f0effc2e8f..718c5f39c8 100644
--- a/Source/Core/AudioCommon/CubebUtils.h
+++ b/Source/Core/AudioCommon/CubebUtils.h
@@ -3,7 +3,6 @@
#pragma once
-#include <functional>
#include <memory>
struct cubeb;