mirror of
https://github.com/mpv-player/mpv
synced 2025-02-03 05:31:34 +00:00
screenshot: report success to caller
Matters only to API callers, but still nice to have.
This commit is contained in:
parent
b0a04b8dea
commit
d7ed3ba473
@ -93,7 +93,7 @@ static char *stripext(void *talloc_ctx, const char *s)
|
|||||||
return talloc_asprintf(talloc_ctx, "%.*s", (int)(end - s), s);
|
return talloc_asprintf(talloc_ctx, "%.*s", (int)(end - s), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_screenshot(struct MPContext *mpctx, struct mp_image *img,
|
static bool write_screenshot(struct MPContext *mpctx, struct mp_image *img,
|
||||||
const char *filename, struct image_writer_opts *opts)
|
const char *filename, struct image_writer_opts *opts)
|
||||||
{
|
{
|
||||||
screenshot_ctx *ctx = mpctx->screenshot_ctx;
|
screenshot_ctx *ctx = mpctx->screenshot_ctx;
|
||||||
@ -113,6 +113,7 @@ static void write_screenshot(struct MPContext *mpctx, struct mp_image *img,
|
|||||||
} else {
|
} else {
|
||||||
screenshot_msg(ctx, MSGL_ERR, "Error writing screenshot!");
|
screenshot_msg(ctx, MSGL_ERR, "Error writing screenshot!");
|
||||||
}
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -418,9 +419,10 @@ void cmd_screenshot_to_file(void *p)
|
|||||||
ctx->osd = old_osd;
|
ctx->osd = old_osd;
|
||||||
if (!image) {
|
if (!image) {
|
||||||
screenshot_msg(ctx, MSGL_ERR, "Taking screenshot failed.");
|
screenshot_msg(ctx, MSGL_ERR, "Taking screenshot failed.");
|
||||||
|
cmd->success = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
write_screenshot(mpctx, image, filename, &opts);
|
cmd->success = write_screenshot(mpctx, image, filename, &opts);
|
||||||
talloc_free(image);
|
talloc_free(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,6 +453,8 @@ void cmd_screenshot(void *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd->success = false;
|
||||||
|
|
||||||
ctx->osd = osd;
|
ctx->osd = osd;
|
||||||
|
|
||||||
struct image_writer_opts *opts = mpctx->opts->screenshot_image_opts;
|
struct image_writer_opts *opts = mpctx->opts->screenshot_image_opts;
|
||||||
@ -461,7 +465,7 @@ void cmd_screenshot(void *p)
|
|||||||
if (image) {
|
if (image) {
|
||||||
char *filename = gen_fname(ctx, image_writer_file_ext(opts));
|
char *filename = gen_fname(ctx, image_writer_file_ext(opts));
|
||||||
if (filename)
|
if (filename)
|
||||||
write_screenshot(mpctx, image, filename, NULL);
|
cmd->success = write_screenshot(mpctx, image, filename, NULL);
|
||||||
talloc_free(filename);
|
talloc_free(filename);
|
||||||
} else {
|
} else {
|
||||||
screenshot_msg(ctx, MSGL_ERR, "Taking screenshot failed.");
|
screenshot_msg(ctx, MSGL_ERR, "Taking screenshot failed.");
|
||||||
|
Loading…
Reference in New Issue
Block a user