diff --git a/include/camera.h b/include/camera.h index 1527b4a..9fa53bf 100644 --- a/include/camera.h +++ b/include/camera.h @@ -35,6 +35,7 @@ typedef struct { C3D_Tex *tex; Handle mutex; volatile bool finished; + volatile bool closed; volatile bool success; Handle cancel; Handle started; @@ -47,4 +48,4 @@ bool init_qr(void); void exit_qr(qr_data *data); void take_picture(void); -#endif \ No newline at end of file +#endif diff --git a/source/camera.c b/source/camera.c index b3d4ab6..6b78b00 100644 --- a/source/camera.c +++ b/source/camera.c @@ -150,7 +150,8 @@ void update_ui(void *arg) if (data->finished) { end_frame(); - } + break; + } C2D_DrawImageAt(data->image, 0.0f, 0.0f, 0.4f, NULL, 1.0f, 1.0f); @@ -158,6 +159,7 @@ void update_ui(void *arg) draw_text_center(GFX_BOTTOM, 4, 0.5, 0.5, 0.5, colors[COLOR_WHITE], "Press \uE005 To Quit"); end_frame(); } + data->closed = true; } bool start_capture_cam(qr_data *data) @@ -306,6 +308,7 @@ bool init_qr(void) qr_data *data = calloc(1, sizeof(qr_data)); data->capturing = false; data->finished = false; + data->closed = false; svcCreateEvent(&data->started, RESET_STICKY); data->context = quirc_new(); @@ -321,7 +324,8 @@ bool init_qr(void) while (!data->finished) update_qr(data); bool success = data->success; + while (!data->closed) svcSleepThread(1000000); free(data); return success; -} \ No newline at end of file +}