Commit e7a8394a authored by Laurent Aimar's avatar Laurent Aimar

Do not use (input_thread_t*)p_access->p_parent it is not always true.

(Use vlc_find_object(PARENT)
parent 7275b922
...@@ -141,10 +141,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -141,10 +141,6 @@ static int Open( vlc_object_t *p_this )
vcddev_t *vcddev; vcddev_t *vcddev;
char *psz_name; char *psz_name;
int i_mrl_tracknum = -1; int i_mrl_tracknum = -1;
input_thread_t *p_input;
playlist_item_t *p_item = NULL;
playlist_t *p_playlist = NULL;
int i_ret; int i_ret;
if( !p_access->psz_path || !*p_access->psz_path ) if( !p_access->psz_path || !*p_access->psz_path )
...@@ -179,36 +175,38 @@ static int Open( vlc_object_t *p_this ) ...@@ -179,36 +175,38 @@ static int Open( vlc_object_t *p_this )
STANDARD_BLOCK_ACCESS_INIT STANDARD_BLOCK_ACCESS_INIT
p_sys->vcddev = vcddev; 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 ? */ /* Do we play a single track ? */
p_sys->i_track = var_CreateGetInteger( p_access, "cdda-track" ); p_sys->i_track = var_CreateGetInteger( p_access, "cdda-track" );
if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 ) if( p_sys->i_track < 0 && i_mrl_tracknum <= 0 )
{ {
p_playlist = pl_Yield( p_access ); /* We only do separate items if the whole disc is requested */
if( p_playlist->status.p_item->p_input == playlist_t *p_playlist = pl_Yield( p_access );
input_GetItem( (input_thread_t *)p_access->p_parent))
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 )
{
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; p_item = p_playlist->status.p_item;
else 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 ); p_item = playlist_ItemGetByInput( p_playlist, p_current, VLC_FALSE );
if( !p_item ) if( p_item )
{ i_ret = GetTracks( p_access, p_playlist, p_item );
else
msg_Dbg( p_playlist, "unable to find item in playlist"); msg_Dbg( p_playlist, "unable to find item in playlist");
return -1; vlc_object_release( p_input );
} }
vlc_object_release( p_playlist );
} }
if( i_ret < 0 )
i_ret = GetTracks( p_access, p_playlist, p_item ); goto error;
if( p_playlist ) vlc_object_release( p_playlist );
if( i_ret < 0 ) goto error;
} }
else else
{ {
...@@ -261,7 +259,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -261,7 +259,6 @@ static int Open( vlc_object_t *p_this )
error: error:
ioctl_Close( VLC_OBJECT(p_access), p_sys->vcddev ); ioctl_Close( VLC_OBJECT(p_access), p_sys->vcddev );
free( p_sys ); free( p_sys );
if( p_playlist ) vlc_object_release( p_playlist );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
......
...@@ -937,18 +937,18 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -937,18 +937,18 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
CDDAMetaInfoInit( p_access ); CDDAMetaInfoInit( p_access );
CDDAMetaInfo( p_access, p_cdda->i_track ); CDDAMetaInfo( p_access, p_cdda->i_track );
if (p_playlist) { if( p_playlist )
{
p_item = playlist_ItemGetByInput( p_playlist, input_thread_t *p_input = (input_thread_t*)vlc_object_find( p_access, VLC_OBJECT_INPUT, FIND_PARENT );
input_GetItem(((input_thread_t *)p_access->p_parent)), VLC_FALSE ); 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 ) if( p_item == p_playlist->status.p_item && !b_single_track )
{
b_play = VLC_TRUE; b_play = VLC_TRUE;
}
else else
{
b_play = VLC_FALSE; b_play = VLC_FALSE;
vlc_object_release( p_input );
} }
} }
......
...@@ -195,22 +195,32 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) ...@@ -195,22 +195,32 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
return VLC_ENOMEM; return VLC_ENOMEM;
playlist_t *p_playlist = pl_Yield( p_access ); 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; playlist_item_t *p_item_in_category;
input_item_t *p_current_input = input_GetItem( input_item_t *p_current_input;
(input_thread_t*)p_access->p_parent); playlist_item_t *p_current;
playlist_item_t *p_current = playlist_ItemGetByInput( p_playlist,
p_current_input, if( !p_input )
VLC_FALSE ); {
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" ); msg_Err( p_access, "unable to find item in playlist" );
vlc_object_release( p_input );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
return VLC_ENOOBJ; return VLC_ENOOBJ;
} }
/* Remove the ending '/' char */ /* Remove the ending '/' char */
if (psz_name[0]) if( psz_name[0] )
{ {
char *ptr = psz_name + strlen (psz_name); char *ptr = psz_name + strlen (psz_name);
switch (*--ptr) switch (*--ptr)
...@@ -249,6 +259,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len) ...@@ -249,6 +259,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
playlist_Signal( p_playlist ); playlist_Signal( p_playlist );
if( psz_name ) free( psz_name ); if( psz_name ) free( psz_name );
vlc_object_release( p_input );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
/* Return fake data forever */ /* Return fake data forever */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment