mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Throw frames out if the encoder is not ready
This commit is contained in:
parent
bdb606b20b
commit
e10071b9b7
|
@ -270,15 +270,21 @@ static void* input_read_thread(void* in_args)
|
||||||
frame_in->interlacing = args->encoder->cfg.source_scan_type;
|
frame_in->interlacing = args->encoder->cfg.source_scan_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usleep(33000);
|
||||||
// Wait until main thread is ready to receive the next frame.
|
// Wait until main thread is ready to receive the next frame.
|
||||||
uvg_sem_wait(args->available_input_slots);
|
if (uvg_sem_trywait(args->available_input_slots) == 0) {
|
||||||
args->img_in = frame_in;
|
args->img_in = frame_in;
|
||||||
args->retval = retval;
|
args->retval = retval;
|
||||||
// Unlock main_thread_mutex to notify main thread that the new img_in
|
// Unlock main_thread_mutex to notify main thread that the new img_in
|
||||||
// and retval have been placed to args.
|
// and retval have been placed to args.
|
||||||
uvg_sem_post(args->filled_input_slots);
|
uvg_sem_post(args->filled_input_slots);
|
||||||
|
|
||||||
frame_in = NULL;
|
frame_in = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
args->api->picture_free(frame_in);
|
||||||
|
frame_in = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -132,6 +132,11 @@ static INLINE void uvg_sem_wait(uvg_sem_t *sem)
|
||||||
sem_wait(sem);
|
sem_wait(sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INLINE int uvg_sem_trywait(uvg_sem_t *sem)
|
||||||
|
{
|
||||||
|
return sem_trywait(sem);
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE void uvg_sem_post(uvg_sem_t *sem)
|
static INLINE void uvg_sem_post(uvg_sem_t *sem)
|
||||||
{
|
{
|
||||||
sem_post(sem);
|
sem_post(sem);
|
||||||
|
|
Loading…
Reference in a new issue