aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/main.c b/main.c
index 5ea236e..c6f4458 100644
--- a/main.c
+++ b/main.c
@@ -52,20 +52,20 @@
* used and still enable video device to decode with the hardware. */
#define RESULT_EXTRA_BUFFER_CNT 2
-static const int event_type[] = {
+static const int event_types[] = {
V4L2_EVENT_EOS,
V4L2_EVENT_SOURCE_CHANGE,
};
static int subscribe_for_events(int fd)
{
- int size_event = sizeof(event_type) / sizeof(event_type[0]);
+ int size_event = sizeof(event_types) / sizeof(event_types[0]);
struct v4l2_event_subscription sub;
int i, ret;
for (i = 0; i < size_event; i++) {
memset(&sub, 0, sizeof(sub));
- sub.type = event_type[i];
+ sub.type = event_types[i];
ret = ioctl(fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
if (ret < 0)
err("cannot subscribe for event type %d (%s)",
@@ -89,10 +89,10 @@ static int handle_v4l_events(struct video *vid)
switch (event.type) {
case V4L2_EVENT_EOS:
- dbg("event eos");
+ info("EOS reached");
break;
case V4L2_EVENT_SOURCE_CHANGE:
- dbg("event source change");
+ info("Source changed");
break;
default:
dbg("unknown event type occurred %x", event.type);
@@ -215,7 +215,7 @@ void *input_thread_func(void *args)
ret = input_read(i, n, &used, &fs);
if (ret)
- continue;
+ err("cannot read from input file");
if (vid->total_encoded >= i->num_frames_to_save) {
i->finish = 1;
@@ -261,6 +261,9 @@ void *main_thread_func(void *args)
revents = pfd.revents;
+ if (revents & POLLPRI)
+ handle_v4l_events(vid);
+
if (revents & (POLLIN | POLLRDNORM)) {
unsigned int bytesused;
@@ -302,6 +305,9 @@ void *main_thread_func(void *args)
next_event:
if (revents & (POLLOUT | POLLWRNORM)) {
+ if (i->finish)
+ continue;
+
dbg("dequeuing output buffer");
ret = video_dequeue_output(i, &n);
@@ -315,11 +321,6 @@ next_event:
dbg("dequeued output buffer %d", n);
}
-
- if (revents & POLLPRI) {
- dbg("v4l2 event");
- handle_v4l_events(vid);
- }
}
return NULL;