]> git.sesse.net Git - vlc/commitdiff
Don't use find for the playlist
authorClément Stenac <zorglub@videolan.org>
Sun, 17 Sep 2006 09:06:24 +0000 (09:06 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 17 Sep 2006 09:06:24 +0000 (09:06 +0000)
13 files changed:
modules/access/cdda.c
modules/access/cdda/info.c
modules/access/directory.c
modules/access/http.c
modules/access/mms/mmsh.c
modules/access_output/http.c
modules/control/hotkeys.c
modules/control/rc.c
modules/control/showintf.c
modules/gui/qt4/input_manager.cpp
modules/gui/qt4/qt4.cpp
modules/gui/qt4/qt4.hpp
modules/misc/growl.c

index 2e34463aa55323c55eda172c9124e33af9fdbd9d..47b0290537d969e9cc79f856bf193bfa23d9a6e2 100644 (file)
@@ -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;
index 1211850ae4c8ce684bf305b8feacadb61010f623..dd8db4cf71f889e9bbd7c95ba0c8dff8909006a8 100644 (file)
@@ -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 ) {
index 5f36d4399aa463b039813ec27a4f13a2e0cecf5f..9d43eec97d538a254c222b1c4e8f502f30393b7f 100644 (file)
@@ -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 );
 
index 5558dd962b978391ed24302d5c2f3c7ea43dbd7b..d8831292a6fe08696315f51c5a5bd4bdd7064d49 100644 (file)
@@ -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 );
index 6786972d0dc2af6d863c36bc5edf218c4cb212f8..8d312b7f0c5b2f4befdaadea939524600e22a0ff 100644 (file)
@@ -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 );
index 09be1527f69fdc8c9154703fbf15583e8aadab95..907ce3227173adac0e34774573fcc4ed4fab0a15 100644 (file)
@@ -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
index ba8fe27e044d8a2e9d79fa8f21d7d4928c4a7962..6ca2f9a12a26a31336c169d62c8259c47b25ffa9 100644 (file)
@@ -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 )
         {
index 22e7f4a004de31492815e6f6855cac2bc50da608..49b5d44f4fb32a2446f3b11324a9251e3f486418 100644 (file)
@@ -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" ) )
index 1a98e7a1c2c355343e3881f60e0fe42c6011d419..55cc2713fa9ff584dfa429fd7f907ec620470f46 100644 (file)
@@ -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;
         }
 
index c4d5579607a763e6ba7363bc2c520267bc1b26ce..042cc4881546eceb3b14bd9536c833b207f00a33 100644 (file)
@@ -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 );
 }
index 824283b4af35ca42b708a286fca9978b8b96a210..96d8745ab8175077b4b05d828776223b1ff540d0 100644 (file)
@@ -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;
index 2b63649e9bf27c6fede95778989bff2837d5f734..c2ed8dbda12c66bb5601ef5c8a86f9125f268bbb 100644 (file)
@@ -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 )
 
index 194a29515184af716cde8854e0170a4824a5e155..6e9749df5f2df341dc75991064abf46a1ad7385d 100644 (file)
@@ -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 );
 }
 
 /*****************************************************************************