Skip to content

Commit be1ec3f

Browse files
committed
vcap/testcard: exit if frames=<n>q
added optional exit if testcard run with frames= limit
1 parent 2d72943 commit be1ec3f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/video_capture/testcard.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ struct testcard_state {
120120
struct audio_len_pattern apattern;
121121
int audio_frequency;
122122
long long capture_frames;
123+
bool quit_after_capture_frames;
123124

124125
char **tiles_data;
125126
int tiles_cnt_horizontal;
@@ -585,8 +586,12 @@ static int vidcap_testcard_init(struct vidcap_params *params, void **state)
585586
} else if (strstr(tmp, "afrequency=") == tmp) {
586587
s->audio_frequency = atoi(strchr(tmp, '=') + 1);
587588
} else if (IS_KEY_PREFIX(tmp, "frames")) {
589+
char *endptr = NULL;
588590
s->capture_frames =
589-
strtoll(strchr(tmp, '=') + 1, NULL, 0);
591+
strtoll(strchr(tmp, '=') + 1, &endptr, 0);
592+
if (*endptr == 'q') {
593+
s->quit_after_capture_frames = true;
594+
}
590595
} else {
591596
fprintf(stderr, "[testcard] Unknown option: %s\n", tmp);
592597
goto error;
@@ -707,6 +712,9 @@ static struct video_frame *vidcap_testcard_grab(void *arg, struct audio_frame **
707712
{
708713
struct testcard_state *state = arg;
709714
if (state->video_frames == state->capture_frames) {
715+
if (state->quit_after_capture_frames) {
716+
exit_uv(0);
717+
}
710718
return NULL;
711719
}
712720
time_ns_t curr_time = 0;

0 commit comments

Comments
 (0)