summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:22:17 +0100
committerwm4 <wm4@nowhere>2013-11-23 21:22:17 +0100
commit0f5ec05d8f4ae02262dc79a895bce3b465b376f2 (patch)
treeba5fc3f640eeefa44a28695f8cd3f63ba2eec2c9 /mpvcore
parent705a7310e6c823a72c961720f8ae416962f1398a (diff)
downloadmpv-0f5ec05d8f4ae02262dc79a895bce3b465b376f2.tar.bz2
mpv-0f5ec05d8f4ae02262dc79a895bce3b465b376f2.tar.xz
audio: move decoder context from sh_audio into new struct
Move all state that basically changes during decoding or is needed in order to manage decoding itself into a new struct (dec_audio). sh_audio (defined in stheader.h) is supposed to be the audio stream header. This should reflect the file headers for the stream. Putting the decoder context there is strange design, to say the least.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/player/audio.c85
-rw-r--r--mpvcore/player/command.c32
-rw-r--r--mpvcore/player/loadfile.c30
-rw-r--r--mpvcore/player/main.c2
-rw-r--r--mpvcore/player/mp_core.h6
-rw-r--r--mpvcore/player/osd.c4
-rw-r--r--mpvcore/player/playloop.c36
-rw-r--r--mpvcore/player/video.c8
8 files changed, 108 insertions, 95 deletions
diff --git a/mpvcore/player/audio.c b/mpvcore/player/audio.c
index 3bf338c21d..ce161a58d5 100644
--- a/mpvcore/player/audio.c
+++ b/mpvcore/player/audio.c
@@ -41,18 +41,18 @@
static int build_afilter_chain(struct MPContext *mpctx)
{
- struct sh_audio *sh_audio = mpctx->sh_audio;
+ struct dec_audio *d_audio = mpctx->d_audio;
struct ao *ao = mpctx->ao;
struct MPOpts *opts = mpctx->opts;
- if (!sh_audio->initialized)
+ if (!d_audio)
return 0;
struct mp_audio in_format;
- mp_audio_buffer_get_format(mpctx->sh_audio->decode_buffer, &in_format);
+ mp_audio_buffer_get_format(d_audio->decode_buffer, &in_format);
int new_srate;
- if (af_control_any_rev(sh_audio->afilter, AF_CONTROL_SET_PLAYBACK_SPEED,
+ if (af_control_any_rev(d_audio->afilter, AF_CONTROL_SET_PLAYBACK_SPEED,
&opts->playback_speed))
new_srate = in_format.rate;
else {
@@ -66,13 +66,13 @@ static int build_afilter_chain(struct MPContext *mpctx)
opts->playback_speed = new_srate / (double)in_format.rate;
}
}
- return init_audio_filters(sh_audio, new_srate,
+ return audio_init_filters(d_audio, new_srate,
&ao->samplerate, &ao->channels, &ao->format);
}
static int recreate_audio_filters(struct MPContext *mpctx)
{
- assert(mpctx->sh_audio);
+ assert(mpctx->d_audio);
// init audio filters:
if (!build_afilter_chain(mpctx)) {
@@ -80,19 +80,19 @@ static int recreate_audio_filters(struct MPContext *mpctx)
return -1;
}
- mixer_reinit_audio(mpctx->mixer, mpctx->ao, mpctx->sh_audio->afilter);
+ mixer_reinit_audio(mpctx->mixer, mpctx->ao, mpctx->d_audio->afilter);
return 0;
}
int reinit_audio_filters(struct MPContext *mpctx)
{
- struct sh_audio *sh_audio = mpctx->sh_audio;
- if (!sh_audio)
+ struct dec_audio *d_audio = mpctx->d_audio;
+ if (!d_audio)
return -2;
- af_uninit(mpctx->sh_audio->afilter);
- if (af_init(mpctx->sh_audio->afilter) < 0)
+ af_uninit(mpctx->d_audio->afilter);
+ if (af_init(mpctx->d_audio->afilter) < 0)
return -1;
if (recreate_audio_filters(mpctx) < 0)
return -1;
@@ -103,20 +103,25 @@ int reinit_audio_filters(struct MPContext *mpctx)
void reinit_audio_chain(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
- init_demux_stream(mpctx, STREAM_AUDIO);
- if (!mpctx->sh_audio) {
+ struct sh_stream *sh = init_demux_stream(mpctx, STREAM_AUDIO);
+ if (!sh) {
uninit_player(mpctx, INITIALIZED_AO);
goto no_audio;
}
if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) {
- if (!init_best_audio_codec(mpctx->sh_audio, opts->audio_decoders))
- goto init_error;
mpctx->initialized_flags |= INITIALIZED_ACODEC;
+ assert(!mpctx->d_audio);
+ mpctx->d_audio = talloc_zero(NULL, struct dec_audio);
+ mpctx->d_audio->opts = opts;
+ mpctx->d_audio->header = sh;
+ if (!audio_init_best_codec(mpctx->d_audio, opts->audio_decoders))
+ goto init_error;
}
+ assert(mpctx->d_audio);
struct mp_audio in_format;
- mp_audio_buffer_get_format(mpctx->sh_audio->decode_buffer, &in_format);
+ mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &in_format);
int ao_srate = opts->force_srate;
int ao_format = opts->audio_output_format;
@@ -137,7 +142,7 @@ void reinit_audio_chain(struct MPContext *mpctx)
// Determine what the filter chain outputs. build_afilter_chain() also
// needs this for testing whether playback speed is changed by resampling
// or using a special filter.
- if (!init_audio_filters(mpctx->sh_audio, // preliminary init
+ if (!audio_init_filters(mpctx->d_audio, // preliminary init
// input:
in_format.rate,
// output:
@@ -188,31 +193,31 @@ no_audio:
// ao so far.
double written_audio_pts(struct MPContext *mpctx)
{
- sh_audio_t *sh_audio = mpctx->sh_audio;
- if (!sh_audio || !sh_audio->initialized)
+ struct dec_audio *d_audio = mpctx->d_audio;
+ if (!d_audio)
return MP_NOPTS_VALUE;
struct mp_audio in_format;
- mp_audio_buffer_get_format(mpctx->sh_audio->decode_buffer, &in_format);
+ mp_audio_buffer_get_format(d_audio->decode_buffer, &in_format);
// first calculate the end pts of audio that has been output by decoder
- double a_pts = sh_audio->pts;
+ double a_pts = d_audio->pts;
if (a_pts == MP_NOPTS_VALUE)
return MP_NOPTS_VALUE;
- // sh_audio->pts is the timestamp of the latest input packet with
- // known pts that the decoder has decoded. sh_audio->pts_bytes is
+ // d_audio->pts is the timestamp of the latest input packet with
+ // known pts that the decoder has decoded. d_audio->pts_bytes is
// the amount of bytes the decoder has written after that timestamp.
- a_pts += sh_audio->pts_offset / (double)in_format.rate;
+ a_pts += d_audio->pts_offset / (double)in_format.rate;
// Now a_pts hopefully holds the pts for end of audio from decoder.
// Subtract data in buffers between decoder and audio out.
// Decoded but not filtered
- a_pts -= mp_audio_buffer_seconds(sh_audio->decode_buffer);
+ a_pts -= mp_audio_buffer_seconds(d_audio->decode_buffer);
// Data buffered in audio filters, measured in seconds of "missing" output
- double buffered_output = af_calc_delay(sh_audio->afilter);
+ double buffered_output = af_calc_delay(d_audio->afilter);
// Data that was ready for ao but was buffered because ao didn't fully
// accept everything to internal buffers yet
@@ -275,11 +280,13 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
{
struct ao *ao = mpctx->ao;
struct MPOpts *opts = mpctx->opts;
- sh_audio_t * const sh_audio = mpctx->sh_audio;
+ struct dec_audio *d_audio = mpctx->d_audio;
int res;
+ assert(d_audio);
+
// Timing info may not be set without
- res = decode_audio(sh_audio, ao->buffer, 1);
+ res = audio_decode(d_audio, ao->buffer, 1);
if (res < 0)
return res;
@@ -300,10 +307,10 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
samples = ptsdiff * real_samplerate;
// ogg demuxers give packets without timing
- if (written_pts <= 1 && sh_audio->pts == MP_NOPTS_VALUE) {
+ if (written_pts <= 1 && d_audio->pts == MP_NOPTS_VALUE) {
if (!did_retry) {
// Try to read more data to see packets that have pts
- res = decode_audio(sh_audio, ao->buffer, ao->samplerate);
+ res = audio_decode(d_audio, ao->buffer, ao->samplerate);
if (res < 0)
return res;
did_retry = true;
@@ -321,12 +328,12 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
mpctx->syncing_audio = false;
int skip_samples = -samples;
int a = MPMIN(skip_samples, MPMAX(playsize, 2500));
- res = decode_audio(sh_audio, ao->buffer, a);
+ res = audio_decode(d_audio, ao->buffer, a);
if (skip_samples <= mp_audio_buffer_samples(ao->buffer)) {
mp_audio_buffer_skip(ao->buffer, skip_samples);
if (res < 0)
return res;
- return decode_audio(sh_audio, ao->buffer, playsize);
+ return audio_decode(d_audio, ao->buffer, playsize);
}
mp_audio_buffer_clear(ao->buffer);
if (res < 0)
@@ -346,7 +353,7 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
}
mpctx->syncing_audio = false;
mp_audio_buffer_prepend_silence(ao->buffer, samples);
- return decode_audio(sh_audio, ao->buffer, playsize);
+ return audio_decode(d_audio, ao->buffer, playsize);
}
int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
@@ -358,9 +365,11 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
bool audio_eof = false;
bool signal_eof = false;
bool partial_fill = false;
- sh_audio_t * const sh_audio = mpctx->sh_audio;
+ struct dec_audio *d_audio = mpctx->d_audio;
bool modifiable_audio_format = !(ao->format & AF_FORMAT_SPECIAL_MASK);
+ assert(d_audio);
+
if (mpctx->paused)
playsize = 1; // just initialize things (audio pts at least)
else
@@ -378,7 +387,7 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
if (mpctx->syncing_audio || mpctx->hrseek_active)
res = audio_start_sync(mpctx, playsize);
else
- res = decode_audio(sh_audio, ao->buffer, playsize);
+ res = audio_decode(d_audio, ao->buffer, playsize);
if (res < 0) { // EOF, error or format change
if (res == -2) {
@@ -392,7 +401,7 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
return -1;
} else if (res == ASYNC_PLAY_DONE)
return 0;
- else if (demux_stream_eof(mpctx->sh_audio->gsh))
+ else if (demux_stream_eof(d_audio->header))
audio_eof = true;
}
@@ -455,6 +464,6 @@ void clear_audio_output_buffers(struct MPContext *mpctx)
// Drop decoded data queued for filtering.
void clear_audio_decode_buffers(struct MPContext *mpctx)
{
- if (mpctx->sh_audio && mpctx->sh_audio->decode_buffer)
- mp_audio_buffer_clear(mpctx->sh_audio->decode_buffer);
+ if (mpctx->d_audio)
+ mp_audio_buffer_clear(mpctx->d_audio->decode_buffer);
}
diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c
index be34d4e8f5..dc190adfc6 100644
--- a/mpvcore/player/command.c
+++ b/mpvcore/player/command.c
@@ -123,7 +123,7 @@ static int mp_property_playback_speed(m_option_t *prop, int action,
opts->playback_speed = *(double *) arg;
// Adjust time until next frame flip for nosound mode
mpctx->time_frame *= orig_speed / opts->playback_speed;
- if (mpctx->sh_audio)
+ if (mpctx->d_audio)
reinit_audio_chain(mpctx);
return M_PROPERTY_OK;
}
@@ -315,7 +315,7 @@ static int mp_property_length(m_option_t *prop, int action, void *arg,
static int mp_property_avsync(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (!mpctx->sh_audio || !mpctx->sh_video)
+ if (!mpctx->d_audio || !mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
if (mpctx->last_av_difference == MP_NOPTS_VALUE)
return M_PROPERTY_UNAVAILABLE;
@@ -625,8 +625,8 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg,
if (mpctx->sh_video)
resync_video_stream(mpctx->sh_video);
- if (mpctx->sh_audio)
- resync_audio_stream(mpctx->sh_audio);
+ if (mpctx->d_audio)
+ audio_resync_stream(mpctx->d_audio);
}
return M_PROPERTY_OK;
case M_PROPERTY_GET_TYPE: {
@@ -816,7 +816,7 @@ static int mp_property_volrestore(m_option_t *prop, int action,
static int mp_property_audio_delay(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- if (!(mpctx->sh_audio && mpctx->sh_video))
+ if (!(mpctx->d_audio && mpctx->sh_video))
return M_PROPERTY_UNAVAILABLE;
float delay = mpctx->opts->audio_delay;
switch (action) {
@@ -835,7 +835,7 @@ static int mp_property_audio_delay(m_option_t *prop, int action,
static int mp_property_audio_format(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- const char *c = mpctx->sh_audio ? mpctx->sh_audio->gsh->codec : NULL;
+ const char *c = mpctx->d_audio ? mpctx->d_audio->header->codec : NULL;
return m_property_strdup_ro(prop, action, arg, c);
}
@@ -843,7 +843,7 @@ static int mp_property_audio_format(m_option_t *prop, int action,
static int mp_property_audio_codec(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- const char *c = mpctx->sh_audio ? mpctx->sh_audio->gsh->decoder_desc : NULL;
+ const char *c = mpctx->d_audio ? mpctx->d_audio->decoder_desc : NULL;
return m_property_strdup_ro(prop, action, arg, c);
}
@@ -851,14 +851,14 @@ static int mp_property_audio_codec(m_option_t *prop, int action,
static int mp_property_audio_bitrate(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
- if (!mpctx->sh_audio)
+ if (!mpctx->d_audio)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
- *(char **)arg = format_bitrate(mpctx->sh_audio->i_bps);
+ *(char **)arg = format_bitrate(mpctx->d_audio->i_bps);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
- *(int *)arg = mpctx->sh_audio->i_bps;
+ *(int *)arg = mpctx->d_audio->i_bps;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
@@ -868,15 +868,15 @@ static int mp_property_audio_bitrate(m_option_t *prop, int action,
static int mp_property_samplerate(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (!mpctx->sh_audio)
+ if (!mpctx->d_audio)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
*(char **)arg = talloc_asprintf(NULL, "%d kHz",
- mpctx->sh_audio->samplerate / 1000);
+ mpctx->d_audio->header->audio->samplerate / 1000);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
- *(int *)arg = mpctx->sh_audio->samplerate;
+ *(int *)arg = mpctx->d_audio->header->audio->samplerate;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
@@ -886,14 +886,14 @@ static int mp_property_samplerate(m_option_t *prop, int action, void *arg,
static int mp_property_channels(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (!mpctx->sh_audio)
+ if (!mpctx->d_audio)
return M_PROPERTY_UNAVAILABLE;
switch (action) {
case M_PROPERTY_PRINT:
- *(char **) arg = mp_chmap_to_str(&mpctx->sh_audio->channels);
+ *(char **) arg = mp_chmap_to_str(&mpctx->d_audio->header->audio->channels);
return M_PROPERTY_OK;
case M_PROPERTY_GET:
- *(int *)arg = mpctx->sh_audio->channels.num;
+ *(int *)arg = mpctx->d_audio->header->audio->channels.num;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index f6e7f6c117..44887ae107 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -73,8 +73,8 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
if (mask & INITIALIZED_ACODEC) {
mpctx->initialized_flags &= ~INITIALIZED_ACODEC;
mixer_uninit_audio(mpctx->mixer);
- if (mpctx->sh_audio)
- uninit_audio(mpctx->sh_audio);
+ audio_uninit(mpctx->d_audio);
+ mpctx->d_audio = NULL;
cleanup_demux_stream(mpctx, STREAM_AUDIO);
}
@@ -113,7 +113,7 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
mpctx->num_tracks = 0;
for (int t = 0; t < STREAM_TYPE_COUNT; t++)
mpctx->current_track[t] = NULL;
- assert(!mpctx->sh_video && !mpctx->sh_audio && !mpctx->sh_sub);
+ assert(!mpctx->sh_video && !mpctx->d_audio && !mpctx->sh_sub);
mpctx->master_demuxer = NULL;
for (int i = 0; i < mpctx->num_sources; i++) {
uninit_subs(mpctx->sources[i]);
@@ -252,20 +252,21 @@ static void print_file_properties(struct MPContext *mpctx)
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
"ID_VIDEO_ASPECT=%1.4f\n", mpctx->sh_video->aspect);
}
- if (mpctx->sh_audio) {
+ if (mpctx->d_audio) {
+ struct sh_audio *sh_audio = mpctx->d_audio->header->audio;
/* Assume FOURCC if all bytes >= 0x20 (' ') */
- if (mpctx->sh_audio->format >= 0x20202020)
+ if (sh_audio->format >= 0x20202020)
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_FORMAT=%.4s\n", (char *)&mpctx->sh_audio->format);
+ "ID_AUDIO_FORMAT=%.4s\n", (char *)&sh_audio->format);
else
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_FORMAT=%d\n", mpctx->sh_audio->format);
+ "ID_AUDIO_FORMAT=%d\n", sh_audio->format);
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_BITRATE=%d\n", mpctx->sh_audio->i_bps * 8);
+ "ID_AUDIO_BITRATE=%d\n", sh_audio->i_bps * 8);
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_RATE=%d\n", mpctx->sh_audio->samplerate);
+ "ID_AUDIO_RATE=%d\n", sh_audio->samplerate);
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
- "ID_AUDIO_NCH=%d\n", mpctx->sh_audio->channels.num);
+ "ID_AUDIO_NCH=%d\n", sh_audio->channels.num);
}
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
"ID_LENGTH=%.2f\n", get_time_length(mpctx));
@@ -304,12 +305,12 @@ static void set_demux_field(struct MPContext *mpctx, enum stream_type type,
// redundant fields for convenience access
switch(type) {
case STREAM_VIDEO: mpctx->sh_video = s ? s->video : NULL; break;
- case STREAM_AUDIO: mpctx->sh_audio = s ? s->audio : NULL; break;
case STREAM_SUB: mpctx->sh_sub = s ? s->sub : NULL; break;
}
}
-void init_demux_stream(struct MPContext *mpctx, enum stream_type type)
+struct sh_stream *init_demux_stream(struct MPContext *mpctx,
+ enum stream_type type)
{
struct track *track = mpctx->current_track[type];
set_demux_field(mpctx, type, track ? track->stream : NULL);
@@ -321,6 +322,7 @@ void init_demux_stream(struct MPContext *mpctx, enum stream_type type)
demux_seek(stream->demuxer, pts, SEEK_ABSOLUTE);
}
}
+ return stream;
}
void cleanup_demux_stream(struct MPContext *mpctx, enum stream_type type)
@@ -1082,7 +1084,7 @@ static void play_current_file(struct MPContext *mpctx)
assert(mpctx->stream == NULL);
assert(mpctx->demuxer == NULL);
- assert(mpctx->sh_audio == NULL);
+ assert(mpctx->d_audio == NULL);
assert(mpctx->sh_video == NULL);
assert(mpctx->sh_sub == NULL);
@@ -1229,7 +1231,7 @@ goto_reopen_demuxer: ;
//==================== START PLAYING =======================
- if (!mpctx->sh_video && !mpctx->sh_audio) {
+ if (!mpctx->sh_video && !mpctx->d_audio) {
MP_FATAL(mpctx, "No video or audio streams selected.\n");
#if HAVE_DVBIN
if (mpctx->stream->type == STREAMTYPE_DVB) {
diff --git a/mpvcore/player/main.c b/mpvcore/player/main.c
index 4119e244c3..81e724252d 100644
--- a/mpvcore/player/main.c
+++ b/mpvcore/player/main.c
@@ -194,7 +194,7 @@ static bool handle_help_options(struct MPContext *mpctx)
struct MPOpts *opts = mpctx->opts;
int opt_exit = 0;
if (opts->audio_decoders && strcmp(opts->audio_decoders, "help") == 0) {
- struct mp_decoder_list *list = mp_audio_decoder_list();
+ struct mp_decoder_list *list = audio_decoder_list();
mp_print_decoders(MSGT_CPLAYER, MSGL_INFO, "Audio decoders:", list);
talloc_free(list);
opt_exit = 1;
diff --git a/mpvcore/player/mp_core.h b/mpvcore/player/mp_core.h
index 4e15f49c49..aa0728d10f 100644
--- a/mpvcore/player/mp_core.h
+++ b/mpvcore/player/mp_core.h
@@ -199,10 +199,11 @@ typedef struct MPContext {
struct track *current_track[STREAM_TYPE_COUNT];
struct sh_stream *sh[STREAM_TYPE_COUNT];
- struct sh_audio *sh_audio; // same as sh[STREAM_AUDIO]->audio
struct sh_video *sh_video; // same as sh[STREAM_VIDEO]->video
struct sh_sub *sh_sub; // same as sh[STREAM_SUB]->sub
+ struct dec_audio *d_audio;
+
// Uses: accessing metadata (consider ordered chapters case, where the main
// demuxer defines metadata), or special purpose demuxers like TV.
struct demuxer *master_demuxer;
@@ -357,7 +358,8 @@ struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type,
int tid);
bool timeline_set_part(struct MPContext *mpctx, int i, bool force);
double timeline_set_from_time(struct MPContext *mpctx, double pts, bool *need_reset);
-void init_demux_stream(struct MPContext *mpctx, enum stream_type type);
+struct sh_stream *init_demux_stream(struct MPContext *mpctx,
+ enum stream_type type);
void cleanup_demux_stream(struct MPContext *mpctx, enum stream_type type);
void add_demuxer_tracks(struct MPContext *mpctx, struct demuxer *demuxer);
bool mp_remove_track(struct MPContext *mpctx, struct track *track);
diff --git a/mpvcore/player/osd.c b/mpvcore/player/osd.c
index 03c7c339b7..04052c359e 100644
--- a/mpvcore/player/osd.c
+++ b/mpvcore/player/osd.c
@@ -108,7 +108,7 @@ void print_status(struct MPContext *mpctx)
saddf(&line, "(Paused) ");
}
- if (mpctx->sh_audio)
+ if (mpctx->d_audio)
saddf(&line, "A");
if (mpctx->sh_video)
saddf(&line, "V");
@@ -131,7 +131,7 @@ void print_status(struct MPContext *mpctx)
saddf(&line, " x%4.2f", opts->playback_speed);
// A-V sync
- if (mpctx->sh_audio && sh_video && mpctx->sync_audio_to_video) {
+ if (mpctx->d_audio && sh_video && mpctx->sync_audio_to_video) {
if (mpctx->last_av_difference != MP_NOPTS_VALUE)
saddf(&line, " A-V:%7.3f", mpctx->last_av_difference);
else
diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c
index d611880605..51daf03bb1 100644
--- a/mpvcore/player/playloop.c
+++ b/mpvcore/player/playloop.c
@@ -96,7 +96,7 @@ void pause_player(struct MPContext *mpctx)
if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL);
- if (mpctx->ao && mpctx->sh_audio)
+ if (mpctx->ao && mpctx->d_audio)
ao_pause(mpctx->ao); // pause audio, keep data if possible
// Only print status if there's actually a file being played.
@@ -124,7 +124,7 @@ void unpause_player(struct MPContext *mpctx)
mpctx->paused = false;
mpctx->osd_function = 0;
- if (mpctx->ao && mpctx->sh_audio)
+ if (mpctx->ao && mpctx->d_audio)
ao_resume(mpctx->ao);
if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_RESUME, NULL); // resume video
@@ -182,10 +182,10 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao)
mpctx->time_frame = 0;
}
- if (mpctx->sh_audio) {
- resync_audio_stream(mpctx->sh_audio);
- if (mpctx->sh_audio->afilter)
- af_control_all(mpctx->sh_audio->afilter, AF_CONTROL_RESET, NULL);
+ if (mpctx->d_audio) {
+ audio_resync_stream(mpctx->d_audio);
+ if (mpctx->d_audio->afilter)
+ af_control_all(mpctx->d_audio->afilter, AF_CONTROL_RESET, NULL);
if (reset_ao)
clear_audio_output_buffers(mpctx);
clear_audio_decode_buffers(mpctx);
@@ -255,7 +255,7 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
if (demuxer_amount == -1) {
assert(!need_reset);
mpctx->stop_play = AT_END_OF_FILE;
- if (mpctx->sh_audio && !timeline_fallthrough) {
+ if (mpctx->d_audio && !timeline_fallthrough) {
// Seek outside of the file -> clear audio from current position
clear_audio_decode_buffers(mpctx);
clear_audio_output_buffers(mpctx);
@@ -589,7 +589,7 @@ do_seek:
static void update_avsync(struct MPContext *mpctx)
{
- if (!mpctx->sh_audio || !mpctx->sh_video)
+ if (!mpctx->d_audio || !mpctx->sh_video)
return;
double a_pos = playing_audio_pts(mpctx);
@@ -620,7 +620,7 @@ static void adjust_sync(struct MPContext *mpctx, double frame_time)
{
struct MPOpts *opts = mpctx->opts;
- if (!mpctx->sh_audio || mpctx->syncing_audio)
+ if (!mpctx->d_audio || mpctx->syncing_audio)
return;
double a_pts = written_audio_pts(mpctx) - mpctx->delay;
@@ -969,7 +969,7 @@ void run_playloop(struct MPContext *mpctx)
mpctx->stop_play = PT_NEXT_ENTRY;
}
- if (mpctx->sh_audio && !mpctx->restart_playback && !mpctx->ao->untimed) {
+ if (mpctx->d_audio && !mpctx->restart_playback && !mpctx->ao->untimed) {
int status = fill_audio_out_buffers(mpctx, endpts);
full_audio_buffers = status >= 0;
// Not at audio stream EOF yet
@@ -1118,7 +1118,7 @@ void run_playloop(struct MPContext *mpctx)
if (mpctx->restart_playback) {
if (mpctx->sync_audio_to_video) {
mpctx->syncing_audio = true;
- if (mpctx->sh_audio)
+ if (mpctx->d_audio)
fill_audio_out_buffers(mpctx, endpts);
mpctx->restart_playback = false;
}
@@ -1135,9 +1135,9 @@ void run_playloop(struct MPContext *mpctx)
video_left &= mpctx->sync_audio_to_video; // force no-video semantics
- if (mpctx->sh_audio && (mpctx->restart_playback ? !video_left :
- mpctx->ao->untimed && (mpctx->delay <= 0 ||
- !video_left))) {
+ if (mpctx->d_audio && (mpctx->restart_playback ? !video_left :
+ mpctx->ao->untimed && (mpctx->delay <= 0 ||
+ !video_left))) {
int status = fill_audio_out_buffers(mpctx, endpts);
full_audio_buffers = status >= 0 && !mpctx->ao->untimed;
// Not at audio stream EOF yet
@@ -1145,7 +1145,7 @@ void run_playloop(struct MPContext *mpctx)
}
if (!video_left)
mpctx->restart_playback = false;
- if (mpctx->sh_audio && buffered_audio == -1)
+ if (mpctx->d_audio && buffered_audio == -1)
buffered_audio = mpctx->paused ? 0 : ao_get_delay(mpctx->ao);
update_osd_msg(mpctx);
@@ -1156,7 +1156,7 @@ void run_playloop(struct MPContext *mpctx)
if (!video_left && (!mpctx->paused || was_restart)) {
double a_pos = 0;
- if (mpctx->sh_audio) {
+ if (mpctx->d_audio) {
a_pos = (written_audio_pts(mpctx) -
mpctx->opts->playback_speed * buffered_audio);
}
@@ -1182,7 +1182,7 @@ void run_playloop(struct MPContext *mpctx)
* should trigger after seek only, when we know there's no audio
* buffered.
*/
- if ((mpctx->sh_audio || mpctx->sh_video) && !audio_left && !video_left
+ if ((mpctx->d_audio || mpctx->sh_video) && !audio_left && !video_left
&& (opts->gapless_audio || buffered_audio < 0.05)
&& (!mpctx->paused || was_restart)) {
if (end_is_chapter) {
@@ -1227,7 +1227,7 @@ void run_playloop(struct MPContext *mpctx)
if (!mpctx->stop_play) {
double audio_sleep = 9;
- if (mpctx->sh_audio && !mpctx->paused) {
+ if (mpctx->d_audio && !mpctx->paused) {
if (mpctx->ao->untimed) {
if (!video_left)
audio_sleep = 0;
diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c
index 66c6216d30..d55a19e79f 100644
--- a/mpvcore/player/video.c
+++ b/mpvcore/player/video.c
@@ -243,8 +243,8 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time)
{
struct MPOpts *opts = mpctx->opts;
// check for frame-drop:
- if (mpctx->sh_audio && !mpctx->ao->untimed &&
- !demux_stream_eof(mpctx->sh_audio->gsh))
+ if (mpctx->d_audio && !mpctx->ao->untimed &&
+ !demux_stream_eof(mpctx->sh[STREAM_AUDIO]))
{
float delay = opts->playback_speed * ao_get_delay(mpctx->ao);
float d = delay - mpctx->delay;
@@ -314,7 +314,7 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx)
struct demux_packet *pkt = video_read_frame(mpctx);
if (!pkt)
return -1;
- if (mpctx->sh_audio)
+ if (mpctx->d_audio)
mpctx->delay -= frame_time;
// video_read_frame can change fps (e.g. for ASF video)
update_fps(mpctx);
@@ -469,7 +469,7 @@ double update_video(struct MPContext *mpctx, double endpts)
}
double frame_time = sh_video->pts - sh_video->last_pts;
sh_video->last_pts = sh_video->pts;
- if (mpctx->sh_audio)
+ if (mpctx->d_audio)
mpctx->delay -= frame_time;
return frame_time;
}