mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +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;
|
||||
}
|
||||
|
||||
usleep(33000);
|
||||
// Wait until main thread is ready to receive the next frame.
|
||||
uvg_sem_wait(args->available_input_slots);
|
||||
args->img_in = frame_in;
|
||||
args->retval = retval;
|
||||
// Unlock main_thread_mutex to notify main thread that the new img_in
|
||||
// and retval have been placed to args.
|
||||
uvg_sem_post(args->filled_input_slots);
|
||||
if (uvg_sem_trywait(args->available_input_slots) == 0) {
|
||||
args->img_in = frame_in;
|
||||
args->retval = retval;
|
||||
// Unlock main_thread_mutex to notify main thread that the new img_in
|
||||
// and retval have been placed to args.
|
||||
uvg_sem_post(args->filled_input_slots);
|
||||
|
||||
frame_in = NULL;
|
||||
frame_in = NULL;
|
||||
}
|
||||
else {
|
||||
args->api->picture_free(frame_in);
|
||||
frame_in = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
|
|
@ -132,6 +132,11 @@ static INLINE void uvg_sem_wait(uvg_sem_t *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)
|
||||
{
|
||||
sem_post(sem);
|
||||
|
|
Loading…
Reference in a new issue