Commit 81cbd185 authored by Rémi Duraffort's avatar Rémi Duraffort

xosd:

 * fix playlist lock (maybe not perfect)
 * add some forgotten vlc_restaure_cancel
 * simplifications
parent e3cffc1f
...@@ -215,62 +215,68 @@ static void Run( intf_thread_t *p_intf ) ...@@ -215,62 +215,68 @@ static void Run( intf_thread_t *p_intf )
{ {
playlist_t *p_playlist; playlist_t *p_playlist;
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
input_item_t *p_input;
char psz_duration[MSTRTIME_MAX_SIZE+2];
char *psz_display = NULL; char *psz_display = NULL;
for( ;; ) for( ;; )
{ {
int canc = vlc_savecancel(); int canc = vlc_savecancel();
if( p_intf->p_sys->b_need_update == true ) if( p_intf->p_sys->b_need_update == true )
{ {
p_intf->p_sys->b_need_update = false; p_intf->p_sys->b_need_update = false;
p_playlist = pl_Hold( p_intf ); p_playlist = pl_Hold( p_intf );
PL_LOCK;
if( playlist_IsEmpty( p_playlist ) ) if( playlist_IsEmpty( p_playlist ) )
{ {
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
vlc_restorecancel( canc );
continue; continue;
} }
free( psz_display ); free( psz_display );
psz_display = NULL;
int i_status = playlist_Status( p_playlist ); int i_status = playlist_Status( p_playlist );
if( i_status == PLAYLIST_STOPPED ) if( i_status == PLAYLIST_STOPPED )
{ {
psz_display = strdup(_("Stop")); psz_display = strdup(_("Stop"));
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
} }
else if( i_status == PLAYLIST_PAUSED ) else if( i_status == PLAYLIST_PAUSED )
{ {
psz_display = strdup(_("Pause")); psz_display = strdup(_("Pause"));
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
} }
else else
{ {
p_item = playlist_CurrentPlayingItem( p_playlist ); p_item = playlist_CurrentPlayingItem( p_playlist );
p_input = p_item->p_input;
pl_Release( p_intf );
if( !p_item ) if( !p_item )
{
PL_UNLOCK;
pl_Release( p_intf );
vlc_restorecancel( canc );
continue; continue;
}
input_item_t *p_input = p_item->p_input;
vlc_gc_incref( p_input );
PL_UNLOCK;
pl_Release( p_intf );
mtime_t i_duration = input_item_GetDuration( p_input ); mtime_t i_duration = input_item_GetDuration( p_input );
if( i_duration != -1 ) if( i_duration != -1 )
{ {
char psz_durationstr[MSTRTIME_MAX_SIZE]; char psz_durationstr[MSTRTIME_MAX_SIZE];
secstotimestr( psz_durationstr, i_duration / 1000000 ); secstotimestr( psz_durationstr, i_duration / 1000000 );
sprintf( psz_duration, "(%s)", psz_durationstr ); if( asprintf( &psz_display, "%s (%s)", p_input->psz_name, psz_durationstr ) == -1 )
psz_display = NULL;
} }
else else
{ psz_display = strdup( p_input->psz_name );
sprintf( psz_duration," " );
}
psz_display = (char *)malloc( vlc_gc_decref( p_input );
(strlen( p_input->psz_name ) +
MSTRTIME_MAX_SIZE + 2+6 + 10 +10 ));
sprintf( psz_display,"%s %s",
p_input->psz_name, psz_duration);
} }
/* Display */ /* Display */
...@@ -279,7 +285,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -279,7 +285,6 @@ static void Run( intf_thread_t *p_intf )
XOSD_string, XOSD_string,
psz_display ); psz_display );
} }
vlc_restorecancel( canc ); vlc_restorecancel( canc );
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment