diff options
author | wm4 <wm4@nowhere> | 2014-11-10 22:01:23 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-10 22:02:05 +0100 |
commit | 5fd8a1e04c725329435e3bead5f11ee3ffb9f1c1 (patch) | |
tree | a3a3ae0ac6ee87449ed780604e55da6dca2f34f2 /player/audio.c | |
parent | 46d6fb9dc1a820b58dd3ffcc155195aea6bb0bd1 (diff) | |
download | mpv-5fd8a1e04c725329435e3bead5f11ee3ffb9f1c1.tar.bz2 mpv-5fd8a1e04c725329435e3bead5f11ee3ffb9f1c1.tar.xz |
audio: make decoders output refcounted frames
This rewrites the audio decode loop to some degree. Audio filters don't
do refcounted frames yet, so af.c contains a hacky "emulation".
Remove some of the weird heuristic-heavy code in dec_audio.c. Instead of
estimating how much audio we need to filter, we always filter full
frames. Maybe this should be adjusted later: in case filtering increases
the volume of the audio data, we should try not to buffer too much
filter output by reducing the input that is fed at once.
For ad_spdif.c and ad_mpg123.c, we don't avoid extra copying yet - it
doesn't seem worth the trouble.
Diffstat (limited to 'player/audio.c')
-rw-r--r-- | player/audio.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/player/audio.c b/player/audio.c index 413cbf4a32..e3dbe6577c 100644 --- a/player/audio.c +++ b/player/audio.c @@ -192,6 +192,7 @@ void reinit_audio_chain(struct MPContext *mpctx) mpctx->d_audio->global = mpctx->global; mpctx->d_audio->opts = opts; mpctx->d_audio->header = sh; + mpctx->d_audio->pool = mp_audio_pool_create(mpctx->d_audio); mpctx->d_audio->afilter = af_new(mpctx->global); mpctx->d_audio->afilter->replaygain_data = sh->audio->replaygain_data; mpctx->ao_buffer = mp_audio_buffer_create(NULL); @@ -207,8 +208,7 @@ void reinit_audio_chain(struct MPContext *mpctx) } assert(mpctx->d_audio); - struct mp_audio in_format; - mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &in_format); + struct mp_audio in_format = mpctx->d_audio->decode_format; if (!mp_audio_config_valid(&in_format)) { // We don't know the audio format yet - so configure it later as we're @@ -238,7 +238,7 @@ void reinit_audio_chain(struct MPContext *mpctx) } // filter input format: same as codec's output format: - mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &afs->input); + afs->input = in_format; // Determine what the filter chain outputs. recreate_audio_filters() also // needs this for testing whether playback speed is changed by resampling @@ -304,8 +304,7 @@ double written_audio_pts(struct MPContext *mpctx) if (!d_audio) return MP_NOPTS_VALUE; - struct mp_audio in_format; - mp_audio_buffer_get_format(d_audio->decode_buffer, &in_format); + struct mp_audio in_format = d_audio->decode_format; if (!mp_audio_config_valid(&in_format) || d_audio->afilter->initialized < 1) return MP_NOPTS_VALUE; @@ -324,7 +323,8 @@ double written_audio_pts(struct MPContext *mpctx) // Subtract data in buffers between decoder and audio out. // Decoded but not filtered - a_pts -= mp_audio_buffer_seconds(d_audio->decode_buffer); + if (d_audio->waiting) + a_pts -= d_audio->waiting->samples / (double)in_format.rate; // Data buffered in audio filters, measured in seconds of "missing" output double buffered_output = af_calc_delay(d_audio->afilter); |