summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:42:31 +0100
committerwm4 <wm4@nowhere>2013-12-01 19:31:29 +0100
commitfc465f1f2622c313cacd9513de54669228bb3709 (patch)
tree7f17888cc0ee4ccaff118f3a6ab6dab8d55439c1
parentbf39906cd5e5b6945133c948afc23b5f08f0c5c8 (diff)
downloadmpv-fc465f1f2622c313cacd9513de54669228bb3709.tar.bz2
mpv-fc465f1f2622c313cacd9513de54669228bb3709.tar.xz
audio: respect --end/--length with spdif passthrough
In theory, we can't really do this, because we don't know when a spdif frame ends. Spdif transports compressed audio through audio setups that were originally designed for PCM only (which includes the audio filter chain, the AO API, most audio output APIs, etc.), and to reach this goal, spdif pretends to be PCM. Compressed data frames are padded with zeros, until a certain data rate is reached, which corresponds to a pseudo-PCM format with 2 bytes per sample and 2 channels at 48000 Hz. Of course an actual spdif frame is significantly larger than a frame of the PCM format it pretends to be, so cutting audio data on frame boundaries (as according to the pseudo-PCM format) merely yields an incomplete and broken frame, not audio that plays for the desired duration. However, sending an incomplete frame might still be much better than the current behavior, which simply ignores --end/--length (but still lets the video end at the exact end time). Should this result in trouble with real spdif receivers, this commit probably has to be reverted. Conflicts: mpvcore/player/audio.c
-rw-r--r--mpvcore/mplayer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c
index c81741066b..0fe620827f 100644
--- a/mpvcore/mplayer.c
+++ b/mpvcore/mplayer.c
@@ -2278,6 +2278,7 @@ static int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
bool audio_eof = false;
bool partial_fill = false;
sh_audio_t * const sh_audio = mpctx->sh_audio;
+ // Can't adjust the start of audio with spdif pass-through.
bool modifiable_audio_format = !(ao->format & AF_FORMAT_SPECIAL_MASK);
int unitsize = ao->channels.num * af_fmt2bits(ao->format) / 8;
@@ -2316,7 +2317,7 @@ static int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
audio_eof = true;
}
- if (endpts != MP_NOPTS_VALUE && modifiable_audio_format) {
+ if (endpts != MP_NOPTS_VALUE) {
double bytes = (endpts - written_audio_pts(mpctx) + mpctx->audio_delay)
* ao->bps / opts->playback_speed;
if (playsize > bytes) {