]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aft.c
Teach the touch command about amplification.
[paraslash.git] / aft.c
diff --git a/aft.c b/aft.c
index 49cdf0503da4fcec6c9ac5581324680575275632..a8fe08105912af0ee5235a255f13f400b1f1bf2f 100644 (file)
--- 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;