Commit c224b9ac authored by Rocky Bernstein's avatar Rocky Bernstein

Honor "prefer-cdtext" option.

Put all of the tracks in stream and media info - would like to make
this a chile under the disc category, but I don't see a mechanism for
that (yet).

To do - there still is a core dump that remains from before when CDDB
is disabled.
parent a7edf837
...@@ -210,7 +210,7 @@ cddb_end: ; ...@@ -210,7 +210,7 @@ cddb_end: ;
/* /*
Gets and saves CDDA Meta Information about the CD. Gets and saves Meta Information about the CD-DA.
In the Control routine, we handle Meta Information requests and In the Control routine, we handle Meta Information requests and
basically copy what we've saved here. basically copy what we've saved here.
...@@ -272,11 +272,15 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -272,11 +272,15 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
(p_cdda->lsn[i_first_track+i] - p_cdda->lsn[i_first_track]) (p_cdda->lsn[i_first_track+i] - p_cdda->lsn[i_first_track])
/ CDIO_CD_FRAMES_PER_SEC; / CDIO_CD_FRAMES_PER_SEC;
dbg_print( INPUT_DBG_META, "Duration %ld", (long int) i_duration ); dbg_print( INPUT_DBG_META, "Duration %ld, tracks %d",
(long int) i_duration, p_cdda->i_tracks );
input_Control( p_cdda->p_input, INPUT_ADD_INFO, input_Control( p_cdda->p_input, INPUT_ADD_INFO,
_("Disc"), _("Duration"), "%s", _("Disc"), _("Duration"), "%s",
secstotimestr( psz_buffer, i_duration ) ); secstotimestr( psz_buffer, i_duration ) );
input_Control( p_cdda->p_input, INPUT_ADD_INFO,
_("Disc"), _("Tracks"), "%d", p_cdda->i_tracks );
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc)
{ {
...@@ -305,8 +309,6 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -305,8 +309,6 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE); add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE);
} }
if( i_track == -1 )
{
for( i = 0 ; i < p_cdda->i_tracks ; i++ ) for( i = 0 ; i < p_cdda->i_tracks ; i++ )
{ {
char psz_track[TITLE_MAX]; char psz_track[TITLE_MAX];
...@@ -315,6 +317,7 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -315,6 +317,7 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
p_cdda->lsn[i_track]) p_cdda->lsn[i_track])
/ CDIO_CD_FRAMES_PER_SEC; / CDIO_CD_FRAMES_PER_SEC;
snprintf(psz_track, TITLE_MAX, "%s %02d", _("Track"), i_track); snprintf(psz_track, TITLE_MAX, "%s %02d", _("Track"), i_track);
input_Control( p_cdda->p_input, INPUT_ADD_INFO, psz_track, input_Control( p_cdda->p_input, INPUT_ADD_INFO, psz_track,
_("Duration"), "%s", _("Duration"), "%s",
secstotimestr( psz_buffer, i_duration ) ); secstotimestr( psz_buffer, i_duration ) );
...@@ -357,7 +360,6 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -357,7 +360,6 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
} }
} }
}
} }
#define add_format_str_info(val) \ #define add_format_str_info(val) \
...@@ -387,6 +389,17 @@ void CDDAMetaInfo( access_t *p_access, int i_track ) ...@@ -387,6 +389,17 @@ void CDDAMetaInfo( access_t *p_access, int i_track )
saw_control_prefix = false; \ saw_control_prefix = false; \
} }
static inline bool
want_cddb_info(
cdda_data_t *p_cdda, char *psz_cdtext)
{
/* We either don't have CD-Text info, or we do but we prefer to get CDDB
which means CDDB has been enabled and we were able to retrieve the info.*/
return !psz_cdtext ||
(!p_cdda->b_cdtext_prefer && p_cdda->b_cddb_enabled && p_cdda->cddb.disc);
}
/*! /*!
Take a format string and expand escape sequences, that is sequences that Take a format string and expand escape sequences, that is sequences that
begin with %, with information from the current CD. begin with %, with information from the current CD.
...@@ -423,6 +436,7 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -423,6 +436,7 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
for (i=0; i<format_len; i++) for (i=0; i<format_len; i++)
{ {
char *psz = NULL;
if (!saw_control_prefix && format_str[i] != '%') if (!saw_control_prefix && format_str[i] != '%')
{ {
...@@ -442,15 +456,19 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -442,15 +456,19 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
break; break;
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
case 'a': case 'a':
if (!p_cdda->b_cddb_enabled) goto not_special; if (p_cdda->p_cdtext[0]
if (p_cdda->cddb.disc) && p_cdda->p_cdtext[0]->field[CDTEXT_PERFORMER])
add_format_str_info(p_cdda->cddb.disc->artist); psz = p_cdda->p_cdtext[0]->field[CDTEXT_PERFORMER];
break; if (want_cddb_info(p_cdda, psz))
psz = p_cdda->cddb.disc->artist;
goto format_str;
case 'A': case 'A':
if (!p_cdda->b_cddb_enabled) goto not_special; if (p_cdda->p_cdtext[0]
if (p_cdda->cddb.disc) && p_cdda->p_cdtext[0]->field[CDTEXT_TITLE])
add_format_str_info(p_cdda->cddb.disc->title); psz = p_cdda->p_cdtext[0]->field[CDTEXT_TITLE];
break; if (want_cddb_info(p_cdda, psz))
psz = p_cdda->cddb.disc->title;
goto format_str;
case 'C': case 'C':
if (!p_cdda->b_cddb_enabled) goto not_special; if (!p_cdda->b_cddb_enabled) goto not_special;
if (p_cdda->cddb.disc) if (p_cdda->cddb.disc)
...@@ -458,14 +476,20 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -458,14 +476,20 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
CDDB_CATEGORY[p_cdda->cddb.disc->category]); CDDB_CATEGORY[p_cdda->cddb.disc->category]);
break; break;
case 'G': case 'G':
if (!p_cdda->b_cddb_enabled) goto not_special; if (p_cdda->p_cdtext[0]
if (p_cdda->cddb.disc) && p_cdda->p_cdtext[0]->field[CDTEXT_GENRE])
add_format_str_info(p_cdda->cddb.disc->genre); psz = p_cdda->p_cdtext[0]->field[CDTEXT_GENRE];
break; if (want_cddb_info(p_cdda, psz))
psz = p_cdda->cddb.disc->genre;
goto format_str;
case 'I': case 'I':
if (!p_cdda->b_cddb_enabled) goto not_special; if (p_cdda->p_cdtext[0]
if (p_cdda->cddb.disc) && p_cdda->p_cdtext[0]->field[CDTEXT_DISCID])
psz = p_cdda->p_cdtext[0]->field[CDTEXT_DISCID];
if (want_cddb_info(p_cdda, psz)) {
add_format_num_info(p_cdda->cddb.disc->discid, "%x"); add_format_num_info(p_cdda->cddb.disc->discid, "%x");
} else if (psz)
add_format_str_info(psz);
break; break;
case 'Y': case 'Y':
if (!p_cdda->b_cddb_enabled) goto not_special; if (!p_cdda->b_cddb_enabled) goto not_special;
...@@ -483,22 +507,29 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -483,22 +507,29 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
else goto not_special; else goto not_special;
break; break;
case 'p': case 'p':
if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER])
psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER];
if (want_cddb_info(p_cdda, psz))
{ {
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
i_track-1); i_track-1);
if (t != NULL && t->artist != NULL) if (t != NULL && t->artist != NULL)
add_format_str_info(t->artist); psz = t->artist;
} else goto not_special; }
break; goto format_str;
case 'e': case 'e':
if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_MESSAGE])
psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_MESSAGE];
if (want_cddb_info(p_cdda, psz))
{ {
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
i_track-1); i_track-1);
if (t != NULL && t->ext_data != NULL) if (t != NULL && t->ext_data != NULL)
add_format_str_info(t->ext_data); psz = t->ext_data;
} else goto not_special; }
goto format_str;
break; break;
case 's': case 's':
if (p_cdda->b_cddb_enabled) if (p_cdda->b_cddb_enabled)
...@@ -511,6 +542,38 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -511,6 +542,38 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
i_duration ) ); i_duration ) );
} else goto not_special; } else goto not_special;
break; break;
#else
case 'a':
if (p_cdda->p_cdtext[0]
&& p_cdda->p_cdtext->field[CDTEXT_PERFORMER]
psz = p_cdda->p_cdtext->field[CDTEXT_PERFORMER]);
goto format_str;
case 'A':
if (p_cdda->p_cdtext[0]
&& p_cdda->p_cdtext->field[CDTEXT_TITLE]
psz = p_cdda->p_cdtext->field[CDTEXT_TITLE]);
goto format_str;
case 'G':
if (p_cdda->p_cdtext[0]
&& p_cdda->p_cdtext[0]->field[CDTEXT_GENRE])
psz = p_cdda->p_cdtext[0]->field[CDTEXT_GENRE];
goto format_str;
case 'I':
if (p_cdda->p_cdtext[0]
&& p_cdda->p_cdtext[0]->field[CDTEXT_DISCID])
add_format_str_info(p_cdda->p_cdtext[0]->field[CDTEXT_DISCID]);
break;
case 'p':
if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER])
psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER];
goto format_str;
case 'e':
if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_MESSAGE])
psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_MESSAGE];
goto format_str;
break;
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
case 'M': case 'M':
...@@ -528,6 +591,10 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -528,6 +591,10 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
case 'T': case 'T':
add_format_num_info(i_track, "%02d"); add_format_num_info(i_track, "%02d");
break; break;
format_str:
if (psz)
add_format_str_info(psz);
break;
#ifdef HAVE_LIBCDDB #ifdef HAVE_LIBCDDB
not_special: not_special:
#endif #endif
......
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