We should make decisions based on the real sync type. This also simplifies
the code.
Signed-off-by: Marton Balint <cus@passwd.hu>
... | ... |
@@ -1146,8 +1146,7 @@ static double compute_target_delay(double delay, VideoState *is) |
1146 | 1146 |
double sync_threshold, diff; |
1147 | 1147 |
|
1148 | 1148 |
/* update delay to follow master synchronisation source */ |
1149 |
- if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || |
|
1150 |
- is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { |
|
1149 |
+ if (get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER) { |
|
1151 | 1150 |
/* if video is slave, we try to correct big delays by |
1152 | 1151 |
duplicating or deleting a frame */ |
1153 | 1152 |
diff = get_video_clock(is) - get_master_clock(is); |
... | ... |
@@ -1264,7 +1263,7 @@ retry: |
1264 | 1264 |
if (is->pictq_size > 1) { |
1265 | 1265 |
VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE]; |
1266 | 1266 |
duration = nextvp->pts - vp->pts; |
1267 |
- if((framedrop>0 || (framedrop && is->av_sync_type != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){ |
|
1267 |
+ if((framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){ |
|
1268 | 1268 |
is->frame_drops_late++; |
1269 | 1269 |
pictq_next_picture(is); |
1270 | 1270 |
goto retry; |
... | ... |
@@ -1582,8 +1581,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, int64_t *pts, AVPacke |
1582 | 1582 |
*pts = 0; |
1583 | 1583 |
} |
1584 | 1584 |
|
1585 |
- if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK) && |
|
1586 |
- (framedrop>0 || (framedrop && is->av_sync_type != AV_SYNC_VIDEO_MASTER))) { |
|
1585 |
+ if (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) { |
|
1587 | 1586 |
SDL_LockMutex(is->pictq_mutex); |
1588 | 1587 |
if (is->frame_last_pts != AV_NOPTS_VALUE && *pts) { |
1589 | 1588 |
double clockdiff = get_video_clock(is) - get_master_clock(is); |
... | ... |
@@ -1941,8 +1939,7 @@ static int synchronize_audio(VideoState *is, int nb_samples) |
1941 | 1941 |
int wanted_nb_samples = nb_samples; |
1942 | 1942 |
|
1943 | 1943 |
/* if not master, then we try to remove or add samples to correct the clock */ |
1944 |
- if (((is->av_sync_type == AV_SYNC_VIDEO_MASTER && is->video_st) || |
|
1945 |
- is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK)) { |
|
1944 |
+ if (get_master_sync_type(is) != AV_SYNC_AUDIO_MASTER) { |
|
1946 | 1945 |
double diff, avg_diff; |
1947 | 1946 |
int min_nb_samples, max_nb_samples; |
1948 | 1947 |
|