Commit dfef7d71 authored by Rocky Bernstein's avatar Rocky Bernstein

A little bit better if CDDB is not enabled or doesn't exist. Well, at

least it it no longer core dumps.
parent ec5590ea
...@@ -516,11 +516,12 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -516,11 +516,12 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
{ {
*pp_meta = vlc_meta_Duplicate( p_cdda->p_meta ); *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
dbg_print( INPUT_DBG_META, "%s", "Meta copied" ); dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
return VLC_SUCCESS;
} }
else else {
msg_Warn( p_access, "tried to copy NULL meta info" ); msg_Warn( p_access, "tried to copy NULL meta info" );
return VLC_EGENERIC;
return VLC_SUCCESS; }
} }
case ACCESS_CAN_SEEK: case ACCESS_CAN_SEEK:
......
...@@ -149,14 +149,14 @@ cddb_end: ; ...@@ -149,14 +149,14 @@ cddb_end: ;
} }
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
#define add_meta_val(FIELD, VLC_META, VAL) \ #define add_meta_val(VLC_META, VAL) \
if ( p_cdda->p_meta && VAL) { \ if ( p_cdda->p_meta && VAL) { \
vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL ); \ vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL ); \
dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL ); \ dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL ); \
} \ } \
#define add_cddb_meta(FIELD, VLC_META) \ #define add_cddb_meta(FIELD, VLC_META) \
add_meta_val(FIELD, VLC_META, p_cdda->cddb.disc->FIELD); add_meta_val(VLC_META, p_cdda->cddb.disc->FIELD);
#define add_cddb_meta_fmt(FIELD, FORMAT_SPEC, VLC_META) \ #define add_cddb_meta_fmt(FIELD, FORMAT_SPEC, VLC_META) \
{ \ { \
...@@ -164,7 +164,7 @@ cddb_end: ; ...@@ -164,7 +164,7 @@ cddb_end: ;
snprintf( psz_buf, sizeof(psz_buf)-1, FORMAT_SPEC, \ snprintf( psz_buf, sizeof(psz_buf)-1, FORMAT_SPEC, \
p_cdda->cddb.disc->FIELD ); \ p_cdda->cddb.disc->FIELD ); \
psz_buf[sizeof(psz_buf)-1] = '\0'; \ psz_buf[sizeof(psz_buf)-1] = '\0'; \
add_meta_val(FIELD, VLC_META, psz_buf); \ add_meta_val(VLC_META, psz_buf); \
} }
/* Adds a string-valued entry to the stream and media information if /* Adds a string-valued entry to the stream and media information if
...@@ -219,13 +219,16 @@ cddb_end: ; ...@@ -219,13 +219,16 @@ cddb_end: ;
media info" or in playlist info. The intialization of CD-Text or CDDB media info" or in playlist info. The intialization of CD-Text or CDDB
is done here though. is done here though.
*/ */
void CDDAMetaInfo( access_t *p_access, int i_track ) void CDDAMetaInfo( access_t *p_access, int i_track, /*const*/ char *psz_mrl )
{ {
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
char *psz_meta_title = psz_mrl;
char *psz_meta_artist = NULL;
if ( ! p_cdda ) return; if ( ! p_cdda ) return;
p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio); p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
p_cdda->p_meta = vlc_meta_New();
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if ( p_cdda->b_cddb_enabled ) if ( p_cdda->b_cddb_enabled )
...@@ -233,11 +236,11 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -233,11 +236,11 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
GetCDDBInfo(p_access, p_cdda); GetCDDBInfo(p_access, p_cdda);
if ( p_cdda->cddb.disc ) if ( p_cdda->cddb.disc )
{ {
p_cdda->p_meta = vlc_meta_New();
if( i_track == -1 ) if( i_track == -1 )
{ {
add_cddb_meta(title, VLC_META_TITLE); psz_meta_title = p_cdda->cddb.disc->title;
add_cddb_meta(artist, VLC_META_ARTIST); psz_meta_artist = p_cdda->cddb.disc->artist;
input_Control( p_cdda->p_input, INPUT_SET_NAME, input_Control( p_cdda->p_input, INPUT_SET_NAME,
p_cdda->cddb.disc->artist ); p_cdda->cddb.disc->artist );
} }
...@@ -249,20 +252,22 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -249,20 +252,22 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
{ {
if( t->title != NULL ) if( t->title != NULL )
{ {
add_meta_val( NULL, VLC_META_TITLE, t->title ); add_meta_val( VLC_META_TITLE, t->title );
} }
if( t->artist != NULL ) if( t->artist != NULL )
{ {
add_meta_val( NULL, VLC_META_ARTIST, t->artist ); add_meta_val( VLC_META_ARTIST, t->artist );
} }
} }
} }
add_cddb_meta(genre, VLC_META_GENRE); add_cddb_meta(genre, VLC_META_GENRE);
add_cddb_meta_fmt(year, "%d", VLC_META_DATE ); add_cddb_meta_fmt(year, "%d", VLC_META_DATE );
} }
} }
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
#define TITLE_MAX 30 #define TITLE_MAX 30
{ {
track_t i = p_cdda->i_tracks; track_t i = p_cdda->i_tracks;
...@@ -299,6 +304,8 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -299,6 +304,8 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
p_cdda->p_cdtext[0] = cdio_get_cdtext(p_cdda->p_cdio, 0); p_cdda->p_cdtext[0] = cdio_get_cdtext(p_cdda->p_cdio, 0);
if (p_cdda->p_cdtext[0]) if (p_cdda->p_cdtext[0])
{ {
char *psz_field;
add_cdtext_disc_info_str("Arranger (CD-Text)", CDTEXT_ARRANGER); add_cdtext_disc_info_str("Arranger (CD-Text)", CDTEXT_ARRANGER);
add_cdtext_disc_info_str("Composer (CD-Text)", CDTEXT_COMPOSER); add_cdtext_disc_info_str("Composer (CD-Text)", CDTEXT_COMPOSER);
add_cdtext_disc_info_str("Disc ID (CD-Text)", CDTEXT_DISCID); add_cdtext_disc_info_str("Disc ID (CD-Text)", CDTEXT_DISCID);
...@@ -307,6 +314,16 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -307,6 +314,16 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
add_cdtext_disc_info_str("Performer (CD-Text)", CDTEXT_PERFORMER); add_cdtext_disc_info_str("Performer (CD-Text)", CDTEXT_PERFORMER);
add_cdtext_disc_info_str("Songwriter (CD-Text)", CDTEXT_SONGWRITER); add_cdtext_disc_info_str("Songwriter (CD-Text)", CDTEXT_SONGWRITER);
add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE); add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE);
psz_field = p_cdda->p_cdtext[0]->field[CDTEXT_TITLE];
if (psz_field && strlen(psz_field)) {
psz_meta_title = psz_field;
}
psz_field = p_cdda->p_cdtext[0]->field[CDTEXT_PERFORMER];
if (psz_field && strlen(psz_field)) {
psz_meta_artist = psz_field;
}
} }
for( i = 0 ; i < p_cdda->i_tracks ; i++ ) for( i = 0 ; i < p_cdda->i_tracks ; i++ )
...@@ -359,6 +376,15 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -359,6 +376,15 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
} }
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
} }
/* Above we should have set psz_meta_title and psz_meta_artist
to CDDB or CD-Text values or the default value depending on
availablity and user preferences. So now add it to VLC's meta.
*/
add_meta_val( VLC_META_TITLE, psz_meta_title );
if (psz_meta_artist)
add_meta_val( VLC_META_ARTIST, psz_meta_artist );
} }
} }
...@@ -805,11 +831,11 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -805,11 +831,11 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
if( b_single_track ) if( b_single_track )
{ {
CDDAMetaInfo( p_access, p_cdda->i_track ); CDDAMetaInfo( p_access, p_cdda->i_track, psz_mrl );
} }
else else
{ {
CDDAMetaInfo( p_access, -1 ); CDDAMetaInfo( p_access, -1, psz_mrl );
} }
p_item = playlist_ItemGetByInput( p_playlist, p_item = playlist_ItemGetByInput( p_playlist,
......
...@@ -33,7 +33,7 @@ int CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -33,7 +33,7 @@ int CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
we handle Meta Information requests and basically copy what we've we handle Meta Information requests and basically copy what we've
saved here. saved here.
*/ */
void CDDAMetaInfo( access_t *p_access, int ); void CDDAMetaInfo( access_t *p_access, int, /*const*/ char *psz_mrl );
/* /*
......
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