[vlc-devel] commit: Add more CDDA informations to the playlist node. (Laurent Aimar )
git version control
git at videolan.org
Tue Feb 3 23:52:54 CET 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Tue Feb 3 23:51:53 2009 +0100| [9d9e1852a3c37c9771d9c9a29401579335bea60b] | committer: Laurent Aimar
Add more CDDA informations to the playlist node.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9d9e1852a3c37c9771d9c9a29401579335bea60b
---
modules/access/cdda.c | 60 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index fb6a714..e8c4ba6 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -396,11 +396,54 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
#ifdef HAVE_LIBCDDB
GetCDDBInfo( p_access, i_titles, p_sys->p_sectors );
+ const char *psz_album = NULL;
+ const char *psz_year = NULL;
+ const char *psz_genre = NULL;
+ char psz_year_buffer[4+1];
+
if( p_sys->p_disc )
{
- const char *psz_name = cddb_disc_get_title( p_sys->p_disc );
- if( psz_name && *psz_name )
- input_item_SetName( p_current, psz_name );
+ psz_album = cddb_disc_get_title( p_sys->p_disc );
+ if( psz_album && *psz_album )
+ {
+ input_item_SetName( p_current, psz_album );
+ input_item_SetAlbum( p_current, psz_album );
+ }
+
+ const unsigned i_year = cddb_disc_get_year( p_sys->p_disc );
+ if( i_year > 0 )
+ {
+ psz_year = psz_year_buffer;
+ snprintf( psz_year_buffer, sizeof(psz_year_buffer), "%u", i_year );
+ input_item_SetDate( p_current, psz_year );
+ }
+
+ psz_genre = cddb_disc_get_genre( p_sys->p_disc );
+ if( psz_genre && *psz_genre )
+ input_item_SetGenre( p_current, psz_genre );
+
+ /* Set artist only if unique */
+ const char *psz_artist = NULL;
+ for( int i = 0; i < i_titles; i++ )
+ {
+ cddb_track_t *t = cddb_disc_get_track( p_sys->p_disc, i );
+ if( !t )
+ continue;
+ const char *psz_track_artist = cddb_track_get_artist( t );
+ if( psz_artist && psz_track_artist &&
+ strcmp( psz_artist, psz_track_artist ) )
+ {
+ psz_artist = NULL;
+ break;
+ }
+ psz_artist = psz_track_artist;
+ }
+ if( psz_artist && *psz_artist )
+ input_item_SetArtist( p_current, psz_artist );
+
+ const mtime_t i_duration = (int64_t)( p_sys->p_sectors[i_titles] - p_sys->p_sectors[0] ) *
+ CDDA_DATA_SIZE * 1000000 / 44100 / 2 / 2;
+ input_item_SetDuration( p_current, i_duration );
}
#endif
@@ -458,19 +501,12 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
input_item_SetArtist( p_input_item, psz_artist );
}
- const char *psz_album = cddb_disc_get_title( p_sys->p_disc );
if( psz_album && *psz_album )
input_item_SetAlbum( p_input_item, psz_album );
- const unsigned i_year = cddb_disc_get_year( p_sys->p_disc );
- if( i_year > 0 )
- {
- char psz_date[4+1];
- snprintf( psz_date, sizeof(psz_date), "%u", i_year );
- input_item_SetDate( p_input_item, psz_date );
- }
+ if( psz_year )
+ input_item_SetDate( p_input_item, psz_year );
- const char *psz_genre = cddb_disc_get_genre( p_sys->p_disc );
if( psz_genre && *psz_genre )
input_item_SetGenre( p_input_item, psz_genre );
}
More information about the vlc-devel
mailing list