From: Clément Stenac Date: Sun, 17 Sep 2006 09:06:24 +0000 (+0000) Subject: Don't use find for the playlist X-Git-Tag: 0.9.0-test0~10274 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=415749bf918d5ca772e1f9ba9f1260d7ab115d3e;p=vlc Don't use find for the playlist --- diff --git a/modules/access/cdda.c b/modules/access/cdda.c index 2e34463aa5..47b0290537 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -186,10 +186,7 @@ static int Open( vlc_object_t *p_this ) if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 ) { - p_playlist = (playlist_t *) vlc_object_find( p_access, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( !p_playlist ) return VLC_EGENERIC; - + p_playlist = pl_Yield( p_access ); if( p_playlist->status.p_item->p_input == ((input_thread_t *)p_access->p_parent)->input.p_item ) p_item = p_playlist->status.p_item; diff --git a/modules/access/cdda/info.c b/modules/access/cdda/info.c index 1211850ae4..dd8db4cf71 100644 --- a/modules/access/cdda/info.c +++ b/modules/access/cdda/info.c @@ -930,14 +930,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, #endif if (! p_cdda->b_nav_mode ) { - p_playlist = (playlist_t *) vlc_object_find( p_access, - VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( !p_playlist ) - { - msg_Warn( p_access, "can't find playlist" ); - return VLC_EGENERIC; - } + p_playlist = pl_Yield( p_access ); } if( b_single_track || p_cdda->b_nav_mode ) { diff --git a/modules/access/directory.c b/modules/access/directory.c index 5f36d4399a..9d43eec97d 100644 --- a/modules/access/directory.c +++ b/modules/access/directory.c @@ -203,17 +203,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) int i_mode, i_activity; playlist_item_t *p_item, *p_root_category; - vlc_bool_t b_play = VLC_FALSE; - - playlist_t *p_playlist = - (playlist_t *) vlc_object_find( p_access, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - - if( !p_playlist ) - { - msg_Err( p_access, "can't find playlist" ); - goto end; - } + playlist_t *p_playlist = pl_Yield( p_access ); psz_name = ToLocale( p_access->psz_path ); ptr = strdup( psz_name ); @@ -249,23 +239,17 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) if( p_playlist->status.p_item && p_playlist->status.p_item->p_input == ((input_thread_t *)p_access->p_parent)->input.p_item ) - { p_item = p_playlist->status.p_item; - b_play = VLC_TRUE; - msg_Dbg( p_access, "starting directory playback"); - } else { input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)-> input.p_item; p_item = playlist_LockItemGetByInput( p_playlist, p_current ); - msg_Dbg( p_access, "not starting directory playback"); if( !p_item ) { msg_Dbg( p_playlist, "unable to find item in playlist"); - return -1; + return VLC_ENOOBJ; } - b_play = VLC_FALSE; } p_item->p_input->i_type = ITEM_TYPE_DIRECTORY; @@ -281,16 +265,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) var_SetInteger( p_playlist, "activity", i_activity - DIRECTORY_ACTIVITY ); end: - - /* Begin to read the directory */ - if( b_play ) - { -#if 0 - /// \bug we can start playing an already deleted item. Fix ?*/ - playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, 1242, - p_playlist->status.p_item, NULL ); -#endif - } if( psz_name ) free( psz_name ); vlc_object_release( p_playlist ); diff --git a/modules/access/http.c b/modules/access/http.c index 5558dd962b..d8831292a6 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -323,16 +323,10 @@ connect: goto error; } - p_playlist = vlc_object_find( p_access, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( !p_playlist ) - { - msg_Err( p_access, "redirection failed: can't find playlist" ); - goto error; - } - /* Change the URI */ - vlc_mutex_lock( &p_playlist->object_lock ); + p_playlist = pl_Yield( p_access ); + PL_LOCK; + p_input_item = p_playlist->status.p_item->p_input; vlc_mutex_lock( &p_input_item->lock ); free( p_input_item->psz_uri ); @@ -340,8 +334,9 @@ connect: p_input_item->psz_uri = strdup( p_sys->psz_location ); p_access->psz_path = strdup( p_sys->psz_location ); vlc_mutex_unlock( &p_input_item->lock ); - vlc_mutex_unlock( &p_playlist->object_lock ); - vlc_object_release( p_playlist ); + + PL_UNLOCK; + pl_Release( p_access ); /* Clean up current Open() run */ vlc_UrlClean( &p_sys->url ); diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c index 6786972d0d..8d312b7f0c 100644 --- a/modules/access/mms/mmsh.c +++ b/modules/access/mms/mmsh.c @@ -108,16 +108,9 @@ int E_(MMSHOpen)( access_t *p_access ) /* Handle redirection */ if( psz_location && *psz_location ) { - playlist_t * p_playlist = vlc_object_find( p_access, VLC_OBJECT_PLAYLIST, FIND_PARENT ); - + playlist_t * p_playlist = pl_Yield( p_access ); msg_Dbg( p_access, "redirection to %s", psz_location ); - if( !p_playlist ) - { - msg_Err( p_access, "redirection failed: can't find playlist" ); - free( psz_location ); - return VLC_EGENERIC; - } /** \bug we do not autodelete here */ playlist_PlaylistAdd( p_playlist, psz_location, psz_location, PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END ); diff --git a/modules/access_output/http.c b/modules/access_output/http.c index 09be1527f6..907ce32271 100644 --- a/modules/access_output/http.c +++ b/modules/access_output/http.c @@ -296,20 +296,8 @@ static int Open( vlc_object_t *p_this ) #ifdef HAVE_AVAHI_CLIENT if( config_GetInt(p_this, SOUT_CFG_PREFIX "bonjour") ) { - playlist_t *p_playlist; char *psz_txt, *psz_name; - - p_playlist = (playlist_t *)vlc_object_find( p_access, - VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( p_playlist == NULL ) - { - msg_Err( p_access, "unable to find playlist" ); - httpd_StreamDelete( p_sys->p_httpd_stream ); - httpd_HostDelete( p_sys->p_httpd_host ); - free( (void *)p_sys ); - return VLC_EGENERIC; - } + playlist_t *p_playlist = pl_Yield( p_access ); psz_name = strrchr( p_playlist->status.p_item->p_input->psz_uri, DIRECTORY_SEPARATOR ); @@ -321,13 +309,11 @@ static int Open( vlc_object_t *p_this ) p_sys->p_bonjour = bonjour_start_service( (vlc_object_t *)p_access, strcmp( p_access->psz_access, "https" ) ? "_vlc-http._tcp" : "_vlc-https._tcp", - psz_name, i_bind_port, psz_txt ); + psz_name, i_bind_port, psz_txt ); free( (void *)psz_txt ); if( p_sys->p_bonjour == NULL ) - { - msg_Err( p_access, "Avahi stream announcing was requested, but no avahi service could be started" ); - } + msg_Err( p_access, "unable to start requested Bonjour announce" ); vlc_object_release( p_playlist ); } else diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c index ba8fe27e04..6ca2f9a12a 100644 --- a/modules/control/hotkeys.c +++ b/modules/control/hotkeys.c @@ -181,15 +181,11 @@ static void Run( intf_thread_t *p_intf ) /* Update the input */ if( p_intf->p_sys->p_input == NULL ) { - p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( p_playlist ) - { - p_intf->p_sys->p_input = p_playlist->p_input; - if( p_intf->p_sys->p_input ) - vlc_object_yield( p_intf->p_sys->p_input ); - vlc_object_release( p_playlist ); - } + p_playlist = pl_Yield( p_intf ); + p_intf->p_sys->p_input = p_playlist->p_input; + if( p_intf->p_sys->p_input ) + vlc_object_yield( p_intf->p_sys->p_input ); + vlc_object_release( p_playlist ); } else if( p_intf->p_sys->p_input->b_dead ) { @@ -245,14 +241,6 @@ static void Run( intf_thread_t *p_intf ) if( i_action == ACTIONID_QUIT ) { - p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( p_playlist ) - { - playlist_Stop( p_playlist ); - vlc_object_release( p_playlist ); - } - /* Playlist is stopped now kill vlc. */ p_intf->p_libvlc->b_die = VLC_TRUE; ClearChannels( p_intf, p_vout ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) ); @@ -291,13 +279,9 @@ static void Run( intf_thread_t *p_intf ) else if( i_action == ACTIONID_INTF_SHOW ) { val.b_bool = VLC_TRUE; - p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( p_playlist ) - { - var_Set( p_playlist, "intf-show", val ); - vlc_object_release( p_playlist ); - } + p_playlist = pl_Yield( p_intf ); + var_Set( p_playlist, "intf-show", val ); + vlc_object_release( p_playlist ); } else if( i_action == ACTIONID_INTF_HIDE ) { diff --git a/modules/control/rc.c b/modules/control/rc.c index 22e7f4a004..49b5d44f4f 100644 --- a/modules/control/rc.c +++ b/modules/control/rc.c @@ -1321,16 +1321,9 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*)p_this; - playlist_t *p_playlist; - - p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - if( !p_playlist ) - { - msg_Err( p_this, "no playlist" ); - return VLC_ENOOBJ; - } + playlist_t *p_playlist = pl_Yield( p_this ); + PL_LOCK; if( p_playlist->p_input ) { vlc_value_t val; @@ -1339,9 +1332,11 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, { msg_rc( _("Type 'menu select' or 'pause' to continue.") ); vlc_object_release( p_playlist ); + PL_UNLOCK; return VLC_EGENERIC; } } + PL_UNLOCK; /* Parse commands that require a playlist */ if( !strcmp( psz_cmd, "prev" ) ) @@ -1359,6 +1354,7 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd, } else if (!strcmp( psz_cmd, "goto" ) ) { + msg_rc( _("goto is deprecated" ) ); msg_Err( p_playlist, "goto is deprecated" ); } else if( !strcmp( psz_cmd, "stop" ) ) diff --git a/modules/control/showintf.c b/modules/control/showintf.c index 1a98e7a1c2..55cc2713fa 100644 --- a/modules/control/showintf.c +++ b/modules/control/showintf.c @@ -123,17 +123,9 @@ static void RunIntf( intf_thread_t *p_intf ) /* Notify the interfaces */ if( p_intf->p_sys->b_triggered ) { - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); - - if( p_playlist != NULL ) - { - vlc_value_t val; - val.b_bool = VLC_TRUE; - var_Set( p_playlist, "intf-show", val ); - vlc_object_release( p_playlist ); - } + playlist_t *p_playlist = pl_Yield( p_intf ); + var_SetBool( p_playlist, "intf-show", VLC_TRUE ); + vlc_object_release( p_playlist ); p_intf->p_sys->b_triggered = VLC_FALSE; } diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp index c4d5579607..042cc48815 100644 --- a/modules/gui/qt4/input_manager.cpp +++ b/modules/gui/qt4/input_manager.cpp @@ -196,18 +196,14 @@ void MainInputManager::updateInput() if( !p_input ) { - playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - assert( p_playlist ); - PL_LOCK; - p_input = p_playlist->p_input; + QPL_LOCK; + p_input = THEPL->p_input; if( p_input ) { vlc_object_yield( p_input ); emit inputChanged( p_input ); } - PL_UNLOCK; - vlc_object_release( p_playlist ); + QPL_UNLOCK; } vlc_mutex_unlock( &p_intf->change_lock ); } diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp index 824283b4af..96d8745ab8 100644 --- a/modules/gui/qt4/qt4.cpp +++ b/modules/gui/qt4/qt4.cpp @@ -71,14 +71,7 @@ static int Open( vlc_object_t *p_this ) p_intf->p_sys = (intf_sys_t *)malloc(sizeof( intf_sys_t ) ); memset( p_intf->p_sys, 0, sizeof( intf_sys_t ) ); - p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( !p_intf->p_sys->p_playlist ) - { - free( p_intf->p_sys ); - return VLC_EGENERIC; - } - + p_intf->p_sys->p_playlist = pl_Yield( p_intf ); p_intf->p_sys->p_sub = msg_Subscribe( p_intf, MSG_QUEUE_NORMAL ); return VLC_SUCCESS; diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp index 2b63649e9b..c2ed8dbda1 100644 --- a/modules/gui/qt4/qt4.hpp +++ b/modules/gui/qt4/qt4.hpp @@ -47,6 +47,9 @@ struct intf_sys_t }; #define THEPL p_intf->p_sys->p_playlist +#define QPL_LOCK vlc_mutex_lock( &THEPL->object_lock ); +#define QPL_UNLOCK vlc_mutex_unlock( &THEPL->object_lock ); + #define THEDP DialogsProvider::getInstance() #define THEMIM MainInputManager::getInstance( NULL ) diff --git a/modules/misc/growl.c b/modules/misc/growl.c index 194a295151..6e9749df5f 100644 --- a/modules/misc/growl.c +++ b/modules/misc/growl.c @@ -91,17 +91,9 @@ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; - playlist_t *p_playlist = (playlist_t *)vlc_object_find( - p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - - if( !p_playlist ) - { - msg_Err( p_intf, "could not find playlist object" ); - return VLC_ENOOBJ; - } - + playlist_t *p_playlist = pl_Yield( p_intf ); var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); - vlc_object_release( p_playlist ); + pl_Release( p_intf ); RegisterToGrowl( p_this ); p_intf->pf_run = Run; @@ -114,14 +106,9 @@ static int Open( vlc_object_t *p_this ) *****************************************************************************/ static void Close( vlc_object_t *p_this ) { - playlist_t *p_playlist = (playlist_t *)vlc_object_find( - p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - - if( p_playlist ) - { - var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this ); - vlc_object_release( p_playlist ); - } + playlist_t *p_playlist = pl_Yield( p_this ); + var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this ); + pl_Release( p_this ); } /*****************************************************************************