test: add volume class support for the test program
authorJanos Kovacs <jankovac503@gmail.com>
Mon, 27 Aug 2012 22:22:33 +0000 (01:22 +0300)
committerIsmo Puustinen <ismo.puustinen@intel.com>
Mon, 11 Mar 2013 11:47:44 +0000 (13:47 +0200)
audiotest/avsys-audio-test.c

index be17305..0f7dd98 100644 (file)
@@ -46,6 +46,13 @@ void usage(char *name)
        printf("-r\t\trouting\n");
        printf("\t\trouting 0 : following policy\n");
        printf("\t\trouting 1 : forced set to alsa\n");
+       printf("-v\t\volume type\n");
+       printf("\t\tvolume type 0 : system\n");
+       printf("\t\tvolume type 1 : notification\n");
+       printf("\t\tvolume type 2 : alarm\n");
+       printf("\t\tvolume type 3 : ringtone\n");
+       printf("\t\tvolume type 4 : media\n");
+       printf("\t\tvolume type 5 : call\n");
        printf("\n");
        return;
 }
@@ -62,7 +69,7 @@ enum {
 static struct sigaction sigterm_action; /* Backup pointer of SIGTERM signal handler */
 int g_interrupted;
 
-int __make_param(int op, int mode, int routing, avsys_audio_param_t *param)
+int __make_param(int op, int mode, int routing, int voltyp, avsys_audio_param_t *param)
 {
        if (!param)
                return -1;
@@ -75,7 +82,7 @@ int __make_param(int op, int mode, int routing, avsys_audio_param_t *param)
                return -1;
 
        param->priority = AVSYS_AUDIO_PRIORITY_NORMAL;
-       param->vol_type = AVSYS_AUDIO_VOLUME_TYPE_SYSTEM;
+       param->vol_type = voltyp;
        param->handle_route = routing;
 
        switch (mode) {
@@ -105,7 +112,7 @@ int __make_param(int op, int mode, int routing, avsys_audio_param_t *param)
        }
        return 0;
 }
-int _playback(int mode, int routing, char *filename)
+int _playback(int mode, int routing, int voltyp, char *filename)
 {
        int res = 0;
        avsys_audio_param_t param;
@@ -120,7 +127,7 @@ int _playback(int mode, int routing, char *filename)
 
        memset(&param, '\0', sizeof(avsys_audio_param_t));
 
-       if (__make_param(OP_PLAYBACK, mode, routing, &param)) {
+       if (__make_param(OP_PLAYBACK, mode, routing, voltyp, &param)) {
                printf("Can not make audio parameter\n");
                return -1;
        }
@@ -159,7 +166,7 @@ FAIL:
        return res;
 }
 
-int _capture(int mode, int routing, char *filename)
+int _capture(int mode, int routing, int voltyp, char *filename)
 {
        int res = 0;
        avsys_audio_param_t param;
@@ -179,7 +186,7 @@ int _capture(int mode, int routing, char *filename)
 
        memset(&param, '\0', sizeof(avsys_audio_param_t));
 
-       if (__make_param(OP_CAPTURE, mode, routing, &param)) {
+       if (__make_param(OP_CAPTURE, mode, routing, voltyp, &param)) {
                printf("Can not make audio parameter\n");
                return -1;
        }
@@ -233,9 +240,10 @@ int main(int argc, char *argv[])
        int mode = 0;
        int tmp = 0;
        int routing = 0;
+        int voltyp = 4; /* media */
        struct sigaction action;
 
-       while ((opt = getopt(argc, argv, "hpcm:r:")) != -1) {
+       while ((opt = getopt(argc, argv, "hpcm:r:v:")) != -1) {
                switch (opt) {
                case 'h':
                        usage(argv[0]);
@@ -273,6 +281,15 @@ int main(int argc, char *argv[])
                        }
                        routing = tmp;
                        break;
+                case 'v':
+                    tmp = atoi(optarg);
+                    if (tmp < 0 || tmp > AVSYS_AUDIO_VOLUME_TYPE_NUM) {
+                                usage(argv[0]);
+                               printf("MESSAGE : invalid volume type\n");
+                               return -1;
+                    }
+                    voltyp = tmp;
+                    break;
                default:
                        usage(argv[0]);
                        break;
@@ -291,8 +308,8 @@ int main(int argc, char *argv[])
        } else if (operation == OP_PLAYBACK) {
                char *name = NULL;
                name = argv[optind++];
-               printf("op %u, mode %u, routing %d, name %s\n", operation, mode, routing, name);
-               _playback(mode, routing, name);
+               printf("op %u, mode %u, routing %d, voltyp %d, name %s\n", operation, mode, routing, voltyp, name);
+               _playback(mode, routing, voltyp, name);
        } else if (operation == OP_CAPTURE) {
                char *name = NULL;
                name = argv[optind++];
@@ -300,8 +317,8 @@ int main(int argc, char *argv[])
                        printf("Insufficient filename length\n");
                        return -2;
                }
-               printf("op %u, mode %u, routing %d, name %s\n", operation, mode, routing, name);
-               _capture(mode, routing, name);
+               printf("op %u, mode %u, routing %d, voltyp %d name %s\n", operation, mode, routing, voltyp, name);
+               _capture(mode, routing, voltyp, name);
        }
 
        return 0;