libobs: Fix lockup when an encode call fails

(This commit also modifies the UI, obs-ffmpeg, and obs-output modules)

Fixes a long-time regression where the program would lock up if an
encode call fails.  Shuts down all outputs associated with the failing
encoder and displays an error message to the user.

Ideally, it would be best if a more detailed error could be displayed to
the user about the nature of the error, though the primary problem is
the encoder errors are typically not something the user would be able to
understand.  The current message is a bit of a generic error message;
improvement is welcome.

Another suggestion is to try to have the encoder restart seamlessly,
though it would take a significant amount of work to be able to make it
do something like that properly, and it sort of assumes that encoder
failures are sporadic, which may not necessarily be the case with some
hardware encoders on some systems.  It may be better just to use another
encoder in that case.  For now, seamless restart is ruled out.
This commit is contained in:
jp9000
2019-05-17 01:51:12 -07:00
parent 19aca12025
commit 973d31b8c2
11 changed files with 136 additions and 27 deletions
+18 -2
View File
@@ -5189,9 +5189,10 @@ void OBSBasic::StreamStopping()
void OBSBasic::StreamingStop(int code, QString last_error)
{
const char *errorDescription;
const char *errorDescription = "";
DStr errorMessage;
bool use_last_error = false;
bool encode_error = false;
switch (code) {
case OBS_OUTPUT_BAD_PATH:
@@ -5207,6 +5208,10 @@ void OBSBasic::StreamingStop(int code, QString last_error)
errorDescription = Str("Output.ConnectFail.InvalidStream");
break;
case OBS_OUTPUT_ENCODE_ERROR:
encode_error = true;
break;
default:
case OBS_OUTPUT_ERROR:
use_last_error = true;
@@ -5245,10 +5250,16 @@ void OBSBasic::StreamingStop(int code, QString last_error)
blog(LOG_INFO, STREAMING_STOP);
if (code != OBS_OUTPUT_SUCCESS && isVisible()) {
if (encode_error) {
OBSMessageBox::information(this,
QTStr("Output.StreamEncodeError.Title"),
QTStr("Output.StreamEncodeError.Msg"));
} else if (code != OBS_OUTPUT_SUCCESS && isVisible()) {
OBSMessageBox::information(this,
QTStr("Output.ConnectFail.Title"),
QT_UTF8(errorMessage));
} else if (code != OBS_OUTPUT_SUCCESS && !isVisible()) {
SysTrayNotify(QT_UTF8(errorDescription), QSystemTrayIcon::Warning);
}
@@ -5373,6 +5384,11 @@ void OBSBasic::RecordingStop(int code, QString last_error)
QTStr("Output.RecordFail.Title"),
QTStr("Output.RecordFail.Unsupported"));
} else if (code == OBS_OUTPUT_ENCODE_ERROR && isVisible()) {
OBSMessageBox::warning(this,
QTStr("Output.RecordError.Title"),
QTStr("Output.RecordError.EncodeErrorMsg"));
} else if (code == OBS_OUTPUT_NO_SPACE && isVisible()) {
OBSMessageBox::warning(this,
QTStr("Output.RecordNoSpace.Title"),