Skip to content

Commit 30f61c5

Browse files
committed
vcap/screen_avf: simplified a bit
used asnprintf
1 parent b388cf3 commit 30f61c5

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/video_capture/screen_avf.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file video_capture/screen_avf.c
33
* @author Martin Pulec <martin.pulec@cesnet.cz>
44
*
5-
* screen capture using vcap/avfoundation (proxy)
5+
* this screen capture is a wrapper/proxy around vcap/avfoundation
66
*/
77
/*
88
* Copyright (c) 2026 CESNET, zájmové sdružení právnických osob
@@ -118,11 +118,9 @@ vidcap_screen_avf_init(struct vidcap_params *params, void **state)
118118
}
119119

120120
// add "d=100" to initialize first screen cap av foundation device
121-
const size_t orig_len = strlen(fmt);
122-
const size_t new_len = orig_len + 50;
123-
char *new_fmt = malloc(new_len);
124-
(void) snprintf(new_fmt, new_len, "%s%sd=%u", fmt,
125-
orig_len == 0 ? "" : ":", AVF_SCR_CAP_OFF);
121+
char *new_fmt = nullptr;
122+
asprintf(&new_fmt, "%s%sd=%u", fmt, strlen(fmt) == 0 ? "" : ":",
123+
AVF_SCR_CAP_OFF);
126124
vidcap_params_replace_fmt(params, new_fmt);
127125
free(new_fmt);
128126
return vidcap_avfoundation_info.init(params, state);

0 commit comments

Comments
 (0)