mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-18 22:14:20 +01:00
Report recorder errors
Stop scrcpy on recorder errors. It was previously indirectly stopped by the demuxer, which failed to push packets to a recorder in error. Report it directly instead: - it avoids to wait for the next demuxer call; - it will allow to open the target file from a separate thread and stop immediately on any I/O error.
This commit is contained in:
@@ -161,6 +161,9 @@ event_loop(struct scrcpy *s) {
|
||||
case SC_EVENT_DEMUXER_ERROR:
|
||||
LOGE("Demuxer error");
|
||||
return SCRCPY_EXIT_FAILURE;
|
||||
case SC_EVENT_RECORDER_ERROR:
|
||||
LOGE("Recorder error");
|
||||
return SCRCPY_EXIT_FAILURE;
|
||||
case SDL_QUIT:
|
||||
LOGD("User requested to quit");
|
||||
return SCRCPY_EXIT_SUCCESS;
|
||||
@@ -198,6 +201,17 @@ await_for_server(bool *connected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
sc_recorder_on_ended(struct sc_recorder *recorder, bool success,
|
||||
void *userdata) {
|
||||
(void) recorder;
|
||||
(void) userdata;
|
||||
|
||||
if (!success) {
|
||||
PUSH_EVENT(SC_EVENT_RECORDER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sc_demuxer_on_ended(struct sc_demuxer *demuxer, bool eos, void *userdata) {
|
||||
(void) demuxer;
|
||||
@@ -379,10 +393,12 @@ scrcpy(struct scrcpy_options *options) {
|
||||
|
||||
struct sc_recorder *rec = NULL;
|
||||
if (options->record_filename) {
|
||||
if (!sc_recorder_init(&s->recorder,
|
||||
options->record_filename,
|
||||
options->record_format,
|
||||
info->frame_size)) {
|
||||
static const struct sc_recorder_callbacks recorder_cbs = {
|
||||
.on_ended = sc_recorder_on_ended,
|
||||
};
|
||||
if (!sc_recorder_init(&s->recorder, options->record_filename,
|
||||
options->record_format, info->frame_size,
|
||||
&recorder_cbs, NULL)) {
|
||||
goto end;
|
||||
}
|
||||
rec = &s->recorder;
|
||||
|
||||
Reference in New Issue
Block a user