xref: /OK3568_Linux_fs/external/rk_pcba_test/pcba_minui/audio_play_test.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  audio_play_test.c  --  audio play test application
3  *
4  *  Copyright (c) 2018 Rockchip Electronics Co. Ltd.
5  *  Author: chad.ma <chad.ma@rock-chips.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * 	 http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <pthread.h>
23 
24 #include <linux/input.h>
25 #include <fcntl.h>
26 #include <dirent.h>
27 #include "common.h"
28 #include "key_test.h"
29 #include "test_case.h"
30 #include "language.h"
31 
32 #include <unistd.h>
33 #include "audio_play_test.h"
34 
35 #define LOG_TAG	    "PCBA [audio play]: "
36 #define LOG(x...)	printf(LOG_TAG x)
37 
38 #define PCBA_TEST_PATH "/data/"
39 #define AUDIO_TIME 5
40 
audio_play_test(void * argv)41 void *audio_play_test(void *argv)
42 {
43     int ret, y;
44     char cmd[128];
45 	struct testcase_info *tc_info = (struct testcase_info *)argv;
46 
47 	if (tc_info->y <= 0)
48 		tc_info->y = get_cur_print_y();
49 	y = tc_info->y;
50 
51     LOG("=========function :%s start=============\n",__func__);
52 	ui_print_xy_rgba(0, y, 255, 255, 0, 255, "%s:[%s..]\n", PCBA_CODEC_PLAY,
53 			 PCBA_TESTING);
54 
55 #ifdef PCBA_PX3SE
56     sprintf(cmd,"aplay -d %d %s%s",AUDIO_TIME,PCBA_TEST_PATH,AUDIO_PLAY_FILE);
57 #endif
58 
59 #ifdef PCBA_3308
60     sprintf(cmd,"aplay %s/%s",PCBA_TEST_PATH,AUDIO_PLAY_FILE);
61 #endif
62 #ifdef PCBA_3229GVA
63     sprintf(cmd,"aplay %s/%s",PCBA_TEST_PATH,AUDIO_PLAY_FILE);
64 #endif
65 
66     ret = run_test_item_cmd(cmd);
67 
68     if(ret == 0) {
69        ui_print_xy_rgba(0, y, 0, 255, 0, 255, "%s:[%s] { %s }\n", PCBA_CODEC_PLAY,
70                 PCBA_SECCESS, "play test success.");
71        tc_info->result = 0;
72        LOG("audio play success.\n");
73    }else  {
74        //ret < 0
75        ui_print_xy_rgba(0, y, 225, 0, 0, 255, "%s:[%s] { %s }\n", PCBA_CODEC_PLAY,
76                 PCBA_FAILED, "play test fail....... ");
77        tc_info->result = -1;
78        LOG("audio play failed.\n");
79        return NULL;
80    }
81 
82     LOG("=========function :%s finish=============\n",__func__);
83     return argv;
84 }
85 
86 
87