New upstream version 22.0.3+dfsg1

This commit is contained in:
Sebastian Ramacher 2018-12-16 17:14:58 +01:00
parent 665f64a933
commit cdc9a9fc87
334 changed files with 14525 additions and 2639 deletions

View file

@ -24,9 +24,10 @@
#include <sstream>
#include <mutex>
#include <util/bmem.h>
#include <util/dstr.h>
#include <util/dstr.hpp>
#include <util/platform.h>
#include <util/profiler.hpp>
#include <util/cf-parser.h>
#include <obs-config.h>
#include <obs.hpp>
@ -77,8 +78,9 @@ string opt_starting_collection;
string opt_starting_profile;
string opt_starting_scene;
// AMD PowerXpress High Performance Flags
// GPU hint exports for AMD/NVIDIA laptops
#ifdef _MSC_VER
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 1;
extern "C" __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
#endif
@ -345,6 +347,7 @@ static void do_log(int log_level, const char *msg, va_list args, void *param)
}
#else
def_log_handler(log_level, msg, args2, nullptr);
va_end(args2);
#endif
if (log_level <= LOG_INFO || log_verbose) {
@ -366,6 +369,7 @@ bool OBSApp::InitGlobalConfigDefaults()
config_set_default_string(globalConfig, "General", "Language",
DEFAULT_LANG);
config_set_default_uint(globalConfig, "General", "MaxLogs", 10);
config_set_default_int(globalConfig, "General", "InfoIncrement", -1);
config_set_default_string(globalConfig, "General", "ProcessPriority",
"Normal");
config_set_default_bool(globalConfig, "General", "EnableAutoUpdates",
@ -418,9 +422,25 @@ bool OBSApp::InitGlobalConfigDefaults()
"CurrentTheme", "Dark");
}
config_set_default_bool(globalConfig, "BasicWindow",
"VerticalVolControl", false);
config_set_default_bool(globalConfig, "BasicWindow",
"MultiviewMouseSwitch", true);
config_set_default_bool(globalConfig, "BasicWindow",
"MultiviewDrawNames", true);
config_set_default_bool(globalConfig, "BasicWindow",
"MultiviewDrawAreas", true);
#ifdef _WIN32
uint32_t winver = GetWindowsVersion();
config_set_default_bool(globalConfig, "Audio", "DisableAudioDucking",
true);
config_set_default_bool(globalConfig, "General", "BrowserHWAccel",
winver > 0x601);
#endif
#ifdef __APPLE__
@ -588,6 +608,42 @@ static string GetSceneCollectionFileFromName(const char *name)
return outputPath;
}
bool OBSApp::UpdatePre22MultiviewLayout(const char *layout)
{
if (!layout)
return false;
if (astrcmpi(layout, "horizontaltop") == 0) {
config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
static_cast<int>(
MultiviewLayout::HORIZONTAL_TOP_8_SCENES));
return true;
}
if (astrcmpi(layout, "horizontalbottom") == 0) {
config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
static_cast<int>(
MultiviewLayout::HORIZONTAL_BOTTOM_8_SCENES));
return true;
}
if (astrcmpi(layout, "verticalleft") == 0) {
config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
static_cast<int>(
MultiviewLayout::VERTICAL_LEFT_8_SCENES));
return true;
}
if (astrcmpi(layout, "verticalright") == 0) {
config_set_int(globalConfig, "BasicWindow", "MultiviewLayout",
static_cast<int>(
MultiviewLayout::VERTICAL_RIGHT_8_SCENES));
return true;
}
return false;
}
bool OBSApp::InitGlobalConfig()
{
char path[512];
@ -653,6 +709,13 @@ bool OBSApp::InitGlobalConfig()
changed = true;
}
if (config_has_user_value(globalConfig, "BasicWindow",
"MultiviewLayout")) {
const char *layout = config_get_string(globalConfig,
"BasicWindow", "MultiviewLayout");
changed |= UpdatePre22MultiviewLayout(layout);
}
if (changed)
config_save_safe(globalConfig, "tmp", nullptr);
@ -727,6 +790,192 @@ bool OBSApp::InitLocale()
return true;
}
void OBSApp::AddExtraThemeColor(QPalette &pal, int group,
const char *name, uint32_t color)
{
std::function<void(QPalette::ColorGroup)> func;
#define DEF_PALETTE_ASSIGN(name) \
do { \
func = [&] (QPalette::ColorGroup group) \
{ \
pal.setColor(group, QPalette::name, \
QColor::fromRgb(color)); \
}; \
} while (false)
if (astrcmpi(name, "alternateBase") == 0) {
DEF_PALETTE_ASSIGN(AlternateBase);
} else if (astrcmpi(name, "base") == 0) {
DEF_PALETTE_ASSIGN(Base);
} else if (astrcmpi(name, "brightText") == 0) {
DEF_PALETTE_ASSIGN(BrightText);
} else if (astrcmpi(name, "button") == 0) {
DEF_PALETTE_ASSIGN(Button);
} else if (astrcmpi(name, "buttonText") == 0) {
DEF_PALETTE_ASSIGN(ButtonText);
} else if (astrcmpi(name, "brightText") == 0) {
DEF_PALETTE_ASSIGN(BrightText);
} else if (astrcmpi(name, "dark") == 0) {
DEF_PALETTE_ASSIGN(Dark);
} else if (astrcmpi(name, "highlight") == 0) {
DEF_PALETTE_ASSIGN(Highlight);
} else if (astrcmpi(name, "highlightedText") == 0) {
DEF_PALETTE_ASSIGN(HighlightedText);
} else if (astrcmpi(name, "light") == 0) {
DEF_PALETTE_ASSIGN(Light);
} else if (astrcmpi(name, "link") == 0) {
DEF_PALETTE_ASSIGN(Link);
} else if (astrcmpi(name, "linkVisited") == 0) {
DEF_PALETTE_ASSIGN(LinkVisited);
} else if (astrcmpi(name, "mid") == 0) {
DEF_PALETTE_ASSIGN(Mid);
} else if (astrcmpi(name, "midlight") == 0) {
DEF_PALETTE_ASSIGN(Midlight);
} else if (astrcmpi(name, "shadow") == 0) {
DEF_PALETTE_ASSIGN(Shadow);
} else if (astrcmpi(name, "text") == 0 ||
astrcmpi(name, "foreground") == 0) {
DEF_PALETTE_ASSIGN(Text);
} else if (astrcmpi(name, "toolTipBase") == 0) {
DEF_PALETTE_ASSIGN(ToolTipBase);
} else if (astrcmpi(name, "toolTipText") == 0) {
DEF_PALETTE_ASSIGN(ToolTipText);
} else if (astrcmpi(name, "windowText") == 0) {
DEF_PALETTE_ASSIGN(WindowText);
} else if (astrcmpi(name, "window") == 0 ||
astrcmpi(name, "background") == 0) {
DEF_PALETTE_ASSIGN(Window);
} else {
return;
}
#undef DEF_PALETTE_ASSIGN
switch (group) {
case QPalette::Disabled:
case QPalette::Active:
case QPalette::Inactive:
func((QPalette::ColorGroup)group);
break;
default:
func((QPalette::ColorGroup)QPalette::Disabled);
func((QPalette::ColorGroup)QPalette::Active);
func((QPalette::ColorGroup)QPalette::Inactive);
}
}
struct CFParser {
cf_parser cfp = {};
inline ~CFParser() {cf_parser_free(&cfp);}
inline operator cf_parser*() {return &cfp;}
inline cf_parser *operator->() {return &cfp;}
};
void OBSApp::ParseExtraThemeData(const char *path)
{
BPtr<char> data = os_quick_read_utf8_file(path);
QPalette pal = palette();
CFParser cfp;
int ret;
cf_parser_parse(cfp, data, path);
while (cf_go_to_token(cfp, "OBSTheme", nullptr)) {
if (!cf_next_token(cfp)) return;
int group = -1;
if (cf_token_is(cfp, ":")) {
ret = cf_next_token_should_be(cfp, ":", nullptr,
nullptr);
if (ret != PARSE_SUCCESS) continue;
if (!cf_next_token(cfp)) return;
if (cf_token_is(cfp, "disabled")) {
group = QPalette::Disabled;
} else if (cf_token_is(cfp, "active")) {
group = QPalette::Active;
} else if (cf_token_is(cfp, "inactive")) {
group = QPalette::Inactive;
} else {
continue;
}
if (!cf_next_token(cfp)) return;
}
if (!cf_token_is(cfp, "{")) continue;
for (;;) {
if (!cf_next_token(cfp)) return;
ret = cf_token_is_type(cfp, CFTOKEN_NAME, "name",
nullptr);
if (ret != PARSE_SUCCESS)
break;
DStr name;
dstr_copy_strref(name, &cfp->cur_token->str);
ret = cf_next_token_should_be(cfp, ":", ";",
nullptr);
if (ret != PARSE_SUCCESS) continue;
if (!cf_next_token(cfp)) return;
const char *array;
uint32_t color = 0;
if (cf_token_is(cfp, "#")) {
array = cfp->cur_token->str.array;
color = strtol(array + 1, nullptr, 16);
} else if (cf_token_is(cfp, "rgb")) {
ret = cf_next_token_should_be(cfp, "(", ";",
nullptr);
if (ret != PARSE_SUCCESS) continue;
if (!cf_next_token(cfp)) return;
array = cfp->cur_token->str.array;
color |= strtol(array, nullptr, 10) << 16;
ret = cf_next_token_should_be(cfp, ",", ";",
nullptr);
if (ret != PARSE_SUCCESS) continue;
if (!cf_next_token(cfp)) return;
array = cfp->cur_token->str.array;
color |= strtol(array, nullptr, 10) << 8;
ret = cf_next_token_should_be(cfp, ",", ";",
nullptr);
if (ret != PARSE_SUCCESS) continue;
if (!cf_next_token(cfp)) return;
array = cfp->cur_token->str.array;
color |= strtol(array, nullptr, 10);
} else if (cf_token_is(cfp, "white")) {
color = 0xFFFFFF;
} else if (cf_token_is(cfp, "black")) {
color = 0;
}
if (!cf_go_to_token(cfp, ";", nullptr)) return;
AddExtraThemeColor(pal, group, name->array, color);
}
ret = cf_token_should_be(cfp, "}", "}", nullptr);
if (ret != PARSE_SUCCESS) continue;
}
setPalette(pal);
}
bool OBSApp::SetTheme(std::string name, std::string path)
{
theme = name;
@ -748,12 +997,18 @@ bool OBSApp::SetTheme(std::string name, std::string path)
}
QString mpath = QString("file:///") + path.c_str();
setPalette(defaultPalette);
setStyleSheet(mpath);
ParseExtraThemeData(path.c_str());
emit StyleChanged();
return true;
}
bool OBSApp::InitTheme()
{
defaultPalette = palette();
const char *themeName = config_get_string(globalConfig, "General",
"CurrentTheme");
if (!themeName) {
@ -916,6 +1171,9 @@ void OBSApp::AppInit()
EnableOSXVSync(false);
#endif
enableHotkeysInFocus = !config_get_bool(globalConfig, "General",
"DisableHotkeysInFocus");
move_basic_to_profiles();
move_basic_to_scene_collections();
@ -942,6 +1200,18 @@ static bool StartupOBS(const char *locale, profiler_name_store_t *store)
return obs_startup(locale, path, store);
}
inline void OBSApp::ResetHotkeyState(bool inFocus)
{
obs_hotkey_enable_background_press(
inFocus || enableHotkeysInFocus);
}
void OBSApp::EnableInFocusHotkeys(bool enable)
{
enableHotkeysInFocus = enable;
ResetHotkeyState(applicationState() != Qt::ApplicationActive);
}
bool OBSApp::OBSInit()
{
ProfileScope("OBSApp::OBSInit");
@ -960,6 +1230,19 @@ bool OBSApp::OBSInit()
if (!StartupOBS(locale.c_str(), GetProfilerNameStore()))
return false;
#ifdef _WIN32
bool browserHWAccel = config_get_bool(globalConfig, "General",
"BrowserHWAccel");
obs_data_t *settings = obs_data_create();
obs_data_set_bool(settings, "BrowserHWAccel", browserHWAccel);
obs_apply_private_data(settings);
obs_data_release(settings);
blog(LOG_INFO, "Browser Hardware Acceleration: %s",
browserHWAccel ? "true" : "false");
#endif
blog(LOG_INFO, "Portable mode: %s",
portable_mode ? "true" : "false");
@ -973,13 +1256,12 @@ bool OBSApp::OBSInit()
mainWindow->OBSInit();
connect(this, &QGuiApplication::applicationStateChanged,
[](Qt::ApplicationState state)
[this](Qt::ApplicationState state)
{
obs_hotkey_enable_background_press(
ResetHotkeyState(
state != Qt::ApplicationActive);
});
obs_hotkey_enable_background_press(
applicationState() != Qt::ApplicationActive);
ResetHotkeyState(applicationState() != Qt::ApplicationActive);
return true;
} else {
return false;
@ -1002,7 +1284,9 @@ string OBSApp::GetVersionString() const
#ifdef _WIN32
if (sizeof(void*) == 8)
ver << "64bit, ";
ver << "64-bit, ";
else
ver << "32-bit, ";
ver << "windows)";
#elif __APPLE__
@ -1366,33 +1650,32 @@ static int run_program(fstream &logFile, int argc, char *argv[])
OBSApp program(argc, argv, profilerNameStore.get());
try {
bool created_log = false;
program.AppInit();
OBSTranslator translator;
create_log_file(logFile);
delete_oldest_file(false, "obs-studio/profiler_data");
OBSTranslator translator;
program.installTranslator(&translator);
#ifdef _WIN32
/* --------------------------------------- */
/* check and warn if already running */
bool cancel_launch = false;
bool already_running = false;
RunOnceMutex rom = GetRunOnceMutex(already_running);
if (already_running && !multi) {
blog(LOG_WARNING, "\n================================");
blog(LOG_WARNING, "Warning: OBS is already running!");
blog(LOG_WARNING, "================================\n");
if (!already_running) {
goto run;
}
if (!multi) {
QMessageBox::StandardButtons buttons(
QMessageBox::Yes | QMessageBox::Cancel);
QMessageBox mb(QMessageBox::Question,
QTStr("AlreadyRunning.Title"),
QTStr("AlreadyRunning.Text"),
buttons,
QTStr("AlreadyRunning.Text"), buttons,
nullptr);
mb.setButtonText(QMessageBox::Yes,
QTStr("AlreadyRunning.LaunchAnyway"));
@ -1401,23 +1684,37 @@ static int run_program(fstream &logFile, int argc, char *argv[])
QMessageBox::StandardButton button;
button = (QMessageBox::StandardButton)mb.exec();
if (button == QMessageBox::Cancel) {
blog(LOG_INFO, "User shut down the program "
"because OBS was already "
"running");
return 0;
}
cancel_launch = button == QMessageBox::Cancel;
}
blog(LOG_WARNING, "User is now running a secondary "
"instance of OBS!");
if (cancel_launch)
return 0;
} else if (already_running && multi) {
if (!created_log) {
create_log_file(logFile);
created_log = true;
}
if (multi) {
blog(LOG_INFO, "User enabled --multi flag and is now "
"running multiple instances of OBS.");
} else {
blog(LOG_WARNING, "================================");
blog(LOG_WARNING, "Warning: OBS is already running!");
blog(LOG_WARNING, "================================");
blog(LOG_WARNING, "User is now running multiple "
"instances of OBS!");
}
/* --------------------------------------- */
run:
#endif
if (!created_log) {
create_log_file(logFile);
created_log = true;
}
if (argc > 1) {
stringstream stor;
stor << argv[1];
@ -1887,6 +2184,7 @@ int main(int argc, char *argv[])
#endif
#ifdef _WIN32
obs_init_win32_crash_handler();
SetErrorMode(SEM_FAILCRITICALERRORS);
load_debug_privilege();
base_set_crash_handler(main_crash_handler, nullptr);