summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:42:31 +0100
committerwm4 <wm4@nowhere>2013-11-23 21:42:31 +0100
commite901bb7c99e22e9986a62fc721757cb30ac7ceb9 (patch)
tree42d7214df70323cc619991c6b24078fb521592f8
parentf90e7ef7eafa0d5b1933f93bb116011cf1cb74b1 (diff)
downloadmpv-e901bb7c99e22e9986a62fc721757cb30ac7ceb9.tar.bz2
mpv-e901bb7c99e22e9986a62fc721757cb30ac7ceb9.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.
-rw-r--r--mpvcore/player/audio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mpvcore/player/audio.c b/mpvcore/player/audio.c
index 377b393dfd..042e6d66c3 100644
--- a/mpvcore/player/audio.c
+++ b/mpvcore/player/audio.c
@@ -367,6 +367,7 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
bool signal_eof = false;
bool partial_fill = false;
struct dec_audio *d_audio = mpctx->d_audio;
+ // Can't adjust the start of audio with spdif pass-through.
bool modifiable_audio_format = !(ao->format & AF_FORMAT_SPECIAL_MASK);
assert(d_audio);
@@ -406,7 +407,7 @@ 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 samples = (endpts - written_audio_pts(mpctx) + mpctx->audio_delay)
* ao->samplerate / opts->playback_speed;
if (playsize > samples) {