X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fcdda.c;h=b246ad67c781a4dcbec171c16d4aa503f42b3a5b;hb=e02432e597acb3511d14433ae3303ff4da3742f9;hp=2e34463aa55323c55eda172c9124e33af9fdbd9d;hpb=90a4caea90dbbb8c8b6d3a78f1671083b8694637;p=vlc diff --git a/modules/access/cdda.c b/modules/access/cdda.c index 2e34463aa5..b246ad67c7 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -31,12 +31,12 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include #include -#include +#include +#include -#include "codecs.h" +#include /* For WAVEHEADER */ #include "vcd/cdrom.h" #include @@ -139,10 +139,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 ) @@ -177,39 +173,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 = (playlist_t *) vlc_object_find( p_access, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( !p_playlist ) return VLC_EGENERIC; - - 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; - else - { - input_item_t *p_current = ( (input_thread_t*)p_access->p_parent)-> - input.p_item; - p_item = playlist_LockItemGetByInput( p_playlist, p_current ); + /* 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 { @@ -262,7 +257,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; } @@ -417,13 +411,9 @@ static int GetTracks( access_t *p_access, return VLC_EGENERIC; } - p_item_in_category = playlist_LockItemToNode( p_playlist, p_parent ); - psz_name = strdup( "Audio CD" ); - vlc_mutex_lock( &p_playlist->object_lock ); - playlist_ItemSetName( p_parent, psz_name ); - vlc_mutex_unlock( &p_playlist->object_lock ); + p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, VLC_FALSE ); + playlist_ItemSetName( p_parent, "Audio CD" ); var_SetInteger( p_playlist, "item-change", p_parent->p_input->i_id ); - free( psz_name ); #ifdef HAVE_LIBCDDB GetCDDBInfo( p_access, i_titles, p_sys->p_sectors ); @@ -431,13 +421,10 @@ static int GetTracks( access_t *p_access, { if( cddb_disc_get_title( p_sys->p_disc ) ) { - asprintf( &psz_name, "%s", cddb_disc_get_title( p_sys->p_disc ) ); - vlc_mutex_lock( &p_playlist->object_lock ); + const char *psz_name = cddb_disc_get_title( p_sys->p_disc ); playlist_ItemSetName( p_parent, psz_name ); - vlc_mutex_unlock( &p_playlist->object_lock ); var_SetInteger( p_playlist, "item-change", p_parent->p_input->i_id ); - free( psz_name ); } } #endif @@ -472,39 +459,39 @@ static int GetTracks( access_t *p_access, p_input_item = input_ItemNewWithType( VLC_OBJECT( p_playlist ), psz_uri, psz_name, 0, NULL, -1, ITEM_TYPE_DISC ); - vlc_input_item_AddOption( p_input_item, psz_first ); - vlc_input_item_AddOption( p_input_item, psz_last ); - vlc_input_item_AddOption( p_input_item, psz_opt ); + input_ItemAddOption( p_input_item, psz_first ); + input_ItemAddOption( p_input_item, psz_last ); + input_ItemAddOption( p_input_item, psz_opt ); #ifdef HAVE_LIBCDDB /* If we have CDDB info, change the name */ if( p_sys->p_disc ) { - char *psz_result; + const char *psz_result; cddb_track_t *t = cddb_disc_get_track( p_sys->p_disc, i ); if( t!= NULL ) { if( cddb_track_get_title( t ) != NULL ) { - vlc_input_item_AddInfo( p_input_item, _(VLC_META_INFO_CAT), + input_ItemAddInfo( p_input_item, _(VLC_META_INFO_CAT), _(VLC_META_TITLE), - cddb_track_get_title( t ) ); + "%s", cddb_track_get_title( t ) ); if( p_input_item->psz_name ) free( p_input_item->psz_name ); - asprintf( &p_input_item->psz_name, "%s", - cddb_track_get_title( t ) ); + p_input_item->psz_name = strdup( cddb_track_get_title( t ) ); } psz_result = cddb_track_get_artist( t ); if( psz_result ) { - vlc_input_item_AddInfo( p_input_item, _(VLC_META_INFO_CAT), - _(VLC_META_ARTIST), psz_result ); + input_ItemAddInfo( p_input_item, _(VLC_META_INFO_CAT), + _(VLC_META_ARTIST), "%s", psz_result ); } } } #endif - playlist_AddWhereverNeeded( p_playlist, p_input_item, p_parent, - p_item_in_category, VLC_FALSE, PLAYLIST_APPEND ); + playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category, + PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL, + VLC_FALSE ); free( psz_uri ); free( psz_opt ); free( psz_name ); free( psz_first ); free( psz_last ); }