static void FreeRSS( filter_t * );
static int ParseUrls( filter_t *, char * );
+static void Fetch( void * );
+
static const int pi_color_values[] = {
0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00,
struct filter_sys_t
{
vlc_mutex_t lock;
+ vlc_timer_t timer; /* Timer to refresh the rss feeds */
+ bool b_fetched;
int i_xoff, i_yoff; /* offsets for the display string in the video window */
int i_pos; /* permit relative positioning (top, bottom, left, right, center) */
rss_feed_t *p_feeds;
int i_ttl;
- time_t t_last_update;
bool b_images;
int i_title;
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
- int i_feed;
int i_ret = VLC_ENOMEM;
char *psz_urls;
}
free( psz_urls );
- if( FetchRSS( p_filter ) )
- {
- msg_Err( p_filter, "failed while fetching RSS ... too bad" );
- text_style_Delete( p_sys->p_style );
- i_ret = VLC_EGENERIC;
- goto error;
- }
- p_sys->t_last_update = time( NULL );
-
- if( p_sys->i_feeds == 0 )
- {
- text_style_Delete( p_sys->p_style );
- i_ret = VLC_EGENERIC;
- goto error;
- }
- for( i_feed=0; i_feed < p_sys->i_feeds; i_feed ++ )
- {
- if( p_sys->p_feeds[i_feed].i_items == 0 )
- {
- DestroyFilter( p_this );
- return VLC_EGENERIC;
- }
- }
-
/* Misc init */
vlc_mutex_init( &p_sys->lock );
p_filter->pf_sub_filter = Filter;
p_sys->last_date = (mtime_t)0;
+ p_sys->b_fetched = false;
+
+ /* Create and arm the timer */
+ if( vlc_timer_create( &p_sys->timer, Fetch, p_filter ) )
+ {
+ vlc_mutex_destroy( &p_sys->lock );
+ goto error;
+ }
+ vlc_timer_schedule( p_sys->timer, false, 1,
+ (mtime_t)(p_sys->i_ttl)*1000000 );
return VLC_SUCCESS;
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
+ vlc_timer_destroy( p_sys->timer );
vlc_mutex_destroy( &p_sys->lock );
+
text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee );
FreeRSS( p_filter );
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( 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 )
/* ( ... ? 5 : 1 ) means "wait 5 times more for the 1st char" */
return NULL;
}
- /* Do we need to update the feeds ? */
- if( p_sys->i_ttl
- && time( NULL ) > p_sys->t_last_update + (time_t)p_sys->i_ttl )
- {
- msg_Dbg( p_filter, "Forcing update of all the RSS feeds" );
- if( FetchRSS( p_filter ) )
- {
- msg_Err( p_filter, "Failed while fetching RSS ... too bad" );
- vlc_mutex_unlock( &p_sys->lock );
- return NULL; /* FIXME : we most likely messed up all the data,
- * so we might need to do something about it */
- }
- p_sys->t_last_update = time( NULL );
- }
-
p_sys->last_date = date;
p_sys->i_cur_char++;
if( p_sys->i_cur_item == -1 ? p_sys->p_feeds[p_sys->i_cur_feed].psz_title[p_sys->i_cur_char] == 0 : p_sys->p_feeds[p_sys->i_cur_feed].p_items[p_sys->i_cur_item].psz_title[p_sys->i_cur_char] == 0 )
/****************************************************************************
- * Parse url list, psz_urls must be non empty
+ * Parse url list, psz_urls must be non empty (TODO: check it !)
***************************************************************************/
static int ParseUrls( filter_t *p_filter, char *psz_urls )
{
free( p_sys->p_feeds );
p_sys->i_feeds = 0;
}
+
+static void Fetch( void *p_data )
+{
+ filter_t *p_filter = p_data;
+ filter_sys_t *p_sys = p_filter->p_sys;
+
+ vlc_mutex_lock( &p_sys->lock );
+ FetchRSS( p_filter );
+ p_sys->b_fetched = true;
+ vlc_mutex_unlock( &p_sys->lock );
+}