mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-15 13:53:19 -05:00
Add helpers for logging, translation, and synchronized data access
This commit is contained in:
16
src/utils/log-helper.hpp
Normal file
16
src/utils/log-helper.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <util/base.h>
|
||||
|
||||
namespace advss {
|
||||
|
||||
bool VerboseLoggingEnabled();
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "[adv-ss] " msg, ##__VA_ARGS__)
|
||||
#define vblog(level, msg, ...) \
|
||||
do { \
|
||||
if (VerboseLoggingEnabled()) { \
|
||||
blog(level, msg, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
} // namespace advss
|
||||
18
src/utils/obs-module-helper.cpp
Normal file
18
src/utils/obs-module-helper.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "switcher-data.hpp"
|
||||
|
||||
const char *obs_module_text(const char *text)
|
||||
{
|
||||
if (!advss::switcher) {
|
||||
return "";
|
||||
}
|
||||
return advss::switcher->Translate(text);
|
||||
}
|
||||
|
||||
obs_module_t *obs_current_module()
|
||||
{
|
||||
if (!advss::switcher) {
|
||||
return nullptr;
|
||||
}
|
||||
return advss::switcher->GetModule();
|
||||
}
|
||||
5
src/utils/obs-module-helper.hpp
Normal file
5
src/utils/obs-module-helper.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include <obs-module.h>
|
||||
|
||||
const char *obs_module_text(const char *text);
|
||||
obs_module_t *obs_current_module();
|
||||
11
src/utils/sync-helper.cpp
Normal file
11
src/utils/sync-helper.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "sync-helper.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
std::mutex *GetSwitcherMutex();
|
||||
std::lock_guard<std::mutex> LockContext()
|
||||
{
|
||||
return std::lock_guard<std::mutex>(*GetSwitcherMutex());
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
8
src/utils/sync-helper.hpp
Normal file
8
src/utils/sync-helper.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <mutex>
|
||||
|
||||
namespace advss {
|
||||
|
||||
[[nodiscard]] std::lock_guard<std::mutex> LockContext();
|
||||
|
||||
} // namespace advss
|
||||
Reference in New Issue
Block a user