diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-12 17:47:13 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-12 17:47:13 +0200 |
commit | 9416704d1b8d3ebdf1dbab14918287cd5f17d351 (patch) | |
tree | 9df8dadd1879eefec906e7cc980e6964485c637f /test/grab.c | |
parent | e62d6a31e8a38a01c529a51b0582ac16373424c1 (diff) | |
download | uca-9416704d1b8d3ebdf1dbab14918287cd5f17d351.tar.gz uca-9416704d1b8d3ebdf1dbab14918287cd5f17d351.tar.bz2 uca-9416704d1b8d3ebdf1dbab14918287cd5f17d351.tar.xz uca-9416704d1b8d3ebdf1dbab14918287cd5f17d351.zip |
Start and stop recording in a loop
Diffstat (limited to 'test/grab.c')
-rw-r--r-- | test/grab.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/test/grab.c b/test/grab.c index 56b7cd6..7b5062f 100644 --- a/test/grab.c +++ b/test/grab.c @@ -57,25 +57,32 @@ int main(int argc, char *argv[]) const int pixel_size = bits == 8 ? 1 : 2; gpointer buffer = g_malloc0(width * height * pixel_size); - uca_camera_start_recording(camera, &error); - gchar filename[FILENAME_MAX]; - gint counter = 0; - - while (counter < 20) { - g_print(" grab frame ... "); - uca_camera_grab(camera, &buffer, &error); - if (error != NULL) - break; - g_print("done\n"); - - snprintf(filename, FILENAME_MAX, "frame-%08i.raw", counter++); - FILE *fp = fopen(filename, "wb"); - fwrite(buffer, width*height, pixel_size, fp); - fclose(fp); + + for (int i = 0; i < 2; i++) { + gint counter = 0; + g_print("Start recording\n"); + uca_camera_start_recording(camera, &error); + g_assert_no_error(error); + + while (counter < 4) { + g_print(" grab frame ... "); + uca_camera_grab(camera, &buffer, &error); + if (error != NULL) + break; + g_print("done\n"); + + snprintf(filename, FILENAME_MAX, "frame-%08i.raw", counter++); + FILE *fp = fopen(filename, "wb"); + fwrite(buffer, width*height, pixel_size, fp); + fclose(fp); + } + + g_print("Start recording\n"); + uca_camera_stop_recording(camera, &error); + g_assert_no_error(error); } - uca_camera_stop_recording(camera, &error); g_object_unref(camera); g_free(buffer); |