audio: Only emit tags changed when tags changed.

Previously we alerted AudioListeners about all new tags, now we filter it down
to just the changed ones. Only real reason for this is that the changed
messages spam the log output making debugging harder.
This commit is contained in:
Thomas Adamcik 2016-02-13 22:34:09 +01:00
parent 69a52bf031
commit c23cad5d13
2 changed files with 14 additions and 3 deletions

View File

@ -326,9 +326,19 @@ class _Handler(object):
def on_tag(self, taglist):
tags = tags_lib.convert_taglist(taglist)
gst_logger.debug('Got TAG bus message: tags=%r', dict(tags))
self._audio._tags.update(tags)
logger.debug('Audio event: tags_changed(tags=%r)', tags.keys())
AudioListener.send('tags_changed', tags=tags.keys())
# TODO: Add proper tests for only emitting changed tags.
unique = object()
changed = []
for key, value in tags.items():
# Update any tags that changed, and store changed keys.
if self._audio._tags.get(key, unique) != value:
self._audio._tags[key] = value
changed.append(key)
if changed:
logger.debug('Audio event: tags_changed(tags=%r)', changed)
AudioListener.send('tags_changed', tags=changed)
def on_missing_plugin(self, msg):
desc = GstPbutils.missing_plugin_message_get_description(msg)

View File

@ -58,6 +58,7 @@ gstreamer-GstTagList.html
log.TRACE_LOG_LEVEL,
'Ignoring unknown tag data: %r = %r', tag, value)
# TODO: dict(result) to not leak the defaultdict, or just use setdefault?
return result