diff --git a/libobs/util/config-file.c b/libobs/util/config-file.c
index 923b9a0930765c2f554a7b37fea8a7df9237c83f..be9e772794b3adbc70253206848d84bc4e077f40 100644
--- a/libobs/util/config-file.c
+++ b/libobs/util/config-file.c
@@ -542,3 +542,56 @@ double config_get_double(config_t config, const char *section,
return 0.0;
}
+
+const char *config_get_default_string(config_t config, const char *section,
+ const char *name)
+{
+ struct config_item *item;
+
+ item = config_find_item(&config->defaults, section, name);
+ if (!item)
+ return NULL;
+
+ return item->value;
+}
+
+int64_t config_get_default_int(config_t config, const char *section,
+ const char *name)
+{
+ const char *value = config_get_default_string(config, section, name);
+ if (value)
+ return strtoll(value, NULL, 10);
+
+ return 0;
+}
+
+uint64_t config_get_default_uint(config_t config, const char *section,
+ const char *name)
+{
+ const char *value = config_get_default_string(config, section, name);
+ if (value)
+ return strtoul(value, NULL, 10);
+
+ return 0;
+}
+
+bool config_get_default_bool(config_t config, const char *section,
+ const char *name)
+{
+ const char *value = config_get_default_string(config, section, name);
+ if (value)
+ return astrcmpi(value, "true") == 0 ||
+ strtoul(value, NULL, 10);
+
+ return false;
+}
+
+double config_get_default_double(config_t config, const char *section,
+ const char *name)
+{
+ const char *value = config_get_default_string(config, section, name);
+ if (value)
+ return strtod(value, NULL);
+
+ return 0.0;
+}
diff --git a/libobs/util/config-file.h b/libobs/util/config-file.h
index abf9277e99422b8249d9a422eaa90ce92e269b28..6a2e4cff7a9620d6714d223a6d9e26de8fe2578b 100644
--- a/libobs/util/config-file.h
+++ b/libobs/util/config-file.h
@@ -81,6 +81,17 @@ EXPORT bool config_get_bool(config_t config, const char *section,
EXPORT double config_get_double(config_t config, const char *section,
const char *name);
+EXPORT const char *config_get_default_string(config_t config,
+ const char *section, const char *name);
+EXPORT int64_t config_get_default_int(config_t config, const char *section,
+ const char *name);
+EXPORT uint64_t config_get_default_uint(config_t config, const char *section,
+ const char *name);
+EXPORT bool config_get_default_bool(config_t config, const char *section,
+ const char *name);
+EXPORT double config_get_default_double(config_t config, const char *section,
+ const char *name);
+
#ifdef __cplusplus
}
#endif
diff --git a/obs/forms/OBSBasicSettings.ui b/obs/forms/OBSBasicSettings.ui
index 9400fcb7ae3c040da9a82d898802c9421f71baff..09813ce2e225a362a9362cf402c1508f145713fb 100644
--- a/obs/forms/OBSBasicSettings.ui
+++ b/obs/forms/OBSBasicSettings.ui
@@ -77,7 +77,7 @@
-
- 0
+ 3
@@ -269,26 +269,6 @@
-
-
-
- 60
-
-
- 20000
-
-
- 700
-
-
-
- -
-
-
- Audio Buffering Time (milliseconds):
-
-
-
- -
color: rgb(255, 0, 4);
diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp
index d0ad0de1b639aca7f31665216e3b9c3c0757be93..463a28e42f34b4c548d5ba794f7103e0c3944f61 100644
--- a/obs/window-basic-main.cpp
+++ b/obs/window-basic-main.cpp
@@ -85,6 +85,17 @@ bool OBSBasic::InitBasicConfigDefaults()
"Stereo");
config_set_default_uint (basicConfig, "Audio", "BufferingTime", 1000);
+ config_set_default_string(basicConfig, "Audio", "DesktopDevice1",
+ "default");
+ config_set_default_string(basicConfig, "Audio", "DesktopDevice2",
+ "disabled");
+ config_set_default_string(basicConfig, "Audio", "AuxDevice1",
+ "default");
+ config_set_default_string(basicConfig, "Audio", "AuxDevice2",
+ "disabled");
+ config_set_default_string(basicConfig, "Audio", "AuxDevice3",
+ "disabled");
+
return true;
}
@@ -408,6 +419,11 @@ bool OBSBasic::ResetAudio()
return obs_reset_audio(&ai);
}
+bool OBSBasic::ResetAudioDevices()
+{
+ return false;
+}
+
void OBSBasic::ResizePreview(uint32_t cx, uint32_t cy)
{
double targetAspect, baseAspect;
diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp
index 6442b514f6f3ff03bb9140c5a1ba47d546e7d930..5feac7adf1eb91953cfc080ecc14f711ea8342c5 100644
--- a/obs/window-basic-main.hpp
+++ b/obs/window-basic-main.hpp
@@ -82,6 +82,8 @@ public:
bool ResetVideo();
bool ResetAudio();
+ bool ResetAudioDevices();
+
void NewProject();
void SaveProject();
void LoadProject();
diff --git a/obs/window-basic-settings.cpp b/obs/window-basic-settings.cpp
index 02ab763f4d9b024f8ce5893a8ac271c51c25481e..5fddec79b0d847f752b6a466ffab05763a842e8e 100644
--- a/obs/window-basic-settings.cpp
+++ b/obs/window-basic-settings.cpp
@@ -1,5 +1,5 @@
/******************************************************************************
- Copyright (C) 2013 by Hugh Bailey
+ Copyright (C) 2013-2014 by Hugh Bailey
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
@@ -78,6 +78,24 @@ static bool ConvertResText(const char *res, uint32_t &cx, uint32_t &cy)
return true;
}
+void OBSBasicSettings::HookWidget(QWidget *widget, const char *signal,
+ const char *slot)
+{
+ QObject::connect(widget, signal, this, slot);
+}
+
+#define COMBO_CHANGED SIGNAL(currentIndexChanged(int))
+#define COMBO_CHANGED SIGNAL(currentIndexChanged(int))
+#define CBEDIT_CHANGED SIGNAL(editTextChanged(const QString &))
+#define SCROLL_CHANGED SIGNAL(valueChanged(int))
+
+#define GENERAL_CHANGED SLOT(GeneralChanged())
+#define AUDIO_CHANGED SLOT(AudioChangedRestart())
+#define AUDIO_RESTART SLOT(AudioChanged())
+#define VIDEO_RESTART SLOT(VideoChangedRestart())
+#define VIDEO_RES SLOT(VideoChangedResolution())
+#define VIDEO_CHANGED SLOT(VideoChanged())
+
OBSBasicSettings::OBSBasicSettings(QWidget *parent)
: QDialog (parent),
main (qobject_cast(parent)),
@@ -98,6 +116,26 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
if (localeIni.Open(path.c_str(), CONFIG_OPEN_EXISTING) != 0)
throw "Could not open locale.ini";
+ HookWidget(ui->language, COMBO_CHANGED, GENERAL_CHANGED);
+ HookWidget(ui->channelSetup, COMBO_CHANGED, AUDIO_RESTART);
+ HookWidget(ui->sampleRate, COMBO_CHANGED, AUDIO_RESTART);
+ HookWidget(ui->desktopAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED);
+ HookWidget(ui->desktopAudioDevice2, COMBO_CHANGED, AUDIO_CHANGED);
+ HookWidget(ui->auxAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED);
+ HookWidget(ui->auxAudioDevice2, COMBO_CHANGED, AUDIO_CHANGED);
+ HookWidget(ui->auxAudioDevice3, COMBO_CHANGED, AUDIO_CHANGED);
+ HookWidget(ui->renderer, COMBO_CHANGED, VIDEO_RESTART);
+ HookWidget(ui->adapter, COMBO_CHANGED, VIDEO_RESTART);
+ HookWidget(ui->baseResolution, CBEDIT_CHANGED, VIDEO_RES);
+ HookWidget(ui->outputResolution, CBEDIT_CHANGED, VIDEO_RES);
+ HookWidget(ui->downscaleFilter, COMBO_CHANGED, VIDEO_CHANGED);
+ HookWidget(ui->fpsType, COMBO_CHANGED, VIDEO_CHANGED);
+ HookWidget(ui->fpsCommon, COMBO_CHANGED, VIDEO_CHANGED);
+ HookWidget(ui->fpsInteger, SCROLL_CHANGED, VIDEO_CHANGED);
+ HookWidget(ui->fpsInteger, SCROLL_CHANGED, VIDEO_CHANGED);
+ HookWidget(ui->fpsNumerator, SCROLL_CHANGED, VIDEO_CHANGED);
+ HookWidget(ui->fpsDenominator, SCROLL_CHANGED, VIDEO_CHANGED);
+
LoadSettings(false);
}
@@ -278,9 +316,12 @@ static inline void LoadListValue(QComboBox *widget, const char *text,
widget->addItem(QT_UTF8(text), QT_UTF8(val));
}
-static void LoadListValues(QComboBox *widget, obs_property_t prop)
+void OBSBasicSettings::LoadListValues(QComboBox *widget, obs_property_t prop,
+ const char *configName)
{
size_t count = obs_property_list_item_count(prop);
+ const char *deviceId = config_get_string(main->Config(), "Audio",
+ configName);
widget->addItem(QTStr("Disabled"), "disabled");
@@ -289,6 +330,16 @@ static void LoadListValues(QComboBox *widget, obs_property_t prop)
const char *val = obs_property_list_item_value(prop, i);
LoadListValue(widget, name, val);
}
+
+ int idx = widget->findData(QVariant(QT_UTF8(deviceId)));
+ if (idx == -1) {
+ deviceId = config_get_default_string(main->Config(), "Audio",
+ configName);
+ idx = widget->findData(QVariant(QT_UTF8(deviceId)));
+ }
+
+ if (idx != -1)
+ widget->setCurrentIndex(idx);
}
void OBSBasicSettings::LoadAudioDevices()
@@ -310,14 +361,14 @@ void OBSBasicSettings::LoadAudioDevices()
obs_properties_t output_props = obs_source_properties(
OBS_SOURCE_TYPE_INPUT, output_id, App()->GetLocale());
- obs_property_t inputs = obs_properties_get(input_props, "device_id");
+ obs_property_t inputs = obs_properties_get(input_props, "device_id");
obs_property_t outputs = obs_properties_get(output_props, "device_id");
- LoadListValues(ui->desktopAudioDevice1, outputs);
- LoadListValues(ui->desktopAudioDevice2, outputs);
- LoadListValues(ui->auxAudioDevice1, inputs);
- LoadListValues(ui->auxAudioDevice2, inputs);
- LoadListValues(ui->auxAudioDevice3, inputs);
+ LoadListValues(ui->desktopAudioDevice1, outputs, "DesktopDevice1");
+ LoadListValues(ui->desktopAudioDevice2, outputs, "DesktopDevice2");
+ LoadListValues(ui->auxAudioDevice1, inputs, "AuxDevice1");
+ LoadListValues(ui->auxAudioDevice2, inputs, "AuxDevice2");
+ LoadListValues(ui->auxAudioDevice3, inputs, "AuxDevice3");
obs_properties_destroy(input_props);
obs_properties_destroy(output_props);
@@ -329,8 +380,6 @@ void OBSBasicSettings::LoadAudioSettings()
"SampleRate");
const char *speakers = config_get_string(main->Config(), "Audio",
"ChannelSetup");
- uint32_t bufferingTime = config_get_uint(main->Config(), "Audio",
- "BufferingTime");
loading = true;
@@ -351,8 +400,6 @@ void OBSBasicSettings::LoadAudioSettings()
else
ui->channelSetup->setCurrentIndex(1);
- ui->audioBufferingTime->setValue(bufferingTime);
-
LoadAudioDevices();
loading = false;
@@ -417,11 +464,24 @@ void OBSBasicSettings::SaveVideoSettings()
main->ResetVideo();
}
+static inline QString GetComboData(QComboBox *combo)
+{
+ int idx = combo->currentIndex();
+ if (idx == -1)
+ return QString();
+
+ return combo->itemData(idx).toString();
+}
+
void OBSBasicSettings::SaveAudioSettings()
{
- QString sampleRateStr = ui->sampleRate->currentText();
- int channelSetupIdx = ui->channelSetup->currentIndex();
- int bufferingTime = ui->audioBufferingTime->value();
+ QString sampleRateStr = ui->sampleRate->currentText();
+ int channelSetupIdx = ui->channelSetup->currentIndex();
+ QString desktopDevice1 = GetComboData(ui->desktopAudioDevice1);
+ QString desktopDevice2 = GetComboData(ui->desktopAudioDevice2);
+ QString auxDevice1 = GetComboData(ui->auxAudioDevice1);
+ QString auxDevice2 = GetComboData(ui->auxAudioDevice2);
+ QString auxDevice3 = GetComboData(ui->auxAudioDevice2);
const char *channelSetup;
if (channelSetupIdx == 0)
@@ -438,8 +498,17 @@ void OBSBasicSettings::SaveAudioSettings()
config_set_uint(main->Config(), "Audio", "SampleRate", sampleRate);
config_set_string(main->Config(), "Audio", "ChannelSetup",
channelSetup);
- config_set_uint(main->Config(), "Audio", "BufferingTime",
- bufferingTime);
+
+ config_set_string(main->Config(), "Audio", "DesktopDevice1",
+ QT_TO_UTF8(desktopDevice1));
+ config_set_string(main->Config(), "Audio", "DesktopDevice2",
+ QT_TO_UTF8(desktopDevice2));
+ config_set_string(main->Config(), "Audio", "AuxDevice1",
+ QT_TO_UTF8(auxDevice1));
+ config_set_string(main->Config(), "Audio", "AuxDevice2",
+ QT_TO_UTF8(auxDevice2));
+ config_set_string(main->Config(), "Audio", "AuxDevice3",
+ QT_TO_UTF8(auxDevice3));
}
void OBSBasicSettings::SaveSettings()
@@ -534,112 +603,53 @@ static bool ValidResolutions(Ui::OBSBasicSettings *ui)
return true;
}
-void OBSBasicSettings::on_language_currentIndexChanged(int index)
+void OBSBasicSettings::on_baseResolution_editTextChanged(const QString &text)
{
- if (!loading)
- generalChanged = true;
+ if (!loading && ValidResolutions(ui.get())) {
+ QString baseResolution = ui->baseResolution->currentText();
+ uint32_t cx, cy;
- UNUSED_PARAMETER(index);
+ ConvertResText(QT_TO_UTF8(baseResolution), cx, cy);
+ ResetDownscales(cx, cy);
+ }
}
-void OBSBasicSettings::on_sampleRate_currentIndexChanged(int index)
+void OBSBasicSettings::GeneralChanged()
{
- if (!loading) {
- audioChanged = true;
- ui->audioMsg->setText(QTStr("Settings.ProgramRestart"));
- }
-
- UNUSED_PARAMETER(index);
+ if (!loading)
+ generalChanged = true;
}
-void OBSBasicSettings::on_channelSetup_currentIndexChanged(int index)
+void OBSBasicSettings::AudioChanged()
{
- if (!loading) {
+ if (!loading)
audioChanged = true;
- ui->audioMsg->setText(QTStr("Settings.ProgramRestart"));
- }
-
- UNUSED_PARAMETER(index);
}
-void OBSBasicSettings::on_audioBufferingTime_valueChanged(int value)
+void OBSBasicSettings::AudioChangedRestart()
{
if (!loading) {
audioChanged = true;
ui->audioMsg->setText(QTStr("Settings.ProgramRestart"));
}
-
- UNUSED_PARAMETER(value);
}
-void OBSBasicSettings::on_renderer_currentIndexChanged(int index)
+void OBSBasicSettings::VideoChangedRestart()
{
if (!loading) {
videoChanged = true;
ui->videoMsg->setText(QTStr("Settings.ProgramRestart"));
}
-
- UNUSED_PARAMETER(index);
-}
-
-void OBSBasicSettings::on_fpsType_currentIndexChanged(int index)
-{
- if (!loading)
- videoChanged = true;
-
- UNUSED_PARAMETER(index);
-}
-
-void OBSBasicSettings::on_baseResolution_editTextChanged(const QString &text)
-{
- if (!loading && ValidResolutions(ui.get())) {
- QString baseResolution = ui->baseResolution->currentText();
- uint32_t cx, cy;
-
- ConvertResText(QT_TO_UTF8(baseResolution), cx, cy);
- ResetDownscales(cx, cy);
- videoChanged = true;
- }
-
- UNUSED_PARAMETER(text);
}
-void OBSBasicSettings::on_outputResolution_editTextChanged(const QString &text)
+void OBSBasicSettings::VideoChangedResolution()
{
if (!loading && ValidResolutions(ui.get()))
videoChanged = true;
-
- UNUSED_PARAMETER(text);
}
-void OBSBasicSettings::on_fpsCommon_currentIndexChanged(int index)
+void OBSBasicSettings::VideoChanged()
{
if (!loading)
videoChanged = true;
-
- UNUSED_PARAMETER(index);
-}
-
-void OBSBasicSettings::on_fpsInteger_valueChanged(int value)
-{
- if (!loading)
- videoChanged = true;
-
- UNUSED_PARAMETER(value);
-}
-
-void OBSBasicSettings::on_fpsNumerator_valueChanged(int value)
-{
- if (!loading)
- videoChanged = true;
-
- UNUSED_PARAMETER(value);
-}
-
-void OBSBasicSettings::on_fpsDenominator_valueChanged(int value)
-{
- if (!loading)
- videoChanged = true;
-
- UNUSED_PARAMETER(value);
}
diff --git a/obs/window-basic-settings.hpp b/obs/window-basic-settings.hpp
index 707906724522d16d722829c3b843006a6cff8737..e21725d4307594be0eaa396fd8399980d662a83e 100644
--- a/obs/window-basic-settings.hpp
+++ b/obs/window-basic-settings.hpp
@@ -21,8 +21,11 @@
#include
#include
+#include
+
class OBSBasic;
class QAbstractButton;
+class QComboBox;
#include "ui_OBSBasicSettings.h"
@@ -55,6 +58,8 @@ private:
videoChanged = false;
}
+ void HookWidget(QWidget *widget, const char *signal, const char *slot);
+
bool QueryChanges();
void LoadGeneralSettings();
@@ -67,6 +72,8 @@ private:
void LoadLanguageList();
/* audio */
+ void LoadListValues(QComboBox *widget, obs_property_t prop,
+ const char *configName);
void LoadAudioDevices();
/* video */
@@ -85,20 +92,14 @@ private slots:
void on_listWidget_itemSelectionChanged();
void on_buttonBox_clicked(QAbstractButton *button);
- void on_language_currentIndexChanged(int index);
-
- void on_sampleRate_currentIndexChanged(int index);
- void on_channelSetup_currentIndexChanged(int index);
- void on_audioBufferingTime_valueChanged(int index);
-
- void on_renderer_currentIndexChanged(int index);
- void on_fpsType_currentIndexChanged(int index);
void on_baseResolution_editTextChanged(const QString &text);
- void on_outputResolution_editTextChanged(const QString &text);
- void on_fpsCommon_currentIndexChanged(int index);
- void on_fpsInteger_valueChanged(int value);
- void on_fpsNumerator_valueChanged(int value);
- void on_fpsDenominator_valueChanged(int value);
+
+ void GeneralChanged();
+ void AudioChanged();
+ void AudioChangedRestart();
+ void VideoChanged();
+ void VideoChangedResolution();
+ void VideoChangedRestart();
protected:
virtual void closeEvent(QCloseEvent *event);