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:
parent
69a52bf031
commit
c23cad5d13
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user