add wav_player_start_loop_stop_others internal api
[platform/core/api/wav-player.git] / test / wav_player_test.c
index 36d1357..d8eac67 100644 (file)
@@ -43,6 +43,7 @@ void help()
                   "  -s, --streamtype          stream type (0:media(default), 1:system, 2:notification, 3:voice-information, 4:solo)\n"
                   "  -i, --iterate             how many times to play\n"
                   "  -q, --quickplay           play quick\n"
+                  "  -o, --stopothers          play after stopping others\n"
                   "  -h, --help                help\n");
 }
 
@@ -59,7 +60,7 @@ void stream_focus_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e
        return;
 }
 
-void wav_play_test(const char *file_path, int iterate, int stream_type)
+void wav_play_test(const char *file_path, int iterate, int stream_type, bool stop_others)
 {
        int ret = 0;
        sound_stream_info_h stream_info;
@@ -101,8 +102,13 @@ void wav_play_test(const char *file_path, int iterate, int stream_type)
        }
 
        printf("Play Wav, File Path : %s, Iterate : %d\n", file_path, iterate);
-       ret = wav_player_start_loop(file_path, stream_info, iterate, _player_stop_cb, (void*)stream_info, &gid);
-       printf("wav_player_start_loop(id=%d) ret = %d\n", gid, ret);
+       if (stop_others) {
+               ret = wav_player_start_loop_stop_others(file_path, stream_info, iterate, _player_stop_cb, (void*)stream_info, &gid);
+               printf("wav_player_start_loop_stop_others(id=%d) ret = %d\n", gid, ret);
+       } else {
+               ret = wav_player_start_loop(file_path, stream_info, iterate, _player_stop_cb, (void*)stream_info, &gid);
+               printf("wav_player_start_loop(id=%d) ret = %d\n", gid, ret);
+       }
        if (ret) {
                sound_manager_destroy_stream_information(stream_info);
                return;
@@ -155,6 +161,7 @@ int main(int argc, char**argv)
        int iterate = 1;
        int stream_type = 0;
        bool quickplay = false;
+       bool stop_others = false;
        char file_path[FILE_PATH_MAX] = DEFAULT_FILE;
        struct sigaction sig_action;
        sig_action.sa_handler = __sig_handler;
@@ -171,26 +178,32 @@ int main(int argc, char**argv)
                        {"file"       , required_argument, 0, 'f'},
                        {"streamtype" , required_argument, 0, 's'},
                        {"quickplay"  , no_argument,       0, 'q'},
+                       {"stopothers" , no_argument,       0, 'o'},
+                       {"help"       , no_argument,       0, 'h'},
                        { 0, 0, 0, 0 }
                };
 
-               if ((opt = getopt_long(argc, argv, "i:f:s:q", long_options, &opt_idx)) == -1)
+               if ((opt = getopt_long(argc, argv, "i:f:s:qoh", long_options, &opt_idx)) == -1)
                        break;
 
+               printf("opt = %d(%c), opt_idx = %d\n", opt, opt, opt_idx);
+
                switch (opt) {
-               case 'f':
-                       strncpy(file_path, optarg, FILE_PATH_MAX - 1);
-                       file_path[FILE_PATH_MAX - 1] = '\0';
-                       break;
                case 'i':
                        iterate = atoi(optarg);
                        break;
+               case 'f':
+                       snprintf(file_path, FILE_PATH_MAX, "%s", optarg);
+                       break;
                case 's':
                        stream_type = atoi(optarg);
                        break;
                case 'q':
                        quickplay = true;
                        break;
+               case 'o':
+                       stop_others = true;
+                       break;
                case 'h':
                default:
                        help();
@@ -201,7 +214,7 @@ int main(int argc, char**argv)
        if (quickplay)
                wav_play_test_quick(file_path);
        else
-               wav_play_test(file_path, iterate, stream_type);
+               wav_play_test(file_path, iterate, stream_type, stop_others);
 
        return 0;
 }