From: Andre Noll Date: Sun, 6 Jul 2008 17:27:31 +0000 (+0200) Subject: Teach the touch command about amplification. X-Git-Tag: v0.3.3~52^2~10 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=d20b524267f4c0594e0246643853db8cba68fa10 Teach the touch command about amplification. --- diff --git a/afs.cmd b/afs.cmd index 3f44873e..8d8ee123 100644 --- a/afs.cmd +++ b/afs.cmd @@ -180,7 +180,7 @@ H: a slash (see fnmatch(3)). N: touch P: AFS_READ | AFS_WRITE D: Manipulate the afs data for all audio files matching a pattern. -U: touch [-n numplayed] [-l lastplayed] [-y lyrics_id] [-i image_id] [-v] [-p] pattern +U: touch [-n numplayed] [-l lastplayed] [-y lyrics_id] [-i image_id] [-a amp] [-v] [-p] pattern H: If no option is given, lastplayed is set to the current time H: and numplayed is increased by one. Otherwise, only the given H: options are taken into account. @@ -202,6 +202,8 @@ H: this audio file. H: H: -i Set the image id. Same as -y, but sets the image. H: +H: -a Set the amplification value (0-255). +H: H: -v Verbose mode. Explain what is being done. H: H: -p Pathname match. Match a slash in the path only with a slash diff --git a/aft.c b/aft.c index 49cdf050..a8fe0810 100644 --- a/aft.c +++ b/aft.c @@ -1920,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. */ + uint8_t amp; + /** Command line flags (see \ref touch_flags). */ unsigned flags; }; @@ -1979,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 */ @@ -2026,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 = 0, }; struct osl_object query = {.data = &cto, .size = sizeof(cto)}; int i, ret; @@ -2064,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;