]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Teach the touch command about amplification.
authorAndre Noll <maan@systemlinux.org>
Sun, 6 Jul 2008 17:27:31 +0000 (19:27 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 6 Jul 2008 17:27:31 +0000 (19:27 +0200)
afs.cmd
aft.c

diff --git a/afs.cmd b/afs.cmd
index 3f44873e444d7036f7b12b42fe4127420786cd71..8d8ee12347b89ee69fa1647b6383fa61a7eb181d 100644 (file)
--- 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.
 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.
 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:
 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
 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 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;
        int32_t num_played;
        /** New last played count. */
        int64_t last_played;
-       /** new lyrics id. */
+       /** New lyrics id. */
        int32_t lyrics_id;
        int32_t lyrics_id;
-       /** new image id. */
+       /** New image id. */
        int32_t 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;
 };
 
        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.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 */
        }
        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,
                .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;
        };
        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;
                }
                                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;
                if (!strcmp(arg, "-p")) {
                        cto.flags |= TOUCH_FLAG_FNM_PATHNAME;
                        continue;