From: Jeongho Mok Date: Thu, 16 Jul 2015 07:48:03 +0000 (+0900) Subject: Improve test util X-Git-Tag: submit/tizen/20150717.050731^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F54%2F44054%2F1;p=platform%2Fcore%2Fapi%2Ftone-player.git Improve test util [Version] Release 0.1.3-18 [Profile] Common [Issue Type] Test Change-Id: If5fed7bdf3e539633ecc3512f348550fcac93d0f --- diff --git a/packaging/capi-media-tone-player.spec b/packaging/capi-media-tone-player.spec index 768d5e7..f4e3b74 100755 --- a/packaging/capi-media-tone-player.spec +++ b/packaging/capi-media-tone-player.spec @@ -1,7 +1,7 @@ Name: capi-media-tone-player Summary: A tone player library in Tizen C API Version: 0.1.3 -Release: 17 +Release: 18 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/test/multimedia_tone_player_test.c b/test/multimedia_tone_player_test.c index 0de8b91..201cc91 100755 --- a/test/multimedia_tone_player_test.c +++ b/test/multimedia_tone_player_test.c @@ -22,41 +22,102 @@ #include #include #include +#include + +#define TONE_FIRST TONE_TYPE_DTMF_0 +#define TONE_LAST TONE_TYPE_USER_DEFINED_HIGH_FRE static GMainLoop *g_mainloop = NULL; static GThread *event_thread; -gpointer GmainThread(gpointer data){ +gpointer GmainThread(gpointer data) { g_mainloop = g_main_loop_new (NULL, 0); g_main_loop_run (g_mainloop); return NULL; } -void tone_play_test(){ +void help() +{ + printf("Usage : "); + printf("multimedia_tone_player_test [OPTION]\n\n" + " -f, --from from which tone type\n" + " -t, --to to which tone type\n" + " -d, --duration duration(ms)\n" + " -s, --sleep sleep time after play start(ms)\n" + " -h, --help help\n"); +} + +void tone_play_test(int from, int to, int duration, int sleep_time) +{ int i ; - for( i =0 ; i <= 106 ; i++){ - printf("play %d sound\n", i); - tone_player_start(i, SOUND_TYPE_MEDIA ,500,NULL); - usleep(1000); + printf("From : %2d, To : %2d, Duration : %4d, sleep_time : %4d\n", from, to, duration, sleep_time); + if (from < TONE_FIRST || to < TONE_FIRST || duration < 0 || from > to || from > TONE_LAST || to > TONE_LAST || sleep_time < 0) { + printf("Wrong Parameter\n"); + return; } -// tone_player_start(SOUND_TONE_DTMF_C, SOUND_TYPE_MEDIA ,100000,NULL); - sleep(1000); + for(i = from ;i <= to ;i++) { + printf("Play Tone : %d\n", i); + tone_player_start(i, SOUND_TYPE_MEDIA , duration, NULL); + usleep(sleep_time * 1000); + } } -int main(int argc, char**argv) +int main(int argc, char** argv) { - if( !g_thread_supported() ) - { - g_thread_init(NULL); + GError *gerr = NULL; + int from = TONE_TYPE_DTMF_0, to = TONE_TYPE_DTMF_S; + int duration = 500, sleep_time = -1; + + while (1) { + int opt; + int opt_idx = 0; + + static struct option long_options[] = + { + {"from" , required_argument, 0, 'f'}, + {"to" , required_argument, 0, 't'}, + {"duration", required_argument, 0, 'd'}, + {"sleep" , required_argument, 0, 's'}, + {"help" , no_argument , 0, 'h'}, + { 0, 0, 0, 0 } + }; + + if ((opt = getopt_long(argc, argv, "f:t:d:s:h", long_options, &opt_idx)) == -1) + break; + + switch (opt) { + case 'f': + from = atoi(optarg); + break; + case 't': + to = atoi(optarg); + break; + case 'd': + duration = atoi(optarg); + break; + case 's': + sleep_time = atoi(optarg); + break; + case 'h': + default: + help(); + return 0; + } } - GError *gerr = NULL; + if (sleep_time == -1) + sleep_time = duration; + + if (!g_thread_supported()) + g_thread_init(NULL); + event_thread = g_thread_create(GmainThread, NULL, 1, &gerr); - tone_play_test(); + tone_play_test(from, to, duration, sleep_time); + return 0; }