-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplugin-main.cpp
More file actions
109 lines (82 loc) · 3.04 KB
/
plugin-main.cpp
File metadata and controls
109 lines (82 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Plugin Name
Copyright (C) <Year> <Developer> <Email Address>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/
#include "CompareVersionStrings.h"
#include "config.h"
#include <atkaudio/atkaudio.h>
#include <chrono>
#include <obs-module.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <thread>
OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE(PLUGIN_NAME, "en-US")
const char* plugin_version = PLUGIN_VERSION;
const char* plugin_name = PLUGIN_NAME;
extern struct obs_source_info delay_filter;
extern struct obs_source_info device_io_filter;
extern struct obs_source_info device_io2_filter;
extern struct obs_source_info pluginhost_filter;
extern struct obs_source_info pluginhost2_filter;
extern struct obs_source_info source_mixer;
extern struct obs_source_info ph2helper_source_info;
void obs_log(int log_level, const char* format, ...);
#include <obs-frontend-api.h>
bool obs_module_load(void)
{
std::string obsCurrentVersion = obs_get_version_string();
std::string requiredVersion = PLUGIN_OBS_VERSION_REQUIRED;
if (CompareVersionStrings(obsCurrentVersion, requiredVersion) < 0)
{
obs_log(
LOG_ERROR,
"Incompatible OBS version: %s (required: %s)",
obsCurrentVersion.c_str(),
requiredVersion.c_str()
);
return false;
}
obs_log(LOG_INFO, "plugin loaded successfully (version %s)", plugin_version);
atk::create();
auto* mainWindow = (QObject*)obs_frontend_get_main_window();
atk::startMessagePump(mainWindow);
atk::update();
obs_register_source(&delay_filter);
obs_register_source(&device_io_filter);
obs_register_source(&device_io2_filter);
obs_register_source(&pluginhost2_filter);
obs_register_source(&pluginhost_filter);
obs_register_source(&source_mixer);
obs_register_source(&ph2helper_source_info);
return true;
}
void obs_module_unload(void)
{
obs_log(LOG_INFO, "Plugin unload started");
atk::destroy();
obs_log(LOG_INFO, "Plugin unloaded successfully");
}
void obs_log(int log_level, const char* format, ...)
{
size_t length = 4 + strlen(plugin_name) + strlen(format);
char* templ = (char*)malloc(length + 1);
snprintf(templ, length, "[%s] %s", plugin_name, format);
va_list args;
va_start(args, format);
blogva(log_level, templ, args);
va_end(args);
free(templ);
}