[grilo] media-source: manage end of search/browse with splitted sources



commit e713b75a81c82186bf9fd269693398c0ac1fec7d
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Wed Jun 29 14:13:38 2011 +0100

    media-source: manage end of search/browse with splitted sources
    
    When running in splitted modes (usually when dealing with websites),
    if you get less results than what the user would like to get, we
    currently end up in an infinite loop with the core of grilo keeping
    asking for new items from a source which can't deliver anymore.
    
    To manage this specific case, we just check whether the plugin has
    returned a remaining results number equals to 0 as well as a null
    item.
    
    Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>

 src/grl-media-source.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index c982c92..811e994 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -643,8 +643,6 @@ browse_result_relay_cb (GrlMediaSource *source,
 
   brc = (struct BrowseRelayCb *) user_data;
 
-  plugin_remaining = remaining;
-
   /* --- operation cancel management --- */
 
   /* Check if operation is still valid , otherwise do not emit the result
@@ -697,9 +695,13 @@ browse_result_relay_cb (GrlMediaSource *source,
     as_info->count--;
     as_info->chunk_consumed++;
 
-    /* FIXME: If we received less than we requested we should
-       not do an extra query */
-    remaining = as_info->count;
+    /* When auto split, if less results than what a chunk should give,
+     * that means we've reached the end of the results. */
+    if ((plugin_remaining == 0) &&
+        (as_info->chunk_consumed < as_info->chunk_requested))
+      remaining = 0;
+    else
+      remaining = as_info->count;
   }
 
   /* --- relay operation  --- */



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