Memory leak fix and camera multithreading safety improvement (#239)

* memory leak fix and attempt at optimizing space

* camera rework

try to use better locking algorithm (MRSW lock on wikipedia)

* add time print (toggleable) and stuff

remove old mixed qr thingss from main

* remove the dumb 3 bytes saving

* remove useless time measure code

* forgot to close the stop event handle

* fix memory leak when loading icon from smdh

* fix entry path on folders

optimization using memcpy cause it to have the "/info.smdh" when the entry is a folder. simply remove that with a memset to 0.

Co-authored-by: Alex Taber <astronautlevel2@users.noreply.github.com>
This commit is contained in:
Théo B
2020-12-22 04:31:38 +01:00
committed by GitHub
parent 1c2e562dd6
commit 95ff2dd3ba
6 changed files with 315 additions and 238 deletions

View File

@@ -30,22 +30,24 @@
#include "common.h"
typedef struct {
u16 *camera_buffer;
C2D_Image image;
C3D_Tex *tex;
Handle mutex;
volatile bool finished;
volatile bool closed;
volatile bool success;
Handle cancel;
Handle started;
u16* camera_buffer;
Handle event_stop;
Thread cam_thread, ui_thread;
LightEvent event_cam_info, event_ui_info;
CondVar cond;
LightLock mut;
u32 num_readers_active;
bool writer_waiting;
bool writer_active;
bool any_update;
bool capturing;
struct quirc* context;
} qr_data;
bool init_qr(void);
void exit_qr(qr_data *data);
void take_picture(void);
#endif