summaryrefslogtreecommitdiff
path: root/src/v4l.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/v4l.cc')
-rw-r--r--src/v4l.cc25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/v4l.cc b/src/v4l.cc
index 55b0397..246026f 100644
--- a/src/v4l.cc
+++ b/src/v4l.cc
@@ -54,6 +54,7 @@ extern "C" {
static bool isYUYV = false;
static V4L *v4l = NULL;
+static volatile bool running = true;
#define CLEAR(x) memset(&(x), 0, sizeof(x))
@@ -174,20 +175,10 @@ static void process_image(const void *p, int size)
if(isYUYV) {
toJpeg(70, (unsigned char*)p, 640, 480, (char**)&img, (size_t*)&img_size);
}
+
if(v4l) v4l->processImage(img, img_size);
- /*
- if (out_buf)
- fwrite(p, size, 1, stdout);
-
- fflush(stderr);
- fprintf(stderr, "[%d]", size);
- fflush(stdout);
-
- FILE *fp = fopen("out.jpg", "w");
- fwrite(p, size, 1, fp);
- fclose(fp);
- exit(0);
- */
+
+ //TODO: if(img != p) free(img);
}
static int read_frame(void)
@@ -281,7 +272,7 @@ static int read_frame(void)
return 1;
}
-static bool running = true;
+
static void mainloop(void)
{
unsigned int count;
@@ -799,16 +790,18 @@ V4L::V4L(QString device)
v4l = this; // Set global V4L object pointer.
+ running = true;
start();
}
V4L::~V4L()
{
+ running = false;
+ wait();
+
free(dev_name);
v4l = NULL; // Unset global V4L object pointer.
-
- // TODO: Stop thread.... somehow.
}
void V4L::run()