diff --git a/src/cdaudio-ng/cdaudio-ng.c b/src/cdaudio-ng/cdaudio-ng.c index 925b847..e986839 100644 --- a/src/cdaudio-ng/cdaudio-ng.c +++ b/src/cdaudio-ng/cdaudio-ng.c @@ -26,11 +26,16 @@ #include #include #include -#include #include #include #include +#if LIBCDIO_VERSION_NUM >= 90 +#include +#else +#include +#endif + /* libcdio's header files #define these */ #undef PACKAGE #undef PACKAGE_BUGREPORT @@ -269,9 +274,9 @@ static void cdaudio_set_strinfo (trackinfo_t * t, const char * performer, const char * name, const char * genre) { - g_strlcpy (t->performer, performer, DEF_STRING_LEN); - g_strlcpy (t->name, name, DEF_STRING_LEN); - g_strlcpy (t->genre, genre, DEF_STRING_LEN); + g_strlcpy (t->performer, performer ? performer : "", DEF_STRING_LEN); + g_strlcpy (t->name, name ? name : "", DEF_STRING_LEN); + g_strlcpy (t->genre, genre ? genre : "", DEF_STRING_LEN); } /* thread safe (mutex may be locked) */ @@ -622,23 +627,32 @@ static void scan_cd (void) } /* get trackinfo[0] cdtext information (the disc) */ + cdtext_t *pcdtext = NULL; if (aud_get_bool ("CDDA", "use_cdtext")) { AUDDBG ("getting cd-text information for disc\n"); - cdtext_t *pcdtext = cdio_get_cdtext (pcdrom_drive->p_cdio, 0); +#if LIBCDIO_VERSION_NUM >= 90 + pcdtext = cdio_get_cdtext (pcdrom_drive->p_cdio); + if (pcdtext == NULL) +#else + pcdtext = cdio_get_cdtext (pcdrom_drive->p_cdio, 0); if (pcdtext == NULL || pcdtext->field[CDTEXT_TITLE] == NULL) +#endif { AUDDBG ("no cd-text available for disc\n"); } else { cdaudio_set_strinfo (&trackinfo[0], - pcdtext->field[CDTEXT_PERFORMER] ? pcdtext-> - field[CDTEXT_PERFORMER] : "", - pcdtext->field[CDTEXT_TITLE] ? pcdtext-> - field[CDTEXT_TITLE] : "", - pcdtext->field[CDTEXT_GENRE] ? pcdtext-> - field[CDTEXT_GENRE] : ""); +#if LIBCDIO_VERSION_NUM >= 90 + cdtext_get(pcdtext, CDTEXT_FIELD_PERFORMER, 0), + cdtext_get(pcdtext, CDTEXT_FIELD_TITLE, 0), + cdtext_get(pcdtext, CDTEXT_FIELD_GENRE, 0)); +#else + pcdtext->field[CDTEXT_PERFORMER], + pcdtext->field[CDTEXT_TITLE], + pcdtext->field[CDTEXT_GENRE]); +#endif } } @@ -646,7 +660,7 @@ static void scan_cd (void) bool_t cdtext_was_available = FALSE; for (trackno = firsttrackno; trackno <= lasttrackno; trackno++) { - cdtext_t *pcdtext = NULL; +#if LIBCDIO_VERSION_NUM < 90 if (aud_get_bool ("CDDA", "use_cdtext")) { AUDDBG ("getting cd-text information for track %d\n", trackno); @@ -657,16 +671,20 @@ static void scan_cd (void) pcdtext = NULL; } } +#endif if (pcdtext != NULL) { cdaudio_set_strinfo (&trackinfo[trackno], - pcdtext->field[CDTEXT_PERFORMER] ? pcdtext-> - field[CDTEXT_PERFORMER] : "", - pcdtext->field[CDTEXT_TITLE] ? pcdtext-> - field[CDTEXT_TITLE] : "", - pcdtext->field[CDTEXT_GENRE] ? pcdtext-> - field[CDTEXT_GENRE] : ""); +#if LIBCDIO_VERSION_NUM >= 90 + cdtext_get(pcdtext, CDTEXT_FIELD_PERFORMER, trackno), + cdtext_get(pcdtext, CDTEXT_FIELD_TITLE, trackno), + cdtext_get(pcdtext, CDTEXT_FIELD_GENRE, trackno)); +#else + pcdtext->field[CDTEXT_PERFORMER], + pcdtext->field[CDTEXT_TITLE], + pcdtext->field[CDTEXT_GENRE]); +#endif cdtext_was_available = TRUE; } else