]> git.sesse.net Git - vlc/commitdiff
Do not use (input_thread_t*)p_access->p_parent it is not always true.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 22 Feb 2007 19:34:05 +0000 (19:34 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 22 Feb 2007 19:34:05 +0000 (19:34 +0000)
(Use vlc_find_object(PARENT)

modules/access/cdda.c
modules/access/cdda/info.c
modules/access/directory.c

index 589e0d7c9aaf1e22fd064fd7f7d2a08ba42b697f..4181b416a021f7d492ea57c0395654bc114f510c 100644 (file)
@@ -141,10 +141,6 @@ static int Open( vlc_object_t *p_this )
     vcddev_t *vcddev;
     char *psz_name;
     int i_mrl_tracknum = -1;
-
-    input_thread_t *p_input;
-    playlist_item_t *p_item = NULL;
-    playlist_t *p_playlist  = NULL;
     int i_ret;
 
     if( !p_access->psz_path || !*p_access->psz_path )
@@ -179,36 +175,38 @@ static int Open( vlc_object_t *p_this )
     STANDARD_BLOCK_ACCESS_INIT
     p_sys->vcddev = vcddev;
 
-    /* We only do separate items if the whole disc is requested -
-     *  Dirty hack we access some private data ! */
-    p_input = (input_thread_t *)( p_access->p_parent );
-
    /* Do we play a single track ? */
    p_sys->i_track = var_CreateGetInteger( p_access, "cdda-track" );
 
    if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 )
    {
-        p_playlist = pl_Yield( p_access );
-        if( p_playlist->status.p_item->p_input ==
-             input_GetItem( (input_thread_t *)p_access->p_parent))
-            p_item = p_playlist->status.p_item;
-        else
-        {
-            input_item_t *p_current = input_GetItem(
-                                        (input_thread_t*)p_access->p_parent);
-            p_item = playlist_ItemGetByInput( p_playlist, p_current, VLC_FALSE );
+        /* We only do separate items if the whole disc is requested */
+        playlist_t *p_playlist = pl_Yield( p_access );
 
-            if( !p_item )
+        i_ret = -1;
+        if( p_playlist )
+        {
+            input_thread_t *p_input = (input_thread_t*)vlc_object_find( p_access, VLC_OBJECT_INPUT, FIND_PARENT );
+            if( p_input )
             {
-                msg_Dbg( p_playlist, "unable to find item in playlist");
-                return -1;
+                input_item_t *p_current = input_GetItem( p_input );
+                playlist_item_t *p_item;
+
+                if( p_playlist->status.p_item->p_input == p_current )
+                    p_item = p_playlist->status.p_item;
+                else
+                    p_item = playlist_ItemGetByInput( p_playlist, p_current, VLC_FALSE );
+
+                if( p_item )
+                    i_ret = GetTracks( p_access, p_playlist, p_item );
+                else
+                    msg_Dbg( p_playlist, "unable to find item in playlist");
+                vlc_object_release( p_input );
             }
+            vlc_object_release( p_playlist );
         }
-
-        i_ret = GetTracks( p_access, p_playlist, p_item );
-
-        if( p_playlist ) vlc_object_release( p_playlist );
-        if( i_ret < 0 ) goto error;
+        if( i_ret < 0 )
+            goto error;
     }
     else
     {
@@ -261,7 +259,6 @@ static int Open( vlc_object_t *p_this )
 error:
     ioctl_Close( VLC_OBJECT(p_access), p_sys->vcddev );
     free( p_sys );
-    if( p_playlist ) vlc_object_release( p_playlist );
     return VLC_EGENERIC;
 }
 
index e8b0caae56d09e5bdc94f2a1d756c9006920e574..b136dd63b7f4c8550832e799272cb26e89adf6a0 100644 (file)
@@ -937,19 +937,19 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
     CDDAMetaInfoInit( p_access );
     CDDAMetaInfo( p_access, p_cdda->i_track );
 
-    if (p_playlist) {
-
-      p_item = playlist_ItemGetByInput( p_playlist,
-                        input_GetItem(((input_thread_t *)p_access->p_parent)), VLC_FALSE );
+    if( p_playlist )
+    {
+        input_thread_t *p_input = (input_thread_t*)vlc_object_find( p_access, VLC_OBJECT_INPUT, FIND_PARENT );
+        if( p_input )
+        {
+            p_item = playlist_ItemGetByInput( p_playlist, input_GetItem(p_input), VLC_FALSE );
 
-      if( p_item == p_playlist->status.p_item && !b_single_track )
-       {
-         b_play = VLC_TRUE;
-       }
-      else
-       {
-         b_play = VLC_FALSE;
-       }
+            if( p_item == p_playlist->status.p_item && !b_single_track )
+                b_play = VLC_TRUE;
+            else
+                b_play = VLC_FALSE;
+            vlc_object_release( p_input );
+        }
     }
 
     if( b_single_track && !p_cdda->b_nav_mode )
index 832cb6c5cb1fed92509789a6170761239c735dab..4311edc1b2d55d9794f7d44e58e0c93331eb66cc 100644 (file)
@@ -195,22 +195,32 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
         return VLC_ENOMEM;
 
     playlist_t         *p_playlist = pl_Yield( p_access );
+    input_thread_t     *p_input = (input_thread_t*)vlc_object_find( p_access, VLC_OBJECT_INPUT, FIND_PARENT );
+
     playlist_item_t    *p_item_in_category;
-    input_item_t       *p_current_input = input_GetItem(
-                                    (input_thread_t*)p_access->p_parent);
-    playlist_item_t    *p_current = playlist_ItemGetByInput( p_playlist,
-                                                             p_current_input,
-                                                             VLC_FALSE );
+    input_item_t       *p_current_input;
+    playlist_item_t    *p_current;
+
+    if( !p_input )
+    {
+        msg_Err( p_access, "unable to find input (internal error)" );
+        vlc_object_release( p_playlist );
+        return VLC_ENOOBJ;
+    }
+
+    p_current_input = input_GetItem( p_input );
+    p_current = playlist_ItemGetByInput( p_playlist, p_current_input, VLC_FALSE );
 
-    if( p_current == NULL )
+    if( !p_current )
     {
         msg_Err( p_access, "unable to find item in playlist" );
+        vlc_object_release( p_input );
         vlc_object_release( p_playlist );
         return VLC_ENOOBJ;
     }
 
     /* Remove the ending '/' char */
-    if (psz_name[0])
+    if( psz_name[0] )
     {
         char *ptr = psz_name + strlen (psz_name);
         switch (*--ptr)
@@ -249,6 +259,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
     playlist_Signal( p_playlist );
 
     if( psz_name ) free( psz_name );
+    vlc_object_release( p_input );
     vlc_object_release( p_playlist );
 
     /* Return fake data forever */