diff options
Diffstat (limited to 'player/loadfile.c')
-rw-r--r-- | player/loadfile.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index 058be92c83..a4ef62f2aa 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -353,7 +353,7 @@ void update_demuxer_properties(struct MPContext *mpctx) } talloc_free(mpctx->filtered_tags); mpctx->filtered_tags = info; - mp_notify(mpctx, MPV_EVENT_METADATA_UPDATE, NULL); + mp_notify(mpctx, MP_EVENT_METADATA_UPDATE, NULL); } if (events & DEMUX_EVENT_DURATION) mp_notify(mpctx, MP_EVENT_DURATION_UPDATE, NULL); @@ -421,6 +421,7 @@ static struct track *add_stream_track(struct MPContext *mpctx, .dependent_track = stream->dependent_track, .visual_impaired_track = stream->visual_impaired_track, .hearing_impaired_track = stream->hearing_impaired_track, + .image = stream->image, .attached_picture = stream->attached_picture != NULL, .lang = stream->lang, .demuxer = demuxer, @@ -428,7 +429,7 @@ static struct track *add_stream_track(struct MPContext *mpctx, }; MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track); - mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL); + mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL); return track; } @@ -476,8 +477,12 @@ static bool compare_track(struct track *t1, struct track *t2, char **langs, return !t1->is_external; bool ext1 = t1->is_external && !t1->no_default; bool ext2 = t2->is_external && !t2->no_default; - if (ext1 != ext2) + if (ext1 != ext2) { + if (t1->attached_picture && t2->attached_picture + && opts->audio_display == 1) + return !ext1; return ext1; + } if (t1->auto_loaded != t2->auto_loaded) return !t1->auto_loaded; int l1 = match_lang(langs, t1->lang), l2 = match_lang(langs, t2->lang); @@ -681,7 +686,7 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type reinit_sub(mpctx, track); } - mp_notify(mpctx, MPV_EVENT_TRACK_SWITCHED, NULL); + mp_notify(mpctx, MP_EVENT_TRACK_SWITCHED, NULL); mp_wakeup_core(mpctx); talloc_free(mpctx->track_layout_hash); @@ -747,7 +752,7 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track) if (!in_use) demux_cancel_and_free(d); - mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL); + mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL); return true; } @@ -758,7 +763,8 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track) // cancel will generally be used to abort the loading process, but on success // the demuxer is changed to be slaved to mpctx->playback_abort instead. int mp_add_external_file(struct MPContext *mpctx, char *filename, - enum stream_type filter, struct mp_cancel *cancel) + enum stream_type filter, struct mp_cancel *cancel, + bool cover_art) { struct MPOpts *opts = mpctx->opts; if (!filename || mp_cancel_test(cancel)) @@ -832,8 +838,8 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename, t->external_filename = talloc_strdup(t, filename); t->no_default = sh->type != filter; t->no_auto_select = t->no_default; - // filter==STREAM_VIDEO always means cover art. - t->attached_picture = t->type == STREAM_VIDEO && filter == STREAM_VIDEO; + // if we found video, and we are loading cover art, flag as such. + t->attached_picture = t->type == STREAM_VIDEO && cover_art; if (first_num < 0 && (filter == STREAM_TYPE_COUNT || sh->type == filter)) first_num = mpctx->num_tracks - 1; } @@ -858,7 +864,9 @@ static void open_external_files(struct MPContext *mpctx, char **files, files = mp_dup_str_array(tmp, files); for (int n = 0; files && files[n]; n++) - mp_add_external_file(mpctx, files[n], filter, mpctx->playback_abort); + // when given filter is set to video, we are loading up cover art + mp_add_external_file(mpctx, files[n], filter, mpctx->playback_abort, + filter == STREAM_VIDEO); talloc_free(tmp); } @@ -897,15 +905,16 @@ void autoload_external_files(struct MPContext *mpctx, struct mp_cancel *cancel) goto skip; if (e->type == STREAM_VIDEO && (sc[STREAM_VIDEO] || !sc[STREAM_AUDIO])) goto skip; - int first = mp_add_external_file(mpctx, e->fname, e->type, cancel); + + // when given filter is set to video, we are loading up cover art + int first = mp_add_external_file(mpctx, e->fname, e->type, cancel, + e->type == STREAM_VIDEO); if (first < 0) goto skip; for (int n = first; n < mpctx->num_tracks; n++) { struct track *t = mpctx->tracks[n]; t->auto_loaded = true; - t->attached_picture = - t->type == STREAM_VIDEO && e->type == STREAM_VIDEO; if (!t->lang) t->lang = talloc_strdup(t, e->lang); } @@ -1349,7 +1358,7 @@ done: reselect_demux_stream(mpctx, mpctx->tracks[n], false); } - mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL); + mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL); return success ? 1 : -1; } @@ -1615,7 +1624,7 @@ static void play_current_file(struct MPContext *mpctx) if (mpctx->vo_chain && mpctx->vo_chain->is_coverart) { MP_INFO(mpctx, - "Displaying attached picture. Use --no-audio-display to prevent this.\n"); + "Displaying cover art. Use --no-audio-display to prevent this.\n"); } if (!mpctx->vo_chain) @@ -1712,7 +1721,7 @@ terminate_playback: talloc_free(mpctx->filtered_tags); mpctx->filtered_tags = NULL; - mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL); + mp_notify(mpctx, MP_EVENT_TRACKS_CHANGED, NULL); if (encode_lavc_didfail(mpctx->encode_lavc_ctx)) mpctx->stop_play = PT_ERROR; @@ -1955,11 +1964,18 @@ void open_recorder(struct MPContext *mpctx, bool on_init) MP_TARRAY_APPEND(NULL, streams, num_streams, track->stream); } + struct demux_attachment **attachments = talloc_array(NULL, struct demux_attachment*, mpctx->demuxer->num_attachments); + for (int n = 0; n < mpctx->demuxer->num_attachments; n++) { + attachments[n] = &mpctx->demuxer->attachments[n]; + } + mpctx->recorder = mp_recorder_create(mpctx->global, mpctx->opts->record_file, - streams, num_streams); + streams, num_streams, + attachments, mpctx->demuxer->num_attachments); if (!mpctx->recorder) { talloc_free(streams); + talloc_free(attachments); close_recorder_and_error(mpctx); return; } @@ -1983,5 +1999,6 @@ void open_recorder(struct MPContext *mpctx, bool on_init) } talloc_free(streams); + talloc_free(attachments); } |