diff options
author | wm4 <wm4@nowhere> | 2014-12-19 23:54:21 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-12-19 23:54:21 +0100 |
commit | 9f4b01400ea515b295ad9f0b92d011e80ed0389f (patch) | |
tree | 44c2991220f5ca349d62afaf823250a95b323784 /player/loadfile.c | |
parent | fcd2ea760108ebc1c3eb59e443407e91b8a33e6b (diff) | |
download | mpv-9f4b01400ea515b295ad9f0b92d011e80ed0389f.tar.bz2 mpv-9f4b01400ea515b295ad9f0b92d011e80ed0389f.tar.xz |
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").
Diffstat (limited to 'player/loadfile.c')
-rw-r--r-- | player/loadfile.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index d1b77743e6..624f6beebc 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -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); |