playtwitch won't show streamlink crash popup if the stream ended

This commit is contained in:
LordMZTE 2022-08-19 19:42:12 +02:00
parent c2bcbfb11c
commit a04f193729
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
2 changed files with 19 additions and 2 deletions

View file

@ -363,7 +363,10 @@ fn streamlinkCommunicateCb(
};
defer c.g_bytes_unref(stdout);
if (c.g_subprocess_get_exit_status(@ptrCast(*c.GSubprocess, source_object)) == 0) {
const exit_code = c.g_subprocess_get_exit_status(@ptrCast(*c.GSubprocess, source_object));
if (exit_code == 0) {
std.log.info("Streamlink exited with code 0.", .{});
c.gtk_window_close(data.window);
return;
}
@ -371,6 +374,20 @@ fn streamlinkCommunicateCb(
var len: usize = 0;
const stdout_data = @ptrCast([*c]const u8, c.g_bytes_get_data(stdout, &len));
// Streamlink exits with a nonzero code if the stream ends, but we don't
// want to count this as a crash.
if (std.mem.containsAtLeast(u8, stdout_data[0..len], 1, "Stream ended")) {
std.log.warn(
\\Streamlink exited with code {d}, but output contained
\\"Stream ended", not showing popup. Full output:
\\{s}
,
.{ exit_code, stdout_data[0..len] },
);
c.gtk_window_close(data.window);
return;
}
c.gtk_text_buffer_set_text(data.text_buf, stdout_data, @intCast(c_int, len));
c.gtk_widget_show(data.dialog);
}

View file

@ -3,7 +3,7 @@ const ffi = @import("ffi.zig");
const c = ffi.c;
const gui = @import("gui.zig");
pub const log = @import("glib-log").log(c, "playtwitch", 512);
pub const log = @import("glib-log").log(c, "playtwitch", 1024);
// glib handles level filtering
pub const log_level = .debug;