Fix video reset and apply new video settings
This allows the changing of bideo settings without having to completely reset all graphics data. Will recreate internal output/conversion buffers and such and reset the main preview.
This commit is contained in:
@@ -495,7 +495,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="errorText">
|
||||
<widget class="QLabel" name="videoMsg">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -508,6 +508,9 @@
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@@ -51,13 +51,11 @@ void OBSBasic::OBSInit()
|
||||
|
||||
if (!obs_startup())
|
||||
throw "Failed to initialize libobs";
|
||||
if (!InitGraphics())
|
||||
throw "Failed to initialize graphics";
|
||||
if (!InitAudio())
|
||||
if (!ResetVideo())
|
||||
throw "Failed to initialize video";
|
||||
if (!ResetAudio())
|
||||
throw "Failed to initialize audio";
|
||||
|
||||
obs_add_draw_callback(OBSBasic::RenderMain, this);
|
||||
|
||||
signal_handler_connect(obs_signalhandler(), "source-add",
|
||||
OBSBasic::SourceAdded, this);
|
||||
signal_handler_connect(obs_signalhandler(), "source-remove",
|
||||
@@ -278,7 +276,7 @@ void OBSBasic::RenderMain(void *data, uint32_t cx, uint32_t cy)
|
||||
|
||||
/* Main class functions */
|
||||
|
||||
bool OBSBasic::InitGraphics()
|
||||
bool OBSBasic::ResetVideo()
|
||||
{
|
||||
struct obs_video_info ovi;
|
||||
|
||||
@@ -306,10 +304,14 @@ bool OBSBasic::InitGraphics()
|
||||
ovi.window_width = size.width();
|
||||
ovi.window_height = size.height();
|
||||
|
||||
return obs_reset_video(&ovi);
|
||||
if (!obs_reset_video(&ovi))
|
||||
return false;
|
||||
|
||||
obs_add_draw_callback(OBSBasic::RenderMain, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OBSBasic::InitAudio()
|
||||
bool OBSBasic::ResetAudio()
|
||||
{
|
||||
/* TODO: load audio settings from config */
|
||||
struct audio_output_info ai;
|
||||
|
@@ -60,8 +60,9 @@ private:
|
||||
void AddSource(obs_scene_t scene, const char *id);
|
||||
void AddSourcePopupMenu(const QPoint &pos);
|
||||
|
||||
bool InitGraphics();
|
||||
bool InitAudio();
|
||||
public:
|
||||
bool ResetVideo();
|
||||
bool ResetAudio();
|
||||
|
||||
void NewProject();
|
||||
void SaveProject();
|
||||
|
@@ -15,6 +15,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
#include <obs.hpp>
|
||||
#include <util/util.hpp>
|
||||
#include <util/lexer.h>
|
||||
#include <sstream>
|
||||
@@ -25,6 +26,7 @@
|
||||
#include "obs-app.hpp"
|
||||
#include "platform.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "window-basic-main.hpp"
|
||||
#include "window-basic-settings.hpp"
|
||||
|
||||
#include <util/platform.h>
|
||||
@@ -205,6 +207,8 @@ void OBSBasicSettings::LoadResolutionLists()
|
||||
|
||||
ResetDownscales(cx, cy);
|
||||
|
||||
ui->baseResolution->lineEdit()->setText(ResString(cx, cy).c_str());
|
||||
|
||||
cx = config_get_uint(GetGlobalConfig(), "Video", "OutputCX");
|
||||
cy = config_get_uint(GetGlobalConfig(), "Video", "OutputCY");
|
||||
|
||||
@@ -254,6 +258,11 @@ void OBSBasicSettings::LoadVideoSettings()
|
||||
{
|
||||
loading = true;
|
||||
|
||||
if (video_output_active(obs_video())) {
|
||||
ui->videoPage->setEnabled(false);
|
||||
ui->videoMsg->setText(QTStr("Settings.Video.CurrentlyActive"));
|
||||
}
|
||||
|
||||
LoadRendererList();
|
||||
LoadResolutionLists();
|
||||
LoadFPSData();
|
||||
@@ -316,6 +325,10 @@ void OBSBasicSettings::SaveVideoSettings()
|
||||
config_set_uint(GetGlobalConfig(), "Video", "FPSInt", fpsInteger);
|
||||
config_set_uint(GetGlobalConfig(), "Video", "FPSNum", fpsNumerator);
|
||||
config_set_uint(GetGlobalConfig(), "Video", "FPSDen", fpsDenominator);
|
||||
|
||||
OBSBasic *window = qobject_cast<OBSBasic*>(parent());
|
||||
if (window)
|
||||
window->ResetVideo();
|
||||
}
|
||||
|
||||
void OBSBasicSettings::SaveSettings()
|
||||
@@ -400,12 +413,12 @@ static bool ValidResolutions(Ui::OBSBasicSettings *ui)
|
||||
if (!ConvertResText(QT_TO_UTF8(baseRes), cx, cy) ||
|
||||
!ConvertResText(QT_TO_UTF8(outputRes), cx, cy)) {
|
||||
|
||||
ui->errorText->setText(
|
||||
ui->videoMsg->setText(
|
||||
QTStr("Settings.Video.InvalidResolution"));
|
||||
return false;
|
||||
}
|
||||
|
||||
ui->errorText->setText("");
|
||||
ui->videoMsg->setText("");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -421,8 +434,7 @@ void OBSBasicSettings::on_renderer_currentIndexChanged(int index)
|
||||
{
|
||||
if (!loading) {
|
||||
videoChanged = true;
|
||||
ui->errorText->setText(
|
||||
QTStr("Settings.ProgramRestart"));
|
||||
ui->videoMsg->setText(QTStr("Settings.ProgramRestart"));
|
||||
}
|
||||
|
||||
UNUSED_PARAMETER(index);
|
||||
|
Reference in New Issue
Block a user