X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=e29c15a0d48afe17fa39f6c349f9fa1e8f7e7216;hp=8797bd8683ccf42909d3b771d030d5045d18bcda;hb=cb1265c87fdb0e817923bf09c47162a7f894aafc;hpb=f1b7734b997352b8df737b8184af69ca91c1b7dd diff --git a/aft.c b/aft.c index 8797bd86..e29c15a0 100644 --- a/aft.c +++ b/aft.c @@ -98,6 +98,8 @@ struct ls_widths { unsigned short duration_width; /** size of the num played field. */ unsigned short num_played_width; + /** size of the amp field. */ + unsigned short amp_width; }; /** Data passed from the ls command handler to its callback function. */ @@ -903,6 +905,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, ret = para_printf(b, "%s" /* score */ "%s " /* attributes */ + "%*u " /* amp */ "%*d " /* image_id */ "%*d " /* lyrics_id */ "%*d " /* bitrate */ @@ -915,6 +918,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, "%s\n", /* path */ score_buf, att_buf, + w->amp_width, afsi->amp, w->image_id_width, afsi->image_id, w->lyrics_id_width, afsi->lyrics_id, w->bitrate_width, afhi->bitrate, @@ -959,6 +963,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, "%s: %lu\n" /* seconds total */ "%s: %s\n" /* last played time */ "%s: %d\n" /* num_played */ + "%s: %u\n" /* ampplification */ "%s" /* tag info */ "%s: %lu\n" /* chunk time */ "%s: %lu\n", /* num chunks */ @@ -979,6 +984,7 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, status_item_list[SI_SECONDS_TOTAL], afhi->seconds_total, status_item_list[SI_LAST_PLAYED], last_played_time, status_item_list[SI_NUM_PLAYED], afsi->num_played, + status_item_list[SI_AMPLIFICATION], afsi->amp, afhi->info_string, status_item_list[SI_CHUNK_TIME], tv2ms(&afhi->chunk_tv), status_item_list[SI_NUM_CHUNKS], afhi->chunks_total @@ -1249,6 +1255,8 @@ static int prepare_ls_row(struct osl_row *row, void *ls_opts) /* get the number of chars to print this amount of time */ tmp = get_duration_width(d->afhi.seconds_total); w->duration_width = PARA_MAX(w->duration_width, tmp); + GET_NUM_DIGITS(d->afsi.amp, &num_digits); + w->amp_width = PARA_MAX(w->amp_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 "-") */ @@ -1912,11 +1920,13 @@ struct com_touch_options { int32_t num_played; /** New last played count. */ int64_t last_played; - /** new lyrics id. */ + /** New lyrics id. */ int32_t lyrics_id; - /** new image id. */ + /** New image id. */ int32_t image_id; - /** command line flags (see \ref touch_flags). */ + /** New amplification value. */ + int32_t amp; + /** Command line flags (see \ref touch_flags). */ unsigned flags; }; @@ -1937,7 +1947,7 @@ static int touch_audio_file(__a_unused struct osl_table *table, struct osl_object obj; struct afs_info old_afsi, new_afsi; int ret, no_options = tad->cto->num_played < 0 && tad->cto->last_played < 0 && - tad->cto->lyrics_id < 0 && tad->cto->image_id < 0; + tad->cto->lyrics_id < 0 && tad->cto->image_id < 0 && tad->cto->amp < 0; struct afsi_change_event_data aced; ret = get_afsi_object_of_row(row, &obj); @@ -1971,6 +1981,7 @@ static int touch_audio_file(__a_unused struct osl_table *table, new_afsi.num_played = tad->cto->num_played; if (tad->cto->last_played >= 0) new_afsi.last_played = tad->cto->last_played; + new_afsi.amp = tad->cto->amp; } tad->num_matches++; save_afsi(&new_afsi, &obj); /* in-place update */ @@ -2018,7 +2029,8 @@ int com_touch(int fd, int argc, char * const * const argv) .num_played = -1, .last_played = -1, .lyrics_id = -1, - .image_id = -1 + .image_id = -1, + .amp = -1, }; struct osl_object query = {.data = &cto, .size = sizeof(cto)}; int i, ret; @@ -2056,6 +2068,16 @@ int com_touch(int fd, int argc, char * const * const argv) return ret; continue; } + if (!strncmp(arg, "-a", 2)) { + int32_t val; + ret = para_atoi32(arg + 2, &val); + if (ret < 0) + return ret; + if (val < 0 || val > 255) + return -ERRNO_TO_PARA_ERROR(EINVAL); + cto.amp = val; + continue; + } if (!strcmp(arg, "-p")) { cto.flags |= TOUCH_FLAG_FNM_PATHNAME; continue;