[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / platform / android / utils / AndroidInterfaceForCLog.cpp
blob46b35f915c350f8e408cf6e2466cb13347910066
1 /*
2 * Copyright (C) 2020 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "platform/android/utils/AndroidInterfaceForCLog.h"
11 #include "CompileInfo.h"
13 #include <dlfcn.h>
14 #include <spdlog/sinks/android_sink.h>
15 #include <spdlog/sinks/dist_sink.h>
17 // On some Android platforms debug logging is deactivated.
18 // We try to activate debug logging for our app via function "__android_log_set_minimum_priority" from "/system/lib/liblog.so".
19 // The function is defined in API level 30 (Android 11) as:
20 // int32_t __android_log_set_minimum_priority(int32_t priority);
21 void ActivateAndroidDebugLogging()
23 void* libHandle = dlopen("liblog.so", RTLD_LAZY);
24 if (libHandle)
26 void* funcPtr = dlsym(libHandle, "__android_log_set_minimum_priority");
27 if (funcPtr)
29 typedef int32_t (*android_log_set_minimum_priority_func)(int32_t);
30 reinterpret_cast<android_log_set_minimum_priority_func>(funcPtr)(ANDROID_LOG_DEBUG);
32 dlclose(libHandle);
36 std::unique_ptr<IPlatformLog> IPlatformLog::CreatePlatformLog()
38 ActivateAndroidDebugLogging();
39 return std::make_unique<CAndroidInterfaceForCLog>();
42 void CAndroidInterfaceForCLog::AddSinks(
43 std::shared_ptr<spdlog::sinks::dist_sink<std::mutex>> distributionSink) const
45 distributionSink->add_sink(
46 std::make_shared<spdlog::sinks::android_sink_st>(CCompileInfo::GetAppName()));