diff options
author | wm4 <wm4@nowhere> | 2020-08-28 20:23:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-08-29 13:12:32 +0200 |
commit | b74c09efbf7c6969fc053265f72cc0501b840ce1 (patch) | |
tree | bfaa86f7b03f28a191e5fdc83594095952e3dfba /player/core.h | |
parent | bb1f82107801a7981f9ae5b4229f48af68cc85c2 (diff) | |
download | mpv-b74c09efbf7c6969fc053265f72cc0501b840ce1.tar.bz2 mpv-b74c09efbf7c6969fc053265f72cc0501b840ce1.tar.xz |
audio: refactor how data is passed to AO
This replaces the two buffers (ao_chain.ao_buffer in the core, and
buffer_state.buffers in the AO) with a single queue. Instead of having a
byte based buffer, the queue is simply a list of audio frames, as output
by the decoder. This should make dataflow simpler and reduce copying.
It also attempts to simplify fill_audio_out_buffers(), the function I
always hated most, because it's full of subtle and buggy logic.
Unfortunately, I got assaulted by corner cases, dumb features (attempt
at seamless looping, really?), and other crap, so it got pretty
complicated again. fill_audio_out_buffers() is still full of subtle and
buggy logic. Maybe it got worse. On the other hand, maybe there really
is some progress. Who knows.
Originally, the data flow parts was meant to be in f_output_chain, but
due to tricky interactions with the playloop code, it's now in the dummy
filter in audio.c.
At least this improves the way the audio PTS is passed to the encoder in
encoding mode. Now it attempts to pass frames directly, along with the
pts, which should minimize timestamp problems. But to be honest, encoder
mode is one big kludge that shouldn't exist in this way.
This commit should be considered pre-alpha code. There are lots of bugs
still hiding.
Diffstat (limited to 'player/core.h')
-rw-r--r-- | player/core.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/player/core.h b/player/core.h index 738233c072..5ad494ff89 100644 --- a/player/core.h +++ b/player/core.h @@ -190,28 +190,33 @@ struct vo_chain { // Like vo_chain, for audio. struct ao_chain { struct mp_log *log; + struct MPContext *mpctx; bool spdif_passthrough, spdif_failed; struct mp_output_chain *filter; struct ao *ao; - struct mp_audio_buffer *ao_buffer; + struct mp_async_queue *ao_queue; + struct mp_filter *queue_filter; + struct mp_filter *ao_filter; double ao_resume_time; - // 1-element output frame queue. - struct mp_aframe *output_frame; bool out_eof; - double last_out_pts; + double start_pts; + bool start_pts_known; + struct track *track; struct mp_pin *filter_src; struct mp_pin *dec_src; double delay; + bool untimed_throttle; - bool underrun; + bool ao_underrun; // last known AO state + bool underrun; // for cache pause logic }; /* Note that playback can be paused, stopped, etc. at any time. While paused, @@ -223,7 +228,6 @@ struct ao_chain { enum playback_status { // code may compare status values numerically STATUS_SYNCING, // seeking for a position to resume - STATUS_FILLING, // decoding more data (so you start with full buffers) STATUS_READY, // buffers full, playback can be started any time STATUS_PLAYING, // normal playback STATUS_DRAINING, // decoding has ended; still playing out queued buffers @@ -500,6 +504,7 @@ void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track); void audio_update_volume(struct MPContext *mpctx); void audio_update_balance(struct MPContext *mpctx); void reload_audio_output(struct MPContext *mpctx); +void audio_start_ao(struct MPContext *mpctx); // configfiles.c void mp_parse_cfgfiles(struct MPContext *mpctx); |