void Playtree::onAppend( playlist_add_t *p_add ) { Iterator it_node = findById( p_add->i_node ); if( it_node != m_children.end() ) { playlist_Lock( m_pPlaylist ); playlist_item_t *pItem = playlist_ItemGetById( m_pPlaylist, p_add->i_item ); if( !pItem ) { playlist_Unlock( m_pPlaylist ); return; } int pos; for( pos = 0; pos < pItem->p_parent->i_children; pos++ ) if( pItem->p_parent->pp_children[pos] == pItem ) break; UString *pName = getTitle( pItem->p_input ); playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist ); Iterator it = it_node->add( p_add->i_item, UStringPtr( pName ), false, pItem == current, false, pItem->i_flags & PLAYLIST_RO_FLAG, pos ); m_allItems[pItem->i_id] = &*it; playlist_Unlock( m_pPlaylist ); tree_update descr( tree_update::ItemInserted, IteratorVisible( it, this ) ); notify( &descr ); } }
static int MarshalMetadata( intf_thread_t *p_intf, DBusMessageIter *container ) { playlist_t *playlist = pl_Get( p_intf ); playlist_item_t *item; int result = VLC_SUCCESS; playlist_Lock( playlist ); item = playlist_CurrentPlayingItem( playlist ); if( item != NULL ) result = GetInputMeta( item, container ); else { // avoid breaking the type marshalling DBusMessageIter a; if( !dbus_message_iter_open_container( container, DBUS_TYPE_ARRAY, "{sv}", &a ) || !dbus_message_iter_close_container( container, &a ) ) result = VLC_ENOMEM; } playlist_Unlock( playlist ); return result; }
/* Define the Input used. Add the callbacks on input p_input is held once here */ void InputManager::setInput( input_thread_t *_p_input ) { delInput(); p_input = _p_input; if( p_input != NULL ) { msg_Dbg( p_intf, "IM: Setting an input" ); vlc_object_hold( p_input ); addCallbacks(); UpdateStatus(); UpdateName(); UpdateArt(); UpdateTeletext(); UpdateNavigation(); UpdateVout(); p_item = input_GetItem( p_input ); emit rateChanged( var_GetFloat( p_input, "rate" ) ); /* Get Saved Time */ if( p_item->i_type == ITEM_TYPE_FILE ) { char *uri = input_item_GetURI( p_item ); int i_time = RecentsMRL::getInstance( p_intf )->time( qfu(uri) ); if( i_time > 0 && qfu( uri ) != lastURI && !var_GetFloat( p_input, "run-time" ) && !var_GetFloat( p_input, "start-time" ) && !var_GetFloat( p_input, "stop-time" ) ) { emit resumePlayback( (int64_t)i_time * 1000 ); } playlist_Lock( THEPL ); // Add root items only playlist_item_t* p_node = playlist_CurrentPlayingItem( THEPL ); if ( p_node != NULL && p_node->p_parent != NULL && p_node->p_parent->i_id == THEPL->p_playing->i_id ) { // Save the latest URI to avoid asking to restore the // position on the same input file. lastURI = qfu( uri ); RecentsMRL::getInstance( p_intf )->addRecent( lastURI ); } playlist_Unlock( THEPL ); free( uri ); } } else { p_item = NULL; lastURI.clear(); assert( !p_input_vbi ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); } }
void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree ) { UString *pName = new UString( getIntf(), pNode->p_input->psz_name ); Iterator it = rTree.add( pNode->i_id, UStringPtr( pName ), false, playlist_CurrentPlayingItem(m_pPlaylist) == pNode, false, pNode->i_flags & PLAYLIST_RO_FLAG ); m_allItems[pNode->i_id] = &*it; for( int i = 0; i < pNode->i_children; i++ ) { buildNode( pNode->pp_children[i], *it ); } }
//--------------------------------------------------------------------------- // DemuxOpen: initialize demux //--------------------------------------------------------------------------- static int DemuxOpen( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t*)p_this; intf_thread_t *p_intf; char *ext; // Needed callbacks p_demux->pf_demux = Demux; p_demux->pf_control = DemuxControl; // Test that we have a valid .vlt or .wsz file, based on the extension if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL || ( strcasecmp( ext, ".vlt" ) && strcasecmp( ext, ".wsz" ) ) ) { return VLC_EGENERIC; } vlc_mutex_lock( &skin_load.mutex ); p_intf = skin_load.intf; if( p_intf ) vlc_object_hold( p_intf ); vlc_mutex_unlock( &skin_load.mutex ); if( p_intf != NULL ) { playlist_t *p_playlist = pl_Get( p_this ); PL_LOCK; // Make sure the item is deleted afterwards /// \bug does not always work playlist_CurrentPlayingItem( p_playlist )->i_flags |= PLAYLIST_REMOVE_FLAG; PL_UNLOCK; var_SetString( p_intf, "skin-to-load", p_demux->psz_path ); vlc_object_release( p_intf ); } else { msg_Warn( p_this, "skin could not be loaded (not using skins2 intf)" ); } return VLC_SUCCESS; }
void Playtree::onUpdateCurrent( bool b_active ) { if( b_active ) { playlist_Lock( m_pPlaylist ); playlist_item_t* current = playlist_CurrentPlayingItem( m_pPlaylist ); if( !current ) { playlist_Unlock( m_pPlaylist ); return; } Iterator it = findById( current->i_id ); if( it != m_children.end() ) { it->setPlaying( true ); tree_update descr( tree_update::ItemUpdated, IteratorVisible( it, this ) ); notify( &descr ); } playlist_Unlock( m_pPlaylist ); } else { for( Iterator it = m_children.begin(); it != m_children.end(); it = getNextItem( it ) ) { if( it->isPlaying() ) { it->setPlaying( false ); tree_update descr( tree_update::ItemUpdated, IteratorVisible( it, this ) ); notify( &descr ); break; } } } }
/***************************************************************************** * Run: xosd thread ***************************************************************************** * This part of the interface runs in a separate thread *****************************************************************************/ static void Run( intf_thread_t *p_intf ) { playlist_t *p_playlist; playlist_item_t *p_item = NULL; char *psz_display = NULL; int cancel = vlc_savecancel(); while( true ) { // Wait for a signal vlc_restorecancel( cancel ); vlc_mutex_lock( &p_intf->p_sys->lock ); mutex_cleanup_push( &p_intf->p_sys->lock ); while( !p_intf->p_sys->b_need_update ) vlc_cond_wait( &p_intf->p_sys->cond, &p_intf->p_sys->lock ); p_intf->p_sys->b_need_update = false; vlc_cleanup_run(); // Compute the signal cancel = vlc_savecancel(); p_playlist = pl_Hold( p_intf ); PL_LOCK; // If the playlist is empty don't do anything if( playlist_IsEmpty( p_playlist ) ) { PL_UNLOCK; pl_Release( p_intf ); continue; } free( psz_display ); int i_status = playlist_Status( p_playlist ); if( i_status == PLAYLIST_STOPPED ) { psz_display = strdup(_("Stop")); } else if( i_status == PLAYLIST_PAUSED ) { psz_display = strdup(_("Pause")); } else { p_item = playlist_CurrentPlayingItem( p_playlist ); if( !p_item ) { psz_display = NULL; PL_UNLOCK; pl_Release( p_intf ); continue; } input_item_t *p_input = p_item->p_input; mtime_t i_duration = input_item_GetDuration( p_input ); if( i_duration != -1 ) { char psz_durationstr[MSTRTIME_MAX_SIZE]; secstotimestr( psz_durationstr, i_duration / 1000000 ); if( asprintf( &psz_display, "%s (%s)", p_input->psz_name, psz_durationstr ) == -1 ) psz_display = NULL; } else psz_display = strdup( p_input->psz_name ); } PL_UNLOCK; pl_Release( p_intf ); /* Display */ xosd_display( p_intf->p_sys->p_osd, 0, /* first line */ XOSD_string, psz_display ); } }
/************************************************************************* * Playlist stuff *************************************************************************/ void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl, playlist_item_t *p_node, char *name, mvar_t *s, int i_depth ) { if( !p_node || !p_node->p_input ) return; if( p_node->i_children == -1 ) { char value[512]; char *psz; playlist_item_t * p_item = playlist_CurrentPlayingItem( p_pl ); if( !p_item || !p_item->p_input ) return; mvar_t *itm = mvar_New( name, "set" ); if( p_item->p_input == p_node->p_input ) mvar_AppendNewVar( itm, "current", "1" ); else mvar_AppendNewVar( itm, "current", "0" ); sprintf( value, "%d", p_node->i_id ); mvar_AppendNewVar( itm, "index", value ); psz = input_item_GetName( p_node->p_input ); mvar_AppendNewVar( itm, "name", psz ); free( psz ); psz = input_item_GetURI( p_node->p_input ); mvar_AppendNewVar( itm, "uri", psz ); free( psz ); mvar_AppendNewVar( itm, "type", "Item" ); sprintf( value, "%d", i_depth ); mvar_AppendNewVar( itm, "depth", value ); if( p_node->i_flags & PLAYLIST_RO_FLAG ) mvar_AppendNewVar( itm, "ro", "ro" ); else mvar_AppendNewVar( itm, "ro", "rw" ); sprintf( value, "%"PRId64, input_item_GetDuration( p_node->p_input ) ); mvar_AppendNewVar( itm, "duration", value ); //Adding extra meta-information to each playlist item psz = input_item_GetTitle( p_node->p_input ); mvar_AppendNewVar( itm, "title", psz ); free( psz ); psz = input_item_GetArtist( p_node->p_input ); mvar_AppendNewVar( itm, "artist", psz ); free( psz ); psz = input_item_GetGenre( p_node->p_input ); mvar_AppendNewVar( itm, "genre", psz ); free( psz ); psz = input_item_GetCopyright( p_node->p_input ); mvar_AppendNewVar( itm, "copyright", psz ); free( psz ); psz = input_item_GetAlbum( p_node->p_input ); mvar_AppendNewVar( itm, "album", psz ); free( psz ); psz = input_item_GetTrackNum( p_node->p_input ); mvar_AppendNewVar( itm, "track", psz ); free( psz ); psz = input_item_GetDescription( p_node->p_input ); mvar_AppendNewVar( itm, "description", psz ); free( psz ); psz = input_item_GetRating( p_node->p_input ); mvar_AppendNewVar( itm, "rating", psz ); free( psz ); psz = input_item_GetDate( p_node->p_input ); mvar_AppendNewVar( itm, "date", psz ); free( psz ); psz = input_item_GetURL( p_node->p_input ); mvar_AppendNewVar( itm, "url", psz ); free( psz ); psz = input_item_GetLanguage( p_node->p_input ); mvar_AppendNewVar( itm, "language", psz ); free( psz ); psz = input_item_GetNowPlaying( p_node->p_input ); mvar_AppendNewVar( itm, "now_playing", psz ); free( psz ); psz = input_item_GetPublisher( p_node->p_input ); mvar_AppendNewVar( itm, "publisher", psz ); free( psz ); psz = input_item_GetEncodedBy( p_node->p_input ); mvar_AppendNewVar( itm, "encoded_by", psz ); free( psz ); psz = input_item_GetArtURL( p_node->p_input ); mvar_AppendNewVar( itm, "art_url", psz ); free( psz ); psz = input_item_GetTrackID( p_node->p_input ); mvar_AppendNewVar( itm, "track_id", psz ); free( psz ); mvar_AppendVar( s, itm ); } else { char value[512]; int i_child; mvar_t *itm = mvar_New( name, "set" ); mvar_AppendNewVar( itm, "name", p_node->p_input->psz_name ); mvar_AppendNewVar( itm, "uri", p_node->p_input->psz_name ); mvar_AppendNewVar( itm, "type", "Node" ); sprintf( value, "%d", p_node->i_id ); mvar_AppendNewVar( itm, "index", value ); sprintf( value, "%d", p_node->i_children); mvar_AppendNewVar( itm, "i_children", value ); sprintf( value, "%d", i_depth ); mvar_AppendNewVar( itm, "depth", value ); if( p_node->i_flags & PLAYLIST_RO_FLAG ) mvar_AppendNewVar( itm, "ro", "ro" ); else mvar_AppendNewVar( itm, "ro", "rw" ); mvar_AppendVar( s, itm ); for( i_child = 0 ; i_child < p_node->i_children ; i_child++ ) PlaylistListNode( p_intf, p_pl, p_node->pp_children[i_child], name, s, i_depth + 1); } }