aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Uoti Urpala <uau@glyph.nonexistent.invalid>2010-11-08 02:38:51 +0200
committerGravatar Uoti Urpala <uau@glyph.nonexistent.invalid>2010-11-08 18:05:12 +0200
commita7b91626cf04139b3a42db048fe5b5aea96e141a (patch)
tree66c48a2ffe943c260ca62e3f9b39481fda97cac0
parent82cd2f7aecef6594f1aea15251b547365bebb183 (diff)
core: use correct demuxer with -audiofile / -subfile
Various code referred to "mpctx->demuxer" where it should really have referred to the one used for audio/subtitles in case those differ. Fix by using "mpctx->d_audio->demuxer" etc instead. Disable the copying of streams in demux_demuxers; that was a partial workaround for things referring to the main demuxer (and it wasn't enough anyway). This fixes, among other things, switching audio tracks within the file specified by -audiofile.
-rw-r--r--command.c36
-rw-r--r--libmpdemux/demux_demuxers.c2
-rw-r--r--mplayer.c7
3 files changed, 23 insertions, 22 deletions
diff --git a/command.c b/command.c
index f669c19fff..f099322428 100644
--- a/command.c
+++ b/command.c
@@ -154,7 +154,7 @@ static void update_global_sub_size(MPContext *mpctx)
// update number of demuxer sub streams
for (i = 0; i < MAX_S_STREAMS; i++)
- if (mpctx->demuxer->s_streams[i])
+ if (mpctx->d_sub->demuxer->s_streams[i])
cnt++;
if (cnt > mpctx->sub_counts[SUB_SOURCE_DEMUX])
mpctx->sub_counts[SUB_SOURCE_DEMUX] = cnt;
@@ -912,7 +912,7 @@ static int mp_property_audio(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
int current_id, tmp;
- if (!mpctx->demuxer || !mpctx->demuxer->audio)
+ if (!mpctx->demuxer || !mpctx->d_audio)
return M_PROPERTY_UNAVAILABLE;
current_id = mpctx->sh_audio ? mpctx->sh_audio->aid : -2;
@@ -960,12 +960,12 @@ static int mp_property_audio(m_option_t *prop, int action, void *arg,
tmp = *((int *) arg);
else
tmp = -1;
- int new_id = demuxer_switch_audio(mpctx->demuxer, tmp);
+ int new_id = demuxer_switch_audio(mpctx->d_audio->demuxer, tmp);
if (new_id != current_id)
uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_ACODEC);
if (new_id != current_id && new_id >= 0) {
sh_audio_t *sh2;
- sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id];
+ sh2 = mpctx->d_audio->demuxer->a_streams[mpctx->demuxer->audio->id];
sh2->ds = mpctx->demuxer->audio;
mpctx->sh_audio = sh2;
reinit_audio_chain(mpctx);
@@ -984,9 +984,9 @@ static int mp_property_video(m_option_t *prop, int action, void *arg,
{
struct MPOpts *opts = &mpctx->opts;
int current_id, tmp;
- if (!mpctx->demuxer || !mpctx->demuxer->video)
+ if (!mpctx->demuxer || !mpctx->d_video)
return M_PROPERTY_UNAVAILABLE;
- current_id = mpctx->demuxer->video->id;
+ current_id = mpctx->d_video->id;
switch (action) {
case M_PROPERTY_GET:
@@ -1014,17 +1014,17 @@ static int mp_property_video(m_option_t *prop, int action, void *arg,
tmp = *((int *) arg);
else
tmp = -1;
- opts->video_id = demuxer_switch_video(mpctx->demuxer, tmp);
+ opts->video_id = demuxer_switch_video(mpctx->d_video->demuxer, tmp);
if (opts->video_id == -2
- || (opts->video_id > -1 && mpctx->demuxer->video->id != current_id
+ || (opts->video_id > -1 && mpctx->d_video->id != current_id
&& current_id != -2))
uninit_player(mpctx, INITIALIZED_VCODEC |
(mpctx->opts.fixed_vo && opts->video_id != -2 ? 0 : INITIALIZED_VO));
- if (opts->video_id > -1 && mpctx->demuxer->video->id != current_id) {
+ if (opts->video_id > -1 && mpctx->d_video->id != current_id) {
sh_video_t *sh2;
- sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id];
+ sh2 = mpctx->d_video->demuxer->v_streams[mpctx->d_video->id];
if (sh2) {
- sh2->ds = mpctx->demuxer->video;
+ sh2->ds = mpctx->d_video;
mpctx->sh_video = sh2;
reinit_video_chain(mpctx);
}
@@ -1546,11 +1546,11 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
}
#endif
- if ((mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA
- || mpctx->demuxer->type == DEMUXER_TYPE_LAVF
- || mpctx->demuxer->type == DEMUXER_TYPE_LAVF_PREFERRED
- || mpctx->demuxer->type == DEMUXER_TYPE_OGG)
- && d_sub && d_sub->sh && opts->sub_id >= 0) {
+ if ((d_sub->demuxer->type == DEMUXER_TYPE_MATROSKA
+ || d_sub->demuxer->type == DEMUXER_TYPE_LAVF
+ || d_sub->demuxer->type == DEMUXER_TYPE_LAVF_PREFERRED
+ || d_sub->demuxer->type == DEMUXER_TYPE_OGG)
+ && d_sub->sh && opts->sub_id >= 0) {
const char* lang = ((sh_sub_t*)d_sub->sh)->lang;
if (!lang) lang = mp_gtext("unknown");
snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang);
@@ -1653,10 +1653,10 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
int i = 0;
// default: assume 1:1 mapping of sid and stream id
d_sub->id = opts->sub_id;
- d_sub->sh = mpctx->demuxer->s_streams[d_sub->id];
+ d_sub->sh = mpctx->d_sub->demuxer->s_streams[d_sub->id];
ds_free_packs(d_sub);
for (i = 0; i < MAX_S_STREAMS; i++) {
- sh_sub_t *sh = mpctx->demuxer->s_streams[i];
+ sh_sub_t *sh = mpctx->d_sub->demuxer->s_streams[i];
if (sh && sh->sid == opts->sub_id) {
d_sub->id = i;
d_sub->sh = sh;
diff --git a/libmpdemux/demux_demuxers.c b/libmpdemux/demux_demuxers.c
index 1c71787008..3de307db0f 100644
--- a/libmpdemux/demux_demuxers.c
+++ b/libmpdemux/demux_demuxers.c
@@ -63,12 +63,12 @@ demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd) {
if (vd) vd->video->demuxer = ret;
if (ad) ad->audio->demuxer = ret;
if (sd) sd->sub->demuxer = ret;
-#endif
// HACK?, necessary for subtitle (and audio and video when implemented) switching
memcpy(ret->v_streams, vd->v_streams, sizeof(ret->v_streams));
memcpy(ret->a_streams, ad->a_streams, sizeof(ret->a_streams));
memcpy(ret->s_streams, sd->s_streams, sizeof(ret->s_streams));
+#endif
ret->desc = &demuxer_desc_demuxers;
diff --git a/mplayer.c b/mplayer.c
index d6007a58c4..3423813deb 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1958,9 +1958,10 @@ static int select_subtitle(MPContext *mpctx)
if (!found && opts->sub_id == -1) {
// finally select subs by language and container hints
if (opts->sub_id == -1 && opts->sub_lang)
- opts->sub_id = demuxer_sub_track_by_lang(mpctx->demuxer, opts->sub_lang);
+ opts->sub_id = demuxer_sub_track_by_lang(mpctx->d_sub->demuxer,
+ opts->sub_lang);
if (opts->sub_id == -1)
- opts->sub_id = demuxer_default_sub_track(mpctx->demuxer);
+ opts->sub_id = demuxer_default_sub_track(mpctx->d_sub->demuxer);
if (opts->sub_id >= 0) {
id = opts->sub_id;
found = mp_property_do("sub_demux", M_PROPERTY_SET, &id, mpctx) == M_PROPERTY_OK;
@@ -3880,7 +3881,7 @@ if (ts_prog) {
select_audio(mpctx->sources[i].demuxer, opts->audio_id,
opts->audio_lang);
else
- select_audio(mpctx->demuxer, opts->audio_id, opts->audio_lang);
+ select_audio(mpctx->d_audio->demuxer, opts->audio_id, opts->audio_lang);
// DUMP STREAMS:
if((stream_dump_type)&&(stream_dump_type<4)){