summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2021-03-07 23:53:19 +0200
committerJan Ekström <jeebjp@gmail.com>2021-03-09 23:26:26 +0200
commiteef281e89eff6e21a67a106d27fd38979ad20752 (patch)
tree0ca9af346ef0d302b3ab6019669057ab184a0637
parent4f07607888541e6eb40fc5c3a1edfeb84aacb0f7 (diff)
downloadmpv-eef281e89eff6e21a67a106d27fd38979ad20752.tar.bz2
mpv-eef281e89eff6e21a67a106d27fd38979ad20752.tar.xz
player/{core,loadfile}: make cover art loading more explicit
Now loading cover art through mp_add_external_file requires an additional argument to be set to true. This way not all video-add commands end up being marked as cover art when they move through mp_add_external_file, as originally changed in 55d7f9ded197d82d172b7baf74b1a07640361ae8 . Additionally, this lets us clean up some logic that would otherwise be duplicated between open_external_files and autoload_external_files, if the logic had been kept split from mp_add_external_file. Fixes #8358
-rw-r--r--player/command.c5
-rw-r--r--player/core.h3
-rw-r--r--player/loadfile.c18
3 files changed, 16 insertions, 10 deletions
diff --git a/player/command.c b/player/command.c
index f28bd120be..96e5daef77 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5260,7 +5260,7 @@ static void cmd_track_add(void *p)
}
}
int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type,
- cmd->abort->cancel);
+ cmd->abort->cancel, false);
if (first < 0) {
cmd->success = false;
return;
@@ -5324,7 +5324,8 @@ static void cmd_track_reload(void *p)
if (t && t->is_external && t->external_filename) {
char *filename = talloc_strdup(NULL, t->external_filename);
mp_remove_track(mpctx, t);
- nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel);
+ nt_num = mp_add_external_file(mpctx, filename, type, cmd->abort->cancel,
+ false);
talloc_free(filename);
}
diff --git a/player/core.h b/player/core.h
index f2f0a15a00..fcb513bed1 100644
--- a/player/core.h
+++ b/player/core.h
@@ -528,7 +528,8 @@ void mp_abort_trigger_locked(struct MPContext *mpctx,
struct mp_abort_entry *abort);
void uninit_player(struct MPContext *mpctx, unsigned int mask);
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);
void mark_track_selection(struct MPContext *mpctx, int order,
enum stream_type type, int value);
#define FLAG_MARK_SELECTION 1
diff --git a/player/loadfile.c b/player/loadfile.c
index 058be92c83..6032cf6193 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -758,7 +758,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 +833,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 +859,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 +900,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);
}