summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-06 13:41:20 +0100
committerwm4 <wm4@nowhere>2014-02-06 13:41:20 +0100
commiteb1ec14b67462c6a1420e2fa67b8213cad83b297 (patch)
tree1b31c7c323dfb21da94bf0cf5528e5093f3b5476 /demux/demux.c
parent5693b5ae16217eb62f4fad43ab90a310dfca4f41 (diff)
downloadmpv-eb1ec14b67462c6a1420e2fa67b8213cad83b297.tar.bz2
mpv-eb1ec14b67462c6a1420e2fa67b8213cad83b297.tar.xz
demux: handle tag updates differently
Instead of printing lines like: Demuxer info GENRE changed to Alternative Rock Just output all tags once they change. The assumption is that individual tags rarely change, while all tags change in the common case. This changes tag updates to use polling. This could be fixed later, although the ICY stuff makes it a bit painful, so maybe it will remain this way. Also remove DEMUXER_CTRL_UPDATE_INFO. This was intended to check for tag updates, but now we use a different approach.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/demux/demux.c b/demux/demux.c
index fe5ac6a3d6..ceaa9db79c 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -720,19 +720,11 @@ int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param)
int demux_info_add_bstr(demuxer_t *demuxer, struct bstr opt, struct bstr param)
{
- char *oldval = mp_tags_get_bstr(demuxer->metadata, opt);
- if (oldval) {
- if (bstrcmp0(param, oldval) == 0)
- return 0;
- MP_INFO(demuxer, "Demuxer info %.*s changed to %.*s\n",
- BSTR_P(opt), BSTR_P(param));
- }
-
mp_tags_set_bstr(demuxer->metadata, opt, param);
return 1;
}
-int demux_info_print(demuxer_t *demuxer)
+static int demux_info_print(demuxer_t *demuxer)
{
struct mp_tags *info = demuxer->metadata;
int n;
@@ -760,14 +752,29 @@ char *demux_info_get(demuxer_t *demuxer, const char *opt)
void demux_info_update(struct demuxer *demuxer)
{
- demux_control(demuxer, DEMUXER_CTRL_UPDATE_INFO, NULL);
+ struct mp_tags *tags = demuxer->metadata;
// Take care of stream metadata as well
char **meta;
if (stream_control(demuxer->stream, STREAM_CTRL_GET_METADATA, &meta) > 0) {
for (int n = 0; meta[n + 0]; n += 2)
- demux_info_add(demuxer, meta[n + 0], meta[n + 1]);
+ mp_tags_set_str(tags, meta[n + 0], meta[n + 1]);
talloc_free(meta);
}
+ // Check for metadata changes the hard way.
+ char *data = talloc_strdup(demuxer, "");
+ for (int n = 0; n < tags->num_keys; n++) {
+ data = talloc_asprintf_append_buffer(data, "%s=%s\n", tags->keys[n],
+ tags->values[n]);
+ }
+ if (!demuxer->previous_metadata ||
+ strcmp(demuxer->previous_metadata, data) != 0)
+ {
+ talloc_free(demuxer->previous_metadata);
+ demuxer->previous_metadata = data;
+ demux_info_print(demuxer);
+ } else {
+ talloc_free(data);
+ }
}
int demux_control(demuxer_t *demuxer, int cmd, void *arg)