Hi.
I compile and run ‘01_video_encode’ sample from ‘tegra multimedia api’ samples in nonblocking mode.
I count number of events by it’s type. Code as below:
static void *encoder_pollthread_fcn(void *arg)
{
context_t *ctx = (context_t *) arg;
v4l2_ctrl_video_device_poll devicepoll;
cout << "Starting Device Poll Thread " << endl;
memset(&devicepoll, 0, sizeof(v4l2_ctrl_video_device_poll));
// wait here until you are signalled to issue the Poll call.
// Check if the abort status is set , if so exit
// Else issue the Poll on the decoder and block.
// When the Poll returns, signal the encoder thread to continue.
while (!ctx->got_error && !ctx->enc->isInError())
{
sem_wait(&ctx->pollthread_sema);
if (ctx->got_eos)
{
cout << "Got eos, exiting poll thread \n";
return NULL;
}
devicepoll.req_events = POLLIN | POLLOUT | POLLERR | POLLPRI;
// This call shall wait in the v4l2 encoder library
ctx->enc->DevicePoll(&devicepoll);
uint16_t resp = devicepoll.resp_events;
uint16_t in = resp & POLLIN;
uint16_t out = resp & POLLOUT;
uint16_t inout = (in || out) ? 1 : 0;
uint16_t zero = (resp == 0) ? 1 : 0;
uint16_t other = (in || out || zero) ? 0 : 1;
ctx->pollall++;
if(in) {
ctx->pollin++;
}
if(out) {
ctx->pollout++;
}
if(zero) {
ctx->pollzero++;
}
if(inout)
ctx->pollinout++;
if(other) {
ctx->pollother++;
}
// We can check the devicepoll.resp_events bitmask to see which events are set.
sem_post(&ctx->encoderthread_sema);
}
return NULL;
}
// at the end of main
cout << "App run was successful" << endl;
cout <<
"in: " << ctx.pollin <<
" out: " << ctx.pollout <<
" zero: " << ctx.pollzero <<
" inout: " << ctx.pollinout <<
" other: " << ctx.pollother <<
" all: " << ctx.pollall << endl;
I run compiled programm with params:
./video_encode out.yuv 640 360 H264 out.h264 --blocking-mode 0
Samples output :
in: 1366 out: 982 zero: 1254 inout: 1367 other: 0 all: 2621
in: 1321 out: 915 zero: 4142 inout: 1325 other: 0 all: 5467
in: 1295 out: 872 zero: 1270 inout: 1296 other: 0 all: 2566
in: 1346 out: 1014 zero: 1831 inout: 1350 other: 0 all: 3181
My question is why zero event is occured often?