static inline void video_output_cur_frame(struct video_output *video) { if (!video->cur_frame.data[0]) return; pthread_mutex_lock(&video->input_mutex); for (size_t i = 0; i < video->inputs.num; i++) { struct video_input *input = video->inputs.array+i; if (scale_video_output(input, &video->cur_frame)) input->callback(input->param, &video->cur_frame); } pthread_mutex_unlock(&video->input_mutex); }
static inline bool video_output_cur_frame(struct video_output *video) { struct cached_frame_info *frame_info; bool complete; /* -------------------------------- */ pthread_mutex_lock(&video->data_mutex); frame_info = &video->cache[video->first_added]; pthread_mutex_unlock(&video->data_mutex); /* -------------------------------- */ pthread_mutex_lock(&video->input_mutex); for (size_t i = 0; i < video->inputs.num; i++) { struct video_input *input = video->inputs.array+i; struct video_data frame = frame_info->frame; if (scale_video_output(input, &frame)) input->callback(input->param, &frame); } pthread_mutex_unlock(&video->input_mutex); /* -------------------------------- */ pthread_mutex_lock(&video->data_mutex); frame_info->frame.timestamp += video->frame_time; complete = --frame_info->count == 0; if (complete) { if (++video->first_added == video->info.cache_size) video->first_added = 0; if (++video->available_frames == video->info.cache_size) video->last_added = video->first_added; } pthread_mutex_unlock(&video->data_mutex); /* -------------------------------- */ return complete; }