# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <stdio.h>
#endif
#include <vlc_codec.h>
-#include <vlc_input.h>
#include <vlc_interface.h>
-#include <vlc_vout.h>
#include <vlc_playlist.h>
#include <vlc_osd.h>
-#include "vlc_keys.h"
+#include <vlc_keys.h>
#include "browser_open.h"
#include "history.h"
#include "xstrcat.h"
#include "xurl.h"
-#undef CMML_INTF_USE_TIMED_URIS
+#undef CMML_INTF_USE_TIMED_URIS
#undef CMML_INTF_DEBUG
#undef CMML_INTF_HISTORY_DEBUG
*****************************************************************************/
struct intf_sys_t
{
+ vlc_mutex_t lock;
decoder_t * p_cmml_decoder;
input_thread_t * p_input;
vlc_value_t, vlc_value_t, void * );
static char *GetTimedURLFromPlaylistItem( intf_thread_t *, playlist_item_t * );
-static char *GetTimedURIFragmentForTime ( int );
+#ifdef CMML_INTF_USE_TIMED_URIS
static int GetCurrentTimeInSeconds ( input_thread_t * );
+static char *GetTimedURIFragmentForTime ( int );
+#endif
static int DisplayAnchor ( intf_thread_t *, vout_thread_t *,
char *, char * );
static int DisplayPendingAnchor ( intf_thread_t *, vout_thread_t * );
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
- {
- return( 1 );
- };
+ return VLC_ENOMEM;
p_intf->pf_run = RunIntf;
+ vlc_mutex_init( &p_intf->p_sys->lock );
var_AddCallback( p_intf->p_libvlc, "key-action", KeyEvent, p_intf );
/* we also need to add the callback for "mouse-clicked", but do that later
var_AddCallback( p_intf->p_libvlc, "browse-follow-anchor",
FollowAnchorCallback, p_intf );
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
vlc_object_release( p_intf->p_sys->p_cmml_decoder );
+ vlc_mutex_destroy( &p_intf->p_sys->lock );
free( p_intf->p_sys );
}
*****************************************************************************/
static void RunIntf( intf_thread_t *p_intf )
{
+ int canc = vlc_savecancel();
vout_thread_t * p_vout = NULL;
if( InitThread( p_intf ) < 0 )
#endif
/* Main loop */
- while( !p_intf->b_die )
+ while( vlc_object_alive (p_intf) )
{
/* if video output is dying, disassociate ourselves from it */
- if( p_vout && p_vout->b_die )
+ if( p_vout && !vlc_object_alive (p_vout) )
{
var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
vlc_object_release( p_vout );
}
}
- vlc_mutex_lock( &p_intf->change_lock );
+ vlc_mutex_lock( &p_intf->p_sys->lock );
/*
* keyboard event
break;
}
p_intf->p_sys->i_key_action = 0;
- vlc_mutex_unlock( &p_intf->change_lock );
+ vlc_mutex_unlock( &p_intf->p_sys->lock );
(void) DisplayPendingAnchor( p_intf, p_vout );
}
vlc_object_release( p_intf->p_sys->p_input );
+ vlc_restorecancel( canc );
}
/*****************************************************************************
if( p_vout != NULL )
{
- /* don't display anchor if main interface can display it */
- p_primary_intf = vlc_object_find( p_intf->p_libvlc, VLC_OBJECT_INTF,
- FIND_CHILD );
-
- if( p_primary_intf )
- {
- if( var_Get( p_primary_intf, "intf-displays-cmml-description", &val )
- == VLC_SUCCESS )
- {
- if( val.b_bool == true )
- {
- vlc_object_release( p_primary_intf );
- return true;
- }
- }
-
- vlc_object_release( p_primary_intf );
- }
-
/* display anchor as subtitle on-screen */
if( DisplayAnchor( p_intf, p_vout, psz_description, psz_url )
!= VLC_SUCCESS )
static int InitThread( intf_thread_t * p_intf )
{
/* We might need some locking here */
- if( !p_intf->b_die )
+ if( vlc_object_alive (p_intf) )
{
input_thread_t * p_input;
decoder_t *p_cmml_decoder;
return VLC_EGENERIC;
}
- vlc_mutex_lock( &p_intf->change_lock );
+ vlc_mutex_lock( &p_intf->p_sys->lock );
p_intf->p_sys->p_input = p_input;
p_intf->p_sys->p_cmml_decoder = p_cmml_decoder;
p_intf->p_sys->i_key_action = 0;
- vlc_mutex_unlock( &p_intf->change_lock );
+ vlc_mutex_unlock( &p_intf->p_sys->lock );
return VLC_SUCCESS;
}
VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
VLC_UNUSED(oldval); VLC_UNUSED(newval);
intf_thread_t *p_intf = (intf_thread_t *)p_data;
- vlc_mutex_lock( &p_intf->change_lock );
+
+ vlc_mutex_lock( &p_intf->p_sys->lock );
+ /* FIXME: key presses might get lost here... */
p_intf->p_sys->i_key_action = newval.i_int;
- vlc_mutex_unlock( &p_intf->change_lock );
+ vlc_mutex_unlock( &p_intf->p_sys->lock );
return VLC_SUCCESS;
}
mtime_t i_seconds;
vlc_value_t time;
- p_playlist = (playlist_t *) vlc_object_find( p_intf,
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
- if ( !p_playlist )
- {
- msg_Warn( p_intf, "can't find playlist" );
- return;
- }
+ p_playlist = pl_Hold( p_intf );
/* Get new URL */
- p_current_item = p_playlist->status.p_item;
+ p_current_item = playlist_CurrentPlayingItem( p_playlist );
char *psz_uri = input_item_GetURI( p_current_item->p_input );
#ifdef CMML_INTF_DEBUG
msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", psz_uri );
msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
#endif
(void) browser_Open( psz_url );
- playlist_Control( p_playlist, PLAYLIST_PAUSE, true, 0 );
+ playlist_Control( p_playlist, PLAYLIST_PAUSE, pl_Unlocked, 0 );
}
free( psz_uri_to_load );
return psz_return_value;
#else
VLC_UNUSED(p_intf);
- void *p;
-
- /* Suppress warning messages about unused functions */
- p = GetTimedURIFragmentForTime; /* unused */
- p = GetCurrentTimeInSeconds; /* unused */
return input_item_GetURI( p_current_item->p_input );
#endif
}
+
+#ifdef CMML_INTF_USE_TIMED_URIS
/*
* Get the current time, rounded down to the nearest second
*
{
char *psz_time;
- asprintf( &psz_time, "%d", seconds );
+ if( asprintf( &psz_time, "%d", seconds ) == -1 )
+ return NULL;
return psz_time;
}
+#endif
static
int GoBackCallback( vlc_object_t *p_this, char const *psz_var,
#endif
/* Find the playlist */
- p_playlist = (playlist_t *) vlc_object_find( p_intf,
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
- if ( !p_playlist )
- {
- msg_Warn( p_intf, "can't find playlist" );
- return;
- }
+ p_playlist = pl_Hold( p_intf );
/* Retrieve navigation history from playlist */
if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
return;
}
- p_current_item = p_playlist->status.p_item;
+ p_current_item = playlist_CurrentPlayingItem( p_playlist );
/* Save the currently-playing media in a new history item */
psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item );
#endif
/* Find the playlist */
- p_playlist = (playlist_t *) vlc_object_find( p_intf,
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
- if ( !p_playlist )
- {
- msg_Warn( p_intf, "can't find playlist" );
- return;
- }
+ p_playlist = pl_Hold( p_intf );
/* Retrieve navigation history from playlist */
if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS ||
vlc_object_release( p_playlist );
return;
}
- p_current_item = p_playlist->status.p_item;
+ p_current_item = playlist_CurrentPlayingItem( p_playlist );
p_new_history_item->psz_uri = GetTimedURLFromPlaylistItem( p_intf,
p_current_item );
p_new_history_item->psz_name = p_new_history_item->psz_uri;