Exemple #1
0
static void *video_thread(void *param)
{
	struct video_output *video = param;
	uint64_t cur_time = os_gettime_ns();

	while (os_event_try(video->stop_event) == EAGAIN) {
		/* wait half a frame, update frame */
		cur_time += (video->frame_time/2);
		os_sleepto_ns(cur_time);

		video->cur_video_time = cur_time;
		os_event_signal(video->update_event);

		/* wait another half a frame, swap and output frames */
		cur_time += (video->frame_time/2);
		os_sleepto_ns(cur_time);

		pthread_mutex_lock(&video->data_mutex);

		video_swapframes(video);
		video_output_cur_frame(video);

		pthread_mutex_unlock(&video->data_mutex);
	}

	return NULL;
}
static void *video_thread(void *param)
{
	struct video_output *video = param;

	os_set_thread_name("video-io: video thread");

	const char *video_thread_name =
		profile_store_name(obs_get_profiler_name_store(),
				"video_thread(%s)", video->info.name);

	while (os_sem_wait(video->update_semaphore) == 0) {
		if (video->stop)
			break;

		profile_start(video_thread_name);
		while (!video->stop && !video_output_cur_frame(video)) {
			video->total_frames++;
		}

		video->total_frames++;
		profile_end(video_thread_name);

		profile_reenable_thread();
	}

	return NULL;
}