[gnome-music/wip/jfelder/async-writeback: 25/25] coregrilo: Use the async version of grl_source_store_metadata
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/async-writeback: 25/25] coregrilo: Use the async version of grl_source_store_metadata
- Date: Fri, 14 Feb 2020 14:36:58 +0000 (UTC)
commit 07a04dfc1f37b7aa6e9577332a43dffb6a09dec6
Author: Jean Felder <jfelder src gnome org>
Date: Fri Jan 31 11:07:37 2020 +0100
coregrilo: Use the async version of grl_source_store_metadata
grl_source_store_metadata is used by the Tracker source to update
information of a song (for example its play count).
The sync version is used because of an introspection annotation
issue. This is fixed since grilo version 0.3.12.
The async version can now be used.
See: https://gitlab.gnome.org/GNOME/grilo/merge_requests/53
gnomemusic/coregrilo.py | 32 ++++++++++++++------------------
meson.build | 2 +-
2 files changed, 15 insertions(+), 19 deletions(-)
---
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 5cce9bc5..f34cef95 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -164,29 +164,25 @@ class CoreGrilo(GObject.GObject):
for wrapper in self._wrappers.values():
wrapper.populate_album_disc_songs(media, discnr, callback)
- def _store_metadata(self, source, media, key):
- """Convenience function to store metadata
+ def writeback(self, media, key):
+ """Store the values associated with the key.
- Wrap the metadata store call in a idle_add compatible form.
- :param source: A Grilo source object
- :param media: A Grilo media item
- :param key: A Grilo metadata key
+ :param Grl.Media media: A Grilo media item
+ :param int key: a Grilo metadata key
"""
- # FIXME: Doing this async crashes.
- try:
- source.store_metadata_sync(
- media, [key], Grl.WriteFlags.NORMAL)
- except GLib.Error as error:
- self._log.warning(
- "Error {}: {}".format(error.domain, error.message))
-
- return GLib.SOURCE_REMOVE
+ def _store_metadata_cb(source, media, failed_keys, data, error):
+ if error is not None:
+ self._log.warning(
+ "Error {}: {}".format(error.domain, error.message))
+ if failed_keys:
+ self._log.warning(
+ "Unable to update the following keys", failed_keys)
- def writeback(self, media, key):
for wrapper in self._wrappers.values():
if media.get_source() == wrapper.source.props.source_id:
- GLib.idle_add(
- self._store_metadata, wrapper.props.source, media, key)
+ wrapper.props.source.store_metadata(
+ media, [key], Grl.WriteFlags.NORMAL, _store_metadata_cb,
+ None)
break
def search(self, text):
diff --git a/meson.build b/meson.build
index a9310adf..1f4122b1 100644
--- a/meson.build
+++ b/meson.build
@@ -45,7 +45,7 @@ dependency('libsoup-2.4')
dependency('tracker-sparql-2.0', version: '>= 2.3.0')
dependency('pygobject-3.0', version: '>= 3.29.1')
dependency('py3cairo', version: '>= 1.14.0')
-dependency('grilo-0.3', version: '>= 0.3.9', fallback: ['grilo', 'libgrl_dep'])
+dependency('grilo-0.3', version: '>= 0.3.12', fallback: ['grilo', 'libgrl_dep'])
dependency('grilo-plugins-0.3', version: '>= 0.3.10', fallback: ['grilo-plugins', 'grilo_plugins_dep'])
subproject('libgd',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]