static int TrackChange( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data );
-static int GetInputMeta ( input_item_t *p_input,
+static int GetInputMeta ( input_item_t *p_input,
DBusMessageIter *args);
struct intf_sys_t
/*****************************************************************************
* Methods
*****************************************************************************/
-#if 0
-DBUS_METHOD( PlaylistExport_XSPF )
-{ /*export playlist to an xspf file */
-
- /* reads the filename to export to */
- /* returns the status as int32:
- * 0 : success
- * 1 : error
- * 2 : playlist empty
- */
- REPLY_INIT;
- OUT_ARGUMENTS;
-
- DBusError error;
- dbus_error_init( &error );
-
- char *psz_file;
- dbus_int32_t i_ret;
-
- dbus_message_get_args( p_from, &error,
- DBUS_TYPE_STRING, &psz_file,
- DBUS_TYPE_INVALID );
-
- if( dbus_error_is_set( &error ) )
- {
- msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s\n",
- error.message );
- dbus_error_free( &error );
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
-
- playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
-
- if( ( !playlist_IsEmpty( p_playlist ) ) &&
- ( p_playlist->p_root_category->i_children > 0 ) )
- {
- if( playlist_Export( p_playlist, psz_file,
- p_playlist->p_root_category->pp_children[0],
- "export-xspf" ) == VLC_SUCCESS )
- i_ret = 0;
- else
- i_ret = 1;
- }
- else
- i_ret = 2;
-
- pl_Release( ((vlc_object_t*) p_this ) );
-
- ADD_INT32( &i_ret );
- REPLY_SEND;
-}
-#endif
/* Player */
}
DBUS_METHOD( PositionGet )
-{ /* returns position as an int in the range [0;1000] */
+{ /* returns position in milliseconds */
REPLY_INIT;
OUT_ARGUMENTS;
vlc_value_t position;
i_pos = 0;
else
{
- var_Get( p_input, "position", &position );
- i_pos = position.f_float * 1000 ;
+ var_Get( p_input, "time", &position );
+ i_pos = position.i_time / 1000;
}
pl_Release( ((vlc_object_t*) p_this) );
ADD_INT32( &i_pos );
}
DBUS_METHOD( PositionSet )
-{ /* set position from an int in the range [0;1000] */
+{ /* set position in milliseconds */
REPLY_INIT;
vlc_value_t position;
if( p_input )
{
- position.f_float = ((float)i_pos) / 1000;
- var_Set( p_input, "position", position );
+ position.i_time = i_pos * 1000;
+ var_Set( p_input, "time", position );
}
pl_Release( ((vlc_object_t*) p_this) );
REPLY_SEND;
REPLY_SEND;
}
-DBUS_METHOD( Disconnect )
-{
- REPLY_INIT;
- DBusError error;
- int i;
- dbus_error_init( &error );
- i = dbus_bus_release_name( p_conn, VLC_MPRIS_DBUS_SERVICE, &error );
- if( ( i == -1 ) && ( dbus_error_is_set( &error ) ) )
- {
- msg_Err( (vlc_object_t*) p_this, "D-Bus disconnection failed : %s\n",
- error.message );
- dbus_error_free( &error );
- }
- REPLY_SEND;
-}
-
DBUS_METHOD( GetCurrentMetadata )
{
REPLY_INIT;
OUT_ARGUMENTS;
playlist_t* p_playlist = pl_Yield( (vlc_object_t*) p_this );
- GetInputMeta( p_playlist->status.p_item->p_input, &args );
+ if( p_playlist->status.p_item )
+ GetInputMeta( p_playlist->status.p_item->p_input, &args );
pl_Release( p_playlist );
REPLY_SEND;
{
REPLY_INIT;
OUT_ARGUMENTS;
- char *psz_identity = malloc( strlen( PACKAGE ) + strlen( VERSION ) + 1 );
+ char *psz_identity = malloc( strlen( PACKAGE ) + strlen( VERSION ) + 2 );
sprintf( psz_identity, "%s %s", PACKAGE, VERSION );
ADD_STRING( &psz_identity );
free( psz_identity );
{
REPLY_INIT;
OUT_ARGUMENTS;
+ /* FIXME 0 indicates the first item,
+ * what to do if we're stopped, or empty ? */
dbus_int32_t i_position = 0;
playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
playlist_item_t* p_tested_item = p_playlist->p_root_onelevel;
- while ( p_tested_item->p_input->i_id !=
- p_playlist->status.p_item->p_input->i_id )
- {
- i_position++;
- TEST_NEXT;
- }
-
+ if( p_playlist->status.p_item )
+ while ( p_tested_item && p_tested_item->p_input->i_id !=
+ p_playlist->status.p_item->p_input->i_id )
+ {
+ i_position++;
+ TEST_NEXT_ITEM;
+ }
+ /* FIXME if p_tested_item is NULL at that point, what do we do ? */
pl_Release( p_playlist );
ADD_INT32( &i_position );
playlist_item_t* p_tested_item = p_playlist->p_root_onelevel;
dbus_message_get_args( p_from, &error,
- DBUS_TYPE_INT32, &i_position,
- DBUS_TYPE_INVALID );
+ DBUS_TYPE_INT32, &i_position,
+ DBUS_TYPE_INVALID );
if( dbus_error_is_set( &error ) )
{
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- while ( i_count < i_position )
+ while ( p_tested_item && ( i_count < i_position ) )
{
i_count++;
- TEST_NEXT;
+ TEST_NEXT_ITEM;
}
- GetInputMeta ( p_tested_item->p_input, &args );
+ if( p_tested_item )
+ GetInputMeta ( p_tested_item->p_input, &args );
pl_Release( p_playlist );
REPLY_SEND;
playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
playlist_item_t* p_tested_item = p_playlist->p_root_onelevel;
playlist_item_t* p_last_item = playlist_GetLastLeaf( p_playlist,
- p_playlist->p_root_onelevel );
+ p_playlist->p_root_onelevel );
- while ( p_tested_item->p_input->i_id != p_last_item->p_input->i_id )
+ while ( p_tested_item &&
+ ( p_tested_item->p_input->i_id != p_last_item->p_input->i_id ) )
{
i_elements++;
- TEST_NEXT;
+ TEST_NEXT_ITEM;
}
pl_Release( p_playlist );
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- while ( i_count < i_position )
+ while ( p_tested_item && ( i_count < i_position ) )
{
i_count++;
- TEST_NEXT;
+ TEST_NEXT_ITEM;
}
- PL_LOCK;
- playlist_DeleteFromInput( p_playlist,
- p_tested_item->p_input->i_id,
- VLC_TRUE );
- PL_UNLOCK;
+ if( p_tested_item )
+ {
+ PL_LOCK;
+ playlist_DeleteFromInput( p_playlist,
+ p_tested_item->p_input->i_id,
+ VLC_TRUE );
+ PL_UNLOCK;
+ }
pl_Release( p_playlist );
dbus_bool_t b_random;
vlc_value_t val;
playlist_t* p_playlist = NULL;
-
+
dbus_error_init( &error );
dbus_message_get_args( p_from, &error,
DBUS_TYPE_BOOLEAN, &b_random,
DBUS_TYPE_INVALID );
-
+
if( dbus_error_is_set( &error ) )
{
msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s\n",
}
val.b_bool = ( b_random == TRUE ) ? VLC_TRUE : VLC_FALSE ;
-
+
p_playlist = pl_Yield( (vlc_object_t*) p_this );
var_Set ( p_playlist, "random", val );
pl_Release( ((vlc_object_t*) p_this) );
METHOD_FUNC( "Play", Play );
METHOD_FUNC( "Pause", Pause );
METHOD_FUNC( "Repeat", Repeat );
- METHOD_FUNC( "Disconnect", Disconnect );
METHOD_FUNC( "VolumeSet", VolumeSet );
METHOD_FUNC( "VolumeGet", VolumeGet );
METHOD_FUNC( "PositionSet", PositionSet );
dbus_bus_request_name( p_conn, VLC_MPRIS_DBUS_SERVICE, 0, &error );
if( dbus_error_is_set( &error ) )
{
- msg_Err( p_this, "Error requesting % service: %s\n"
- VLC_MPRIS_DBUS_SERVICE, error.message );
+ msg_Err( p_this, "Error requesting service " VLC_MPRIS_DBUS_SERVICE
+ ": %s", error.message );
dbus_error_free( &error );
free( p_sys );
return VLC_EGENERIC;
static void Run ( intf_thread_t *p_intf )
{
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
msleep( INTF_IDLE_SLEEP );
dbus_connection_read_write_dispatch( p_intf->p_sys->p_conn, 0 );
DBusMessageIter dict, dict_entry, variant;
/* We need the track length to be expressed in seconds
* instead of milliseconds */
- dbus_int64_t i_length = (p_input->i_duration / 1000);
+ dbus_int64_t i_length = ( input_item_GetDuration( p_input ) / 1000 );
-
- const char* ppsz_meta_items[] =
+ const char* ppsz_meta_items[] =
{
"title", "artist", "genre", "copyright", "album", "tracknum",
"description", "rating", "date", "setting", "url", "language",
ADD_VLC_META_STRING( 13, Publisher );
ADD_VLC_META_STRING( 14, EncodedBy );
ADD_VLC_META_STRING( 15, ArtURL );
- ADD_VLC_META_STRING( 16, TrackID );
+ ADD_VLC_META_STRING( 16, TrackID );
+
+ vlc_mutex_lock( &p_input->lock );
+ if( p_input->p_meta )
+ ADD_META( 17, DBUS_TYPE_INT32, p_input->p_meta->i_status );
+ vlc_mutex_unlock( &p_input->lock );
- ADD_META( 17, DBUS_TYPE_INT32, p_input->p_meta->i_status );
- ADD_META( 18, DBUS_TYPE_STRING, p_input->psz_uri );
+ ADD_VLC_META_STRING( 18, URI );
ADD_META( 19, DBUS_TYPE_INT64, i_length );
dbus_message_iter_close_container( args, &dict );