Beispiel #1
0
void PLItem::init( playlist_item_t *_playlist_item, PLItem *parent )
{
    parentItem = parent;          /* Can be NULL, but only for the rootItem */
    i_id       = _playlist_item->i_id;           /* Playlist item specific id */
    p_input    = _playlist_item->p_input;
    vlc_gc_incref( p_input );
}
CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
    : QLabel( parent ), p_intf( _p_i ), p_item( NULL )
{
    setContextMenuPolicy( Qt::ActionsContextMenu );
    CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
             this, showArtUpdate( input_item_t * ) );

    setMinimumHeight( 128 );
    setMinimumWidth( 128 );
    setScaledContents( false );
    setAlignment( Qt::AlignCenter );

    QAction *action = new QAction( qtr( "Download cover art" ), this );
    CONNECT( action, triggered(), this, askForUpdate() );
    addAction( action );

    action = new QAction( qtr( "Add cover art from file" ), this );
    CONNECT( action, triggered(), this, setArtFromFile() );
    addAction( action );

    p_item = THEMIM->currentInputItem();
    if( p_item )
    {
        vlc_gc_incref( p_item );
        showArtUpdate( p_item );
    }
    else
        showArtUpdate( "" );
}
Beispiel #3
0
/*****************************************************************************
 * Playlist item creation
 *****************************************************************************/
playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
                                              input_item_t *p_input )
{
    playlist_item_t* p_item = malloc( sizeof( playlist_item_t ) );
    if( !p_item )
        return NULL;

    assert( p_input );

    p_item->p_input = p_input;
    vlc_gc_incref( p_item->p_input );

    p_item->i_id = ++pl_priv(p_playlist)->i_last_playlist_id;

    p_item->p_parent = NULL;
    p_item->i_children = -1;
    p_item->pp_children = NULL;
    p_item->i_nb_played = 0;
    p_item->i_flags = 0;
    p_item->p_playlist = p_playlist;

    install_input_item_observer( p_item );

    return p_item;
}
Beispiel #4
0
input_item_t * GetCurrentItem(demux_t *p_demux)
{
    input_thread_t *p_input_thread = demux_GetParentInput( p_demux );
    input_item_t *p_current_input = input_GetItem( p_input_thread );
    vlc_gc_incref(p_current_input);
    vlc_object_release(p_input_thread);
    return p_current_input;
}
Beispiel #5
0
static PyObject *gc_test( PyObject *self, PyObject *args )
{
     mygc *gc = (mygc *)malloc( sizeof( mygc ) );

     vlc_gc_init( gc, mygc_destructor, NULL );
     ASSERT( gc->i_gc_refcount == 0, "Refcount should be 0" );
     vlc_gc_incref( gc );
     ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
     vlc_gc_incref( gc );
     ASSERT( gc->i_gc_refcount == 2, "Refcount should be 2" );
     gc->i++;
     vlc_gc_decref( gc );
     ASSERT( gc->i_gc_refcount == 1, "Refcount should be 1" );
     vlc_gc_decref( gc );

     Py_INCREF( Py_None );
     return Py_None;
};
Beispiel #6
0
/**************************************************************************
 * Create a new media descriptor object from an input_item
 * (libvlc internal)
 * That's the generic constructor
 **************************************************************************/
libvlc_media_t * libvlc_media_new_from_input_item(
                                   libvlc_instance_t *p_instance,
                                   input_item_t *p_input_item )
{
    libvlc_media_t * p_md;

    if (!p_input_item)
    {
        libvlc_printerr( "No input item given" );
        return NULL;
    }

    p_md = calloc( 1, sizeof(libvlc_media_t) );
    if( !p_md )
    {
        libvlc_printerr( "Not enough memory" );
        return NULL;
    }

    p_md->p_libvlc_instance = p_instance;
    p_md->p_input_item      = p_input_item;
    p_md->i_refcount        = 1;

    vlc_cond_init(&p_md->parsed_cond);
    vlc_mutex_init(&p_md->parsed_lock);
    vlc_mutex_init(&p_md->subitems_lock);

    p_md->state = libvlc_NothingSpecial;

    /* A media descriptor can be a playlist. When you open a playlist
     * It can give a bunch of item to read. */
    p_md->p_subitems        = NULL;

    p_md->p_event_manager = libvlc_event_manager_new( p_md, p_instance );
    if( unlikely(p_md->p_event_manager == NULL) )
    {
        free(p_md);
        return NULL;
    }

    libvlc_event_manager_t *em = p_md->p_event_manager;
    libvlc_event_manager_register_event_type(em, libvlc_MediaMetaChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemAdded);
    libvlc_event_manager_register_event_type(em, libvlc_MediaFreed);
    libvlc_event_manager_register_event_type(em, libvlc_MediaDurationChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaStateChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaParsedChanged);
    libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemTreeAdded);

    vlc_gc_incref( p_md->p_input_item );

    install_input_item_observer( p_md );

    return p_md;
}
Beispiel #7
0
void Item::setInputItem( input_item_t* p_input_item )
{
    if(_inputItem == p_input_item)
        return;

    if(_inputItem)
        vlc_gc_decref( _inputItem );

    vlc_gc_incref( p_input_item );
    _inputItem = p_input_item;
}
Beispiel #8
0
void MediaServer::setInputItem( input_item_t* p_input_item )
{
    if( _p_input_item == p_input_item )
        return;

    if( _p_input_item )
        vlc_gc_decref( _p_input_item );

    vlc_gc_incref( p_input_item );
    _p_input_item = p_input_item;
}
Beispiel #9
0
void Container::setInputItem( input_item_t* p_input_item )
{
    if( _p_input_item == p_input_item )
        return;

    if( _p_input_item )
        vlc_gc_decref( _p_input_item );

    vlc_gc_incref( p_input_item );
    _p_input_item = p_input_item;
}
Beispiel #10
0
PLSelItem *PLSelector::addPodcastItem( playlist_item_t *p_item )
{
    vlc_gc_incref( p_item->p_input );
    char *psz_name = input_item_GetName( p_item->p_input );
    PLSelItem *item = addItem(
                          PL_ITEM_TYPE,  psz_name, false, podcastsParent );
    item->addAction( RM_ACTION, qtr( "Remove this podcast subscription" ) );
    item->treeItem()->setData( 0, PL_ITEM_ROLE, QVariant::fromValue( p_item ) );
    item->treeItem()->setData( 0, PL_ITEM_ID_ROLE, QVariant(p_item->i_id) );
    item->treeItem()->setData( 0, IN_ITEM_ROLE, QVariant::fromValue( p_item->p_input ) );
    CONNECT( item, action( PLSelItem* ), this, podcastRemove( PLSelItem* ) );
    free( psz_name );
    return item;
}
Beispiel #11
0
static void entry_item_append( services_discovery_t *p_sd,
                               netbios_ns_entry *p_entry,
                               input_item_t *p_item )
{
    services_discovery_sys_t *p_sys = p_sd->p_sys;
    struct entry_item *p_entry_item = calloc(1, sizeof(struct entry_item));

    if( !p_entry_item )
        return;
    p_entry_item->p_entry = p_entry;
    p_entry_item->p_item = p_item;
    vlc_gc_incref( p_item );
    vlc_array_append( p_sys->p_entry_item_list, p_entry_item );
    services_discovery_AddItem( p_sd, p_item, NULL );
}
Beispiel #12
0
void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p_item )
{
    vlc_gc_incref( p_item );

    vlc_mutex_lock( &p_preparser->lock );
    INSERT_ELEM( p_preparser->pp_waiting, p_preparser->i_waiting,
                 p_preparser->i_waiting, p_item );
    if( !p_preparser->b_live )
    {
        if( vlc_clone_detach( NULL, Thread, p_preparser,
                              VLC_THREAD_PRIORITY_LOW ) )
            msg_Warn( p_preparser->object, "cannot spawn pre-parser thread" );
        else
            p_preparser->b_live = true;
    }
    vlc_mutex_unlock( &p_preparser->lock );
}
Beispiel #13
0
static int vlclua_input_item_get( lua_State *L, input_item_t *p_item )
{
    vlc_gc_incref( p_item );
    input_item_t **pp = lua_newuserdata( L, sizeof( input_item_t* ) );
    *pp = p_item;

    if( luaL_newmetatable( L, "input_item" ) )
    {
        lua_newtable( L );
        luaL_register( L, NULL, vlclua_input_item_reg );
        lua_setfield( L, -2, "__index" );
        lua_pushcfunction( L, vlclua_input_item_delete );
        lua_setfield( L, -2, "__gc" );
    }

    lua_setmetatable(L, -2);

    return 1;
}
Beispiel #14
0
void EpgDialog::updateInfos()
{
    timer->stop();
    input_item_t *p_input_item = NULL;
    playlist_t *p_playlist = THEPL;
    input_thread_t *p_input_thread = playlist_CurrentInput( p_playlist ); /* w/hold */
    if( p_input_thread )
    {
        PL_LOCK; /* as input_GetItem still unfixed */
        p_input_item = input_GetItem( p_input_thread );
        if ( p_input_item ) vlc_gc_incref( p_input_item );
        PL_UNLOCK;
        vlc_object_release( p_input_thread );
        if ( p_input_item )
        {
            epg->updateEPG( p_input_item );
            vlc_gc_decref( p_input_item );
            if ( isVisible() ) timer->start();
        }
    }
}
Beispiel #15
0
void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p_item,
                              input_item_meta_request_option_t i_options )
{
    preparser_entry_t *p_entry = malloc( sizeof(preparser_entry_t) );

    if ( !p_entry )
        return;
    p_entry->p_item = p_item;
    p_entry->i_options = i_options;
    vlc_gc_incref( p_entry->p_item );

    vlc_mutex_lock( &p_preparser->lock );
    INSERT_ELEM( p_preparser->pp_waiting, p_preparser->i_waiting,
                 p_preparser->i_waiting, p_entry );
    if( !p_preparser->b_live )
    {
        if( vlc_clone_detach( NULL, Thread, p_preparser,
                              VLC_THREAD_PRIORITY_LOW ) )
            msg_Warn( p_preparser->object, "cannot spawn pre-parser thread" );
        else
            p_preparser->b_live = true;
    }
    vlc_mutex_unlock( &p_preparser->lock );
}
void CoverArtLabel::setItem( input_item_t *_p_item )
{
    if ( p_item ) vlc_gc_decref( p_item );
    p_item = _p_item;
    if ( p_item ) vlc_gc_incref( p_item );
}
Beispiel #17
0
 IMEvent( event_types type, input_item_t *p_input = NULL )
     : QEvent( (QEvent::Type)(type) )
 {
     if( (p_item = p_input) != NULL )
         vlc_gc_incref( p_item );
 }
Beispiel #18
0
input_item_t * GetCurrentItem(demux_t *p_demux)
{
    input_item_t *p_current_input = input_GetItem( p_demux->p_input );
    vlc_gc_incref(p_current_input);
    return p_current_input;
}
Beispiel #19
0
int playlist_MLLoad( playlist_t *p_playlist )
{
    char *psz_datadir;
    char *psz_uri = NULL;
    input_item_t *p_input;

    if( !config_GetInt( p_playlist, "media-library") )
        return VLC_SUCCESS;

    psz_datadir = config_GetUserDir( VLC_DATA_DIR );

    if( !psz_datadir ) /* XXX: This should never happen */
    {
        msg_Err( p_playlist, "no data directory, cannot load media library") ;
        return VLC_EGENERIC;
    }

    if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) != -1 )
    {   /* loosy check for media library file */
        struct stat st;
        int ret = utf8_stat( psz_uri , &st );
        free( psz_uri );
        if( ret )
        {
            free( psz_datadir );
            return VLC_EGENERIC;
        }
    }

    psz_uri = make_URI( psz_datadir );
    free( psz_datadir );
    psz_datadir = psz_uri;
    if( psz_datadir == NULL )
        return VLC_EGENERIC;

    /* Force XSPF demux (psz_datadir was a path, now it is a file URI) */
    if( asprintf( &psz_uri, "file/xspf-open%s/ml.xspf", psz_datadir+4 ) == -1 )
        psz_uri = NULL;
    free( psz_datadir );
    psz_datadir = NULL;
    if( psz_uri == NULL )
        return VLC_ENOMEM;

    const char *const options[1] = { "meta-file", };
    /* that option has to be cleaned in input_item_subitem_added() */
    /* vlc_gc_decref() in the same function */
    p_input = input_item_NewExt( p_playlist, psz_uri, _("Media Library"),
                                 1, options, VLC_INPUT_OPTION_TRUSTED, -1 );
    free( psz_uri );
    if( p_input == NULL )
        return VLC_EGENERIC;

    PL_LOCK;
    if( p_playlist->p_ml_onelevel->p_input )
        vlc_gc_decref( p_playlist->p_ml_onelevel->p_input );
    if( p_playlist->p_ml_category->p_input )
        vlc_gc_decref( p_playlist->p_ml_category->p_input );

    p_playlist->p_ml_onelevel->p_input =
    p_playlist->p_ml_category->p_input = p_input;
    /* We save the input at two different place, incref */
    vlc_gc_incref( p_input );
    vlc_gc_incref( p_input );

    vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                        input_item_subitem_added, p_playlist );

    pl_priv(p_playlist)->b_doing_ml = true;
    PL_UNLOCK;

    stats_TimerStart( p_playlist, "ML Load", STATS_TIMER_ML_LOAD );
    input_Read( p_playlist, p_input );
    stats_TimerStop( p_playlist,STATS_TIMER_ML_LOAD );

    PL_LOCK;
    pl_priv(p_playlist)->b_doing_ml = false;
    PL_UNLOCK;

    vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemAdded,
                        input_item_subitem_added, p_playlist );

    vlc_gc_decref( p_input );
    return VLC_SUCCESS;
}
Beispiel #20
0
input_resource_t *input_resource_Hold( input_resource_t *p_resource )
{
    vlc_gc_incref( p_resource );
    return p_resource;
}
Beispiel #21
0
 CmdItemUpdate( intf_thread_t *pIntf, input_item_t* pItem ):
     CmdGeneric( pIntf ), m_pItem( pItem )
 {
     if( pItem )
         vlc_gc_incref( pItem );
 }