summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/mplayer.c b/mplayer.c
index 7030a50da0..c13f56a143 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -2464,10 +2464,16 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
bool did_retry = false;
double written_pts;
double bps = ao->bps / opts->playback_speed;
+ bool hrseek = mpctx->hrseek_active; // audio only hrseek
+ mpctx->hrseek_active = false;
while (1) {
written_pts = written_audio_pts(mpctx);
- double ptsdiff = written_pts - mpctx->sh_video->pts - mpctx->delay
- - audio_delay;
+ double ptsdiff;
+ if (hrseek)
+ ptsdiff = written_pts - mpctx->hrseek_pts;
+ else
+ ptsdiff = written_pts - mpctx->sh_video->pts - mpctx->delay
+ - audio_delay;
bytes = ptsdiff * bps;
bytes -= bytes % (ao->channels * af_fmt2bits(ao->format) / 8);
@@ -2506,6 +2512,9 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
if (res < 0)
return res;
}
+ if (hrseek)
+ // Don't add silence in audio-only case even if position is too late
+ return 0;
int fillbyte = 0;
if ((ao->format & AF_FORMAT_SIGN_MASK) == AF_FORMAT_US)
fillbyte = 0x80;
@@ -2557,11 +2566,16 @@ static int fill_audio_out_buffers(struct MPContext *mpctx)
current_module = "decode_audio";
t = GetTimer();
- if (!opts->initial_audio_sync || !modifiable_audio_format)
+ // Coming here with hrseek_active still set means audio-only
+ if (!mpctx->sh_video)
+ mpctx->syncing_audio = false;
+ if (!opts->initial_audio_sync || !modifiable_audio_format) {
mpctx->syncing_audio = false;
+ mpctx->hrseek_active = false;
+ }
int res;
- if (mpctx->syncing_audio && mpctx->sh_video)
+ if (mpctx->syncing_audio || mpctx->hrseek_active)
res = audio_start_sync(mpctx, playsize);
else
res = decode_audio(sh_audio, &ao->buffer, playsize);