struct file_tags *tags_dup (const struct file_tags *tags) { struct file_tags *dtags; assert (tags != NULL); dtags = tags_new(); tags_copy (dtags, tags); return dtags; }
/* Update tags if tags from the decoder or the stream are available. */ static void update_tags (const struct decoder *f, void *decoder_data, struct io_stream *s) { char *stream_title = NULL; int tags_changed = 0; struct file_tags *new_tags; new_tags = tags_new (); LOCK (curr_tags_mut); if (f->current_tags && f->current_tags(decoder_data, new_tags) && new_tags->title) { tags_changed = 1; tags_copy (curr_tags, new_tags); logit ("Tags change from the decoder"); tags_source = TAGS_SOURCE_DECODER; show_tags (curr_tags); } else if (s && (stream_title = io_get_metadata_title(s))) { if (curr_tags && curr_tags->title && tags_source == TAGS_SOURCE_DECODER) { logit ("New IO stream tags, ignored because there are " "decoder tags present"); free (stream_title); } else { tags_clear (curr_tags); curr_tags->title = stream_title; show_tags (curr_tags); tags_changed = 1; logit ("New IO stream tags"); tags_source = TAGS_SOURCE_METADATA; } } if (tags_changed) tags_change (); tags_free (new_tags); UNLOCK (curr_tags_mut); }