[grilo] Check media when resolving key dependencies
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] Check media when resolving key dependencies
- Date: Tue, 15 Jun 2010 17:04:12 +0000 (UTC)
commit 6c5ecbda5a3bcdb3432874edb9321b955a72ad94
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Tue Jun 15 18:57:52 2010 +0200
Check media when resolving key dependencies
When requesting metadata() for a media, it could be possible that one of the
requested keys depends on another key which value is already set in media
(because a previous operation already set it, or because client set it
manually).
In this case, we can consider that the requested key can be satisfied, so it is
not needed to check if the dependent key can be provided by any source.
src/grl-media-source.c | 11 ++++-------
src/grl-metadata-source-priv.h | 1 +
src/grl-metadata-source.c | 39 ++++++++++++++++++++++++++++++++-------
3 files changed, 37 insertions(+), 14 deletions(-)
---
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index d2290ec..3df08fa 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -1147,7 +1147,7 @@ grl_media_source_browse (GrlMediaSource *source,
if (flags & GRL_RESOLVE_FULL) {
g_debug ("requested full resolution");
grl_metadata_source_setup_full_resolution_mode (GRL_METADATA_SOURCE (source),
- _keys, &key_mapping);
+ NULL, _keys, &key_mapping);
/* If we do not have a source map for the unsupported keys then
we cannot resolve any of them */
@@ -1282,8 +1282,7 @@ grl_media_source_search (GrlMediaSource *source,
if (flags & GRL_RESOLVE_FULL) {
g_debug ("requested full search");
grl_metadata_source_setup_full_resolution_mode (GRL_METADATA_SOURCE (source),
- _keys,
- &key_mapping);
+ NULL, _keys, &key_mapping);
/* If we do not have a source map for the unsupported keys then
we cannot resolve any of them */
@@ -1415,8 +1414,7 @@ grl_media_source_query (GrlMediaSource *source,
if (flags & GRL_RESOLVE_FULL) {
g_debug ("requested full search");
grl_metadata_source_setup_full_resolution_mode (GRL_METADATA_SOURCE (source),
- _keys,
- &key_mapping);
+ NULL, _keys, &key_mapping);
/* If we do not have a source map for the unsupported keys then
we cannot resolve any of them */
@@ -1534,8 +1532,7 @@ grl_media_source_metadata (GrlMediaSource *source,
if (flags & GRL_RESOLVE_FULL) {
g_debug ("requested full metadata");
grl_metadata_source_setup_full_resolution_mode (GRL_METADATA_SOURCE (source),
- _keys,
- &key_mapping);
+ media, _keys, &key_mapping);
/* If we do not have a source map for the unsupported keys then
we cannot resolve any of them */
diff --git a/src/grl-metadata-source-priv.h b/src/grl-metadata-source-priv.h
index 1d39bb1..2d3d538 100644
--- a/src/grl-metadata-source-priv.h
+++ b/src/grl-metadata-source-priv.h
@@ -45,6 +45,7 @@ struct SourceKeyMapList {
G_BEGIN_DECLS
void grl_metadata_source_setup_full_resolution_mode (GrlMetadataSource *source,
+ GrlMedia *media,
const GList *keys,
struct SourceKeyMapList *key_mapping);
diff --git a/src/grl-metadata-source.c b/src/grl-metadata-source.c
index c32d0c6..5884181 100644
--- a/src/grl-metadata-source.c
+++ b/src/grl-metadata-source.c
@@ -789,6 +789,7 @@ grl_metadata_source_filter_writable (GrlMetadataSource *source,
void
grl_metadata_source_setup_full_resolution_mode (GrlMetadataSource *source,
+ GrlMedia *media,
const GList *keys,
struct SourceKeyMapList *key_mapping)
{
@@ -814,17 +815,18 @@ grl_metadata_source_setup_full_resolution_mode (GrlMetadataSource *source,
* 1) Find which sources (other than the current one) can resolve
* some of the missing keys
* 2) Check out dependencies for the keys they can resolve
- * 3) For each dependency list check if the original source can resolve them.
- * 3.1) Yes: Add key and dependencies to be resolved
- * 3.2) No: forget about that key and its dependencies
- * Ideally, we would check if other sources can resolve them
- * 4) Execute the user operation passing in our own callback
- * 5) For each result, check the sources that can resolve
+ * 2.1) If dependency is already resolved in Media, add key to be resolved
+ * 2.2) Else check if original source can resolve dependency.
+ * 2.2.1) Yes: Add key and dependencies to be resolved
+ * 2.2.2) No: forget about that key and its dependencies
+ * Ideally, we would check if other sources can resolve them
+ * 3) Execute the user operation passing in our own callback
+ * 4) For each result, check the sources that can resolve
* the missing metadata and issue resolution operations on them.
* We could do this once per source passing in a list with all the
* browse results. Problem is we lose response time although we gain
* overall efficiency.
- * 6) Invoke user callback with results
+ * 5) Invoke user callback with results
*/
/* Find which sources resolve which keys */
@@ -885,6 +887,29 @@ grl_metadata_source_setup_full_resolution_mode (GrlMetadataSource *source,
key_list = g_list_prepend (key_list, key);
continue;
}
+
+ if (media) {
+ g_debug (" Key '%s' might be resolved using current media",
+ GRL_METADATA_KEY_GET_NAME (key));
+ GList *iter_deps;
+ GList *iter_deps_prev;
+ iter_deps = deps;
+ while (iter_deps) {
+ if (grl_data_key_is_known (GRL_DATA (media), iter_deps->data)) {
+ iter_deps_prev = iter_deps;
+ iter_deps = g_list_next (iter_deps);
+ deps = g_list_delete_link (deps, iter_deps_prev);
+ } else {
+ iter_deps = g_list_next (iter_deps);
+ }
+ }
+ if (!deps) {
+ g_debug (" Key '%s' can be resolved solely using current media",
+ GRL_METADATA_KEY_GET_NAME (key));
+ continue;
+ }
+ }
+
g_debug (" Key '%s' might be resolved using external metadata",
GRL_METADATA_KEY_GET_NAME (key));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]