mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
player: print only changed tags
The code in the demuxer etc. was changed to update all metadata/tags at once, instead of changing each metadata field. As a consequence, printing of the tags to the terminal was also changed to print everything on each change. Some users didn't like this. Add a very primitive way to avoid printing fields with the same value again if metadata is marked as changed. This is not always correct (could print unchanged fields anyway), but usually works. (In general, a rather roundabout way to reflect a changed title with ICY streaming...) Fixes #813 (let's call it a "policy change").
This commit is contained in:
parent
fcd2ea7601
commit
9f4b01400e
@ -196,6 +196,7 @@ typedef struct MPContext {
|
||||
double video_offset;
|
||||
|
||||
struct demuxer *demuxer;
|
||||
struct mp_tags *tags;
|
||||
|
||||
struct track **tracks;
|
||||
int num_tracks;
|
||||
|
@ -167,11 +167,27 @@ void update_demuxer_properties(struct MPContext *mpctx)
|
||||
}
|
||||
tracks->events &= ~DEMUX_EVENT_STREAMS;
|
||||
}
|
||||
struct mp_tags *info = demuxer->metadata;
|
||||
if ((events & DEMUX_EVENT_METADATA) && info->num_keys) {
|
||||
MP_INFO(mpctx, "File tags:\n");
|
||||
for (int n = 0; n < info->num_keys; n++)
|
||||
if (events & DEMUX_EVENT_METADATA) {
|
||||
struct mp_tags *info = demuxer->metadata;
|
||||
// prev is used to attempt to print changed tags only (to some degree)
|
||||
struct mp_tags *prev = mpctx->tags;
|
||||
int n_prev = 0;
|
||||
bool had_output = false;
|
||||
for (int n = 0; n < info->num_keys; n++) {
|
||||
if (prev && n_prev < prev->num_keys) {
|
||||
if (strcmp(prev->keys[n_prev], info->keys[n]) == 0) {
|
||||
n_prev++;
|
||||
if (strcmp(prev->values[n_prev - 1], info->values[n]) == 0)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!had_output)
|
||||
MP_INFO(mpctx, "File tags:\n");
|
||||
MP_INFO(mpctx, " %s: %s\n", info->keys[n], info->values[n]);
|
||||
had_output = true;
|
||||
}
|
||||
talloc_free(mpctx->tags);
|
||||
mpctx->tags = mp_tags_dup(mpctx, info);
|
||||
mp_notify(mpctx, MPV_EVENT_METADATA_UPDATE, NULL);
|
||||
}
|
||||
demuxer->events = 0;
|
||||
@ -1189,6 +1205,9 @@ terminate_playback:
|
||||
|
||||
m_config_restore_backups(mpctx->mconfig);
|
||||
|
||||
talloc_free(mpctx->tags);
|
||||
mpctx->tags = NULL;
|
||||
|
||||
mpctx->playback_initialized = false;
|
||||
|
||||
mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user