[vlc-commits] spu: rss: Fix TODOs: If no item exists then RSS feed is skipped

Daniel Glaas git at videolan.org
Fri Sep 4 09:00:14 CEST 2020


vlc | branch: master | Daniel Glaas <daniel.glaas at freenet.de> | Wed Aug 26 01:10:15 2020 +0200| [1e44ca26ffe72af48abfd732bdb75eac9f8d1624] | committer: Thomas Guillem

spu: rss: Fix TODOs: If no item exists then RSS feed is skipped

In function *Filter, there already existed a TODO note that it needs to be
checked whether the feeds have items at all. As this can change with every
parsing of the URLs, this can only be done dynamically at that point in time
when the display is rendered.

The TODO note in the function comment of ParseUrls seems to be outdated as the
check for an non empty url string is already done in function CreateFilter() in
lines 263..268.

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e44ca26ffe72af48abfd732bdb75eac9f8d1624
---

 modules/spu/rss.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/modules/spu/rss.c b/modules/spu/rss.c
index 0c86963843..95f55e34a4 100644
--- a/modules/spu/rss.c
+++ b/modules/spu/rss.c
@@ -347,6 +347,11 @@ static void DestroyFilter( vlc_object_t *p_this )
     free( p_sys );
 }
 
+static void switchToNextFeed(filter_sys_t *p_sys)
+{
+    p_sys->i_cur_feed = (p_sys->i_cur_feed + 1)%p_sys->i_feeds;
+}
+
 /****************************************************************************
  * Filter: the whole thing
  ****************************************************************************
@@ -365,13 +370,21 @@ static subpicture_t *Filter( filter_t *p_filter, vlc_tick_t date )
     vlc_mutex_lock( &p_sys->lock );
 
     /* Check if the feeds have been fetched and that we have some feeds */
-    /* TODO: check that we have items for each feeds */
     if( !p_sys->b_fetched && p_sys->i_feeds > 0 )
     {
         vlc_mutex_unlock( &p_sys->lock );
         return NULL;
     }
 
+    /* If the current feed has no item then switch to the next feed
+       and skip further processing */
+    if (p_sys->p_feeds[p_sys->i_cur_feed].i_items == 0)
+    {
+        switchToNextFeed(p_sys);
+        vlc_mutex_unlock( &p_sys->lock );
+        return NULL;
+    }
+
     if( p_sys->last_date
        + ( p_sys->i_cur_char <= 0 &&
            p_sys->i_cur_item == ( p_sys->i_title == scroll_title ? -1 : 0 ) ? 5 : 1 )
@@ -397,7 +410,7 @@ static subpicture_t *Filter( filter_t *p_filter, vlc_tick_t date )
                 p_sys->i_cur_item = -1;
             else
                 p_sys->i_cur_item = 0;
-            p_sys->i_cur_feed = (p_sys->i_cur_feed + 1)%p_sys->i_feeds;
+            switchToNextFeed(p_sys);
         }
     }
 
@@ -625,7 +638,7 @@ static char *removeWhiteChars( const char *psz_src )
 
 
 /****************************************************************************
- * Parse url list, psz_urls must be non empty (TODO: check it !)
+ * Parse url list, psz_urls must be non empty (ensured by check in CreateFilter() )
  ***************************************************************************/
 static int ParseUrls( filter_t *p_filter, char *psz_urls )
 {



More information about the vlc-commits mailing list