From 5defc67991c3350efd2868d4d7dfc8bcedaae435 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 3 Sep 2014 21:44:54 -0700 Subject: [PATCH] Remove audio/video sync reference counter This is actually unnecessary now that there's a hard limit on the maximum offset in which audio can be inserted. This also assumes too much about the audio; it assumes audio is always on, where as with some devices (such as the elgato) audio is not on until the stream starts, and when the video has already incremented the counter. --- libobs/obs-internal.h | 19 ------------------- libobs/obs-source.c | 9 +-------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index 146197a9a..3fe9a9d00 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -294,25 +294,6 @@ struct obs_source { uint64_t last_frame_ts; uint64_t last_sys_timestamp; - /* - * audio/video timestamp synchronization reference counter - * - * if audio goes outside of expected timing bounds, this number will - * be deremented. - * - * if video goes outside of expecting timing bounds, this number will - * be incremented. - * - * when this reference counter is at 0, it means ths audio is - * synchronized with the video and it is safe to play. when it's not - * 0, it means that audio and video are desynchronized, and thus not - * safe to play. this just generally ensures synchronization between - * audio/video when timing somehow becomes 'reset'. - * - * XXX: may be an overly cautious check - */ - volatile long av_sync_ref; - /* audio */ bool audio_failed; struct resample_info sample_info; diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 861cce381..9816d5e9b 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -534,9 +534,7 @@ static inline void handle_ts_jump(obs_source_t source, uint64_t expected, source->context.name, diff, expected, ts); /* if has video, ignore audio data until reset */ - if (source->info.output_flags & OBS_SOURCE_ASYNC) - os_atomic_dec_long(&source->av_sync_ref); - else + if (!(source->info.output_flags & OBS_SOURCE_ASYNC)) reset_audio_timing(source, ts); } @@ -654,9 +652,6 @@ static void source_output_audio_line(obs_source_t source, source->next_audio_ts_min = in.timestamp + conv_frames_to_time(in.frames); - if (source->av_sync_ref != 0) - return; - in.timestamp += source->timing_adjust + source->sync_offset; in.volume = source->user_volume * source->present_volume * obs->audio.user_volume * obs->audio.present_volume; @@ -1514,7 +1509,6 @@ static bool ready_async_frame(obs_source_t source, uint64_t sys_time) /* account for timestamp invalidation */ if (frame_out_of_bounds(source, frame_time)) { source->last_frame_ts = next_frame->timestamp; - os_atomic_inc_long(&source->av_sync_ref); } else { frame_offset = frame_time - source->last_frame_ts; source->last_frame_ts += frame_offset; @@ -1534,7 +1528,6 @@ static bool ready_async_frame(obs_source_t source, uint64_t sys_time) if ((next_frame->timestamp - frame_time) > MAX_TIMESTAMP_JUMP) { source->last_frame_ts = next_frame->timestamp - frame_offset; - os_atomic_inc_long(&source->av_sync_ref); } frame_time = next_frame->timestamp;