diff options
author | wm4 <wm4@nowhere> | 2015-03-10 15:17:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-03-10 15:17:57 +0100 |
commit | da46a13c6b50417df1edd5e0768aeb9880c537db (patch) | |
tree | 357150d4d7d69c17164dbc9d1ca4c5094842b6bf /player/audio.c | |
parent | 5f8b060ec2dde7d0ff5468a5b7499851c22b756d (diff) | |
download | mpv-da46a13c6b50417df1edd5e0768aeb9880c537db.tar.bz2 mpv-da46a13c6b50417df1edd5e0768aeb9880c537db.tar.xz |
audio: cut audio with spdif too on playback restart
When playback is started after seeking or opening a file, we need to
make sure audio and video line up exactly. This is done by cutting or
padding the audio stream to start on the video PTS.
This does not quite work with spdif: audio is compressed data, within a
spdif frame. There is no way to cut the audio "in between" the frames.
Cutting between the frames would just produce broken spdif packets, and
who knows how receivers will react to this (play noise?). But we still
can cut it in frame boundaries.
Unfortunately, we also insert 0 data for "silence" - we probably
shouldn't do this. Chances are the receiver will switch to PCM or so.
But for now this will have to do.
Note that this could be simplified somewhat, as soon as we work with
frames. See previous commit.
Diffstat (limited to 'player/audio.c')
-rw-r--r-- | player/audio.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/player/audio.c b/player/audio.c index 306df086ab..b66952c53c 100644 --- a/player/audio.c +++ b/player/audio.c @@ -403,8 +403,7 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip) ao_get_format(mpctx->ao, &out_format); double play_samplerate = out_format.rate / opts->playback_speed; - bool is_pcm = !AF_FORMAT_IS_SPECIAL(out_format.format); // no spdif - if (!opts->initial_audio_sync || !is_pcm) { + if (!opts->initial_audio_sync) { mpctx->audio_status = STATUS_FILLING; return true; } @@ -438,7 +437,8 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip) return true; } - *skip = -ptsdiff * play_samplerate; + int align = af_format_sample_alignment(out_format.format); + *skip = (-ptsdiff * play_samplerate) / align * align; return true; } |