[PATCH] media-source: avoid some useless call the grl_metadata_source_resolve()



From: Lionel Landwerlin <lionel g landwerlin linux intel com>

When doing a full metadata resolution, avoid to call
grl_metadata_source_resolve on sources that can not actually fill new
metadata keys.

Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>
---
 src/grl-media-source.c |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index f32346c..df5a731 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -1339,15 +1339,30 @@ metadata_full_resolution_ctl_cb (GrlMediaSource *source,
                grl_metadata_source_get_name (_source));
 
     if (grl_metadata_source_supported_operations (_source) & GRL_OP_RESOLVE) {
-      grl_metadata_source_resolve (_source,
-                                   /* all keys are asked, metadata sources
-                                    * should check what's already in media */
-                                   ctl_info->keys,
-                                   media,
-                                   ctl_info->flags,
-                                   metadata_full_resolution_done_cb,
-                                   done_info);
-      done_info->pending_callbacks++;
+      GList *key = ctl_info->keys;
+
+      /* First, let's find out if this source can actually resolve something. */
+      while (key) {
+        if (grl_metadata_source_may_resolve (_source,
+                                             media,
+                                             key->data,
+                                             NULL))
+          break;
+        key = key->next;
+      }
+
+      /* If it does, then call resolve. */
+      if (key) {
+        grl_metadata_source_resolve (_source,
+                                     /* all keys are asked, metadata sources
+                                      * should check what's already in media */
+                                     ctl_info->keys,
+                                     media,
+                                     ctl_info->flags,
+                                     metadata_full_resolution_done_cb,
+                                     done_info);
+        done_info->pending_callbacks++;
+      }
     }
   }
   g_list_free (sources);
-- 
1.7.4.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]