Currently the field width for the audio format is hard-coded as three
as the name of each supported audio format (mp3, ogg, aac, wma, spx)
consists of three characters.
However, with the forthcoming flac support, this is no longer true
since "flac" consists of four characters. So the ls command must
calculate the maximal field width of the audio formats of all listed
files.
This is achieved by introducing the new audio_format_width member of
struct ls_widths.
unsigned short num_played_width;
/** size of the amp field. */
unsigned short amp_width;
unsigned short num_played_width;
/** size of the amp field. */
unsigned short amp_width;
+ /** size of the audio format field. */
+ unsigned short audio_format_width;
};
/** Data passed from the ls command handler to its callback function. */
};
/** Data passed from the ls command handler to its callback function. */
"%*d " /* image_id */
"%*d " /* lyrics_id */
"%*d " /* bitrate */
"%*d " /* image_id */
"%*d " /* lyrics_id */
"%*d " /* bitrate */
- "%s " /* audio format */
+ "%*s " /* audio format */
"%*d " /* frequency */
"%d " /* channels */
"%s " /* duration */
"%*d " /* frequency */
"%d " /* channels */
"%s " /* duration */
w->image_id_width, afsi->image_id,
w->lyrics_id_width, afsi->lyrics_id,
w->bitrate_width, afhi->bitrate,
w->image_id_width, afsi->image_id,
w->lyrics_id_width, afsi->lyrics_id,
w->bitrate_width, afhi->bitrate,
audio_format_name(afsi->audio_format_id),
w->frequency_width, afhi->frequency,
afhi->channels,
audio_format_name(afsi->audio_format_id),
w->frequency_width, afhi->frequency,
afhi->channels,
w->duration_width = PARA_MAX(w->duration_width, num_digits);
GET_NUM_DIGITS(d->afsi.amp, &num_digits);
w->amp_width = PARA_MAX(w->amp_width, num_digits);
w->duration_width = PARA_MAX(w->duration_width, num_digits);
GET_NUM_DIGITS(d->afsi.amp, &num_digits);
w->amp_width = PARA_MAX(w->amp_width, num_digits);
+ num_digits = strlen(audio_format_name(d->afsi.audio_format_id));
+ w->audio_format_width = PARA_MAX(w->audio_format_width, num_digits);
if (options->flags & LS_FLAG_ADMISSIBLE_ONLY) {
GET_NUM_DIGITS(score, &num_digits);
num_digits++; /* add one for the sign (space or "-") */
if (options->flags & LS_FLAG_ADMISSIBLE_ONLY) {
GET_NUM_DIGITS(score, &num_digits);
num_digits++; /* add one for the sign (space or "-") */