0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02: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:
wm4 2014-12-19 23:54:21 +01:00
parent fcd2ea7601
commit 9f4b01400e
2 changed files with 24 additions and 4 deletions

View File

@ -196,6 +196,7 @@ typedef struct MPContext {
double video_offset;
struct demuxer *demuxer;
struct mp_tags *tags;
struct track **tracks;
int num_tracks;

View File

@ -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);