audio-io fixed crash at audio_in_read() of another thread.
[platform/core/api/audio-io.git] / test / audio_io_test.c
1 /*
2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21 #include <math.h>
22 #include <sound_manager.h>
23 #include <audio_io.h>
24
25 #ifndef M_PI
26 #define M_PI  (3.14159265)
27 #endif
28
29 #define TABLE_SIZE   (200)
30 typedef struct {
31         float sine[TABLE_SIZE];
32         int left_channel;
33         int right_channel;
34 } test_wav_t;
35 test_wav_t test_wav;
36
37 static int ch_table[3] = { 0, AUDIO_CHANNEL_MONO, AUDIO_CHANNEL_STEREO };
38
39 void play_file(char *file, int length, int ch)
40 {
41         audio_out_h output;
42         FILE *fp = fopen(file, "r");
43         if (fp == NULL) {
44                 printf("fopen failed\n");
45                 return;
46         }
47
48         char *buf = malloc(length);
49         if (buf == NULL) {
50                 printf("malloc failed\n");
51                 fclose(fp);
52                 return;
53         }
54
55         printf("start to play [%s][%d][%d]\n", file, length, ch);
56         audio_out_create_new(44100, ch_table[ch], AUDIO_SAMPLE_TYPE_S16_LE, &output);
57         if (fread(buf, 1, length, fp) != length)
58                 printf("error!!!!\n");
59
60         audio_out_prepare(output);
61         audio_out_write(output, buf, length);
62         audio_out_unprepare(output);
63
64         audio_out_destroy(output);
65
66         fclose(fp);
67
68         printf("play done\n");
69 }
70
71 #define DUMP_FILE "/root/test.raw"
72
73 void play_file_sample(char *file, int frequency, int ch, int type)
74 {
75         audio_out_h output;
76         int file_size = 0;
77         int read_bytes = 0;
78         int buffer_size = 0;
79         char *buf = NULL;
80
81         if (ch < 0 || ch > 2)
82                 ch = 0;
83
84         FILE *fp = fopen(file, "r");
85         if (fp == NULL) {
86                 printf("open failed\n");
87                 return;
88         }
89         /* Get the size */
90         fseek(fp, 0, SEEK_END);
91         file_size = ftell(fp);
92         fseek(fp, 0, SEEK_SET);
93
94         printf("start to play [%s] of size [%d] with [%d][%d][%d]\n", file, file_size, frequency, ch, type);
95         if (type)
96                 audio_out_create_new(frequency, ch_table[ch], AUDIO_SAMPLE_TYPE_S16_LE, &output);
97         else
98                 audio_out_create_new(frequency, ch_table[ch], AUDIO_SAMPLE_TYPE_U8, &output);
99
100         audio_out_prepare(output);
101         audio_out_get_buffer_size(output, &buffer_size);
102
103         buf = (char *)malloc(buffer_size);
104         if (buf == NULL) {
105                 printf("malloc failed\n");
106                 audio_out_unprepare(output);
107                 audio_out_destroy(output);
108                 fclose(fp);
109                 return;
110         }
111
112         while (file_size > 0) {
113                 read_bytes = fread(buf, 1, buffer_size, fp);
114                 printf("Read %d Requested - %d\n", read_bytes, buffer_size);
115                 audio_out_write(output, buf, read_bytes);
116                 file_size = file_size - read_bytes;
117         }
118
119         audio_out_unprepare(output);
120         audio_out_destroy(output);
121
122         free(buf);
123         fclose(fp);
124         printf("play done\n");
125 }
126
127 int audio_io_test(int length, int num, int ch)
128 {
129         int ret, size, i;
130         audio_in_h input;
131         if ((ret = audio_in_create(44100, ch_table[ch], AUDIO_SAMPLE_TYPE_S16_LE, &input)) == AUDIO_IO_ERROR_NONE) {
132                 ret = audio_in_ignore_session(input);
133                 if (ret != 0) {
134                         printf("ERROR, set session mix\n");
135                         audio_in_destroy(input);
136                         return 0;
137                 }
138
139                 ret = audio_in_prepare(input);
140                 if (ret != 0) {
141                         printf("ERROR, prepare\n");
142                         audio_in_destroy(input);
143                         return 0;
144                 }
145
146                 FILE *fp = fopen(DUMP_FILE, "wb+");
147
148                 if (fp == NULL) {
149                         printf("ERROR, file open failed\n");
150                         audio_in_destroy(input);
151                         return 0;
152                 }
153
154                 if ((ret = audio_in_get_buffer_size(input, &size)) == AUDIO_IO_ERROR_NONE) {
155                         size = length;
156                         char *buffer = alloca(size);
157
158                         for (i = 0; i < num; i++) {
159                                 printf("### loop = %d ============== \n", i);
160                                 if ((ret = audio_in_read(input, (void *)buffer, size)) > AUDIO_IO_ERROR_NONE) {
161                                         fwrite(buffer, size, sizeof(char), fp);
162                                         printf("PASS, size=%d, ret=%d\n", size, ret);
163                                 } else {
164                                         printf("FAIL, size=%d, ret=%d\n", size, ret);
165                                 }
166                         }
167                 }
168
169                 fclose(fp);
170
171                 audio_in_unprepare(input);
172                 audio_in_destroy(input);
173         }
174
175         play_file(DUMP_FILE, length * num, ch);
176
177         return 1;
178 }
179
180 int audio_io_loopback_in_test()
181 {
182         int ret, size;
183         audio_in_h input;
184         FILE *fp = fopen("/tmp/dump_test.raw", "wb+");
185
186         if (fp == NULL) {
187                 printf("open failed \n");
188                 return 0;
189         }
190
191         if ((ret = audio_in_create(16000, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &input)) == AUDIO_IO_ERROR_NONE) {
192                 ret = audio_in_ignore_session(input);
193                 if (ret != 0) {
194                         printf("ERROR, set session mix\n");
195                         goto exit;
196                 }
197
198                 ret = audio_in_prepare(input);
199                 if (ret != 0) {
200                         printf("ERROR, prepare\n");
201                         goto exit;
202                 }
203
204                 ret = audio_in_get_buffer_size(input, &size);
205                 if (ret != AUDIO_IO_ERROR_NONE) {
206                         printf("audio_in_get_buffer_size failed.\n");
207                         goto exit;
208                 }
209
210                 while (1) {
211                         char *buffer = alloca(size);
212                         if ((ret = audio_in_read(input, (void *)buffer, size)) > AUDIO_IO_ERROR_NONE) {
213                                 fwrite(buffer, size, sizeof(char), fp);
214                                 printf("PASS, size=%d, ret=%d\n", size, ret);
215                         } else {
216                                 printf("FAIL, size=%d, ret=%d\n", size, ret);
217                         }
218                 }
219         }
220
221  exit:
222         audio_in_destroy(input);
223
224         fclose(fp);
225
226         return ret;
227
228 }
229
230 int audio_io_loopback_test()
231 {
232         int ret, size;
233         audio_in_h input;
234         audio_out_h output;
235         char *buffer = NULL;
236
237         ret = audio_in_create(16000, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &input);
238         if (ret != AUDIO_IO_ERROR_NONE) {
239                 printf("audio_in_create_ex failed. \n");
240                 return 0;
241         }
242         ret = audio_out_create_new(16000, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &output);
243         if (ret != AUDIO_IO_ERROR_NONE) {
244                 printf("audio_out_create failed. \n");
245                 return 0;
246         }
247
248         ret = audio_in_prepare(input);
249         if (ret != 0) {
250                 printf("audio_in_prepare failed, err(0x%x)\n", ret);
251                 audio_in_destroy(input);
252                 return 0;
253         } else {
254                 ret = audio_in_get_buffer_size(input, &size);
255                 if (ret != AUDIO_IO_ERROR_NONE) {
256                         printf("audio_in_get_buffer_size failed, err(0x%x)\n", ret);
257                         return 0;
258                 } else {
259                         printf("size(%d)\n", size);
260                         buffer = alloca(size);
261                 }
262         }
263
264         ret = audio_out_prepare(output);
265         if (ret != 0) {
266                 printf("audio_out_prepare failed, err(0x%x)\n", ret);
267                 audio_out_destroy(output);
268                 return 0;
269         }
270
271         if (buffer == NULL) {
272                 printf("buffer is null\n");
273                 return 0;
274         }
275
276         while (1) {
277                 ret = audio_in_read(input, (void *)buffer, size);
278                 if (ret > AUDIO_IO_ERROR_NONE) {
279                         ret = audio_out_write(output, buffer, size);
280                         if (ret > AUDIO_IO_ERROR_NONE)
281                                 printf("audio read/write success. buffer(%p), size(%d)\n", buffer, size);
282                         else
283                                 printf("audio read success, write failed. buffer(%p), size(%d)\n", buffer, size);
284                 } else
285                         printf("audio read/write failed. buffer(%p), size(%d)\n", buffer, size);
286         }
287
288 }
289
290 audio_in_h input;
291 audio_out_h output;
292
293 FILE *fp_w = NULL;
294
295 sound_stream_info_h g_stream_info_read_h = NULL;
296 sound_stream_info_h g_stream_info_write_h = NULL;
297
298 static void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
299 {
300         int ret = 0;
301         sound_stream_focus_state_e playback_focus_state;
302         sound_stream_focus_state_e recording_focus_state;
303         printf("*** focus_callback_read is called, stream_info(%p, read(%p)/write(%p)) ***\n", stream_info, g_stream_info_read_h, g_stream_info_write_h);
304         printf(" - reason_for_change(%d), additional_info(%s), user_data(%p)\n", reason_for_change, additional_info, user_data);
305         ret = sound_manager_get_focus_state(stream_info, &playback_focus_state, &recording_focus_state);
306         if (!ret)
307                 printf(" - focus_state(playback_focus:%d, recording_focus:%d)\n", playback_focus_state, recording_focus_state);
308
309         return;
310 }
311
312 static void _audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *user_data)
313 {
314         const void *buffer = NULL;
315         unsigned int len = (unsigned int)nbytes;
316
317         if (len > 0) {
318                 audio_in_peek(handle, &buffer, &len);
319                 if (fp_w)
320                         fwrite(buffer, sizeof(char), len, fp_w);
321                 audio_in_drop(handle);
322         }
323 }
324
325 static void _audio_io_stream_write_cb(audio_out_h handle, size_t nbytes, void *user_data)
326 {
327         short *buffer = NULL;
328         int i = 0;
329
330         if (nbytes > 0) {
331                 buffer = (short *)malloc(nbytes);
332                 if (buffer == NULL) {
333                         printf("malloc failed\n");
334                         return;
335                 }
336                 memset(buffer, 0, nbytes);
337
338                 for (i = 0; i < nbytes / 2; i += 2) {
339                         buffer[i] = (short)32768 *test_wav.sine[test_wav.left_channel]; /* left */
340                         buffer[i + 1] = (short)32768 *test_wav.sine[test_wav.right_channel];    /* right */
341                         test_wav.left_channel += 1;
342                         if (test_wav.left_channel >= TABLE_SIZE)
343                                 test_wav.left_channel -= TABLE_SIZE;
344                         test_wav.right_channel += 3;
345                         if (test_wav.right_channel >= TABLE_SIZE)
346                                 test_wav.right_channel -= TABLE_SIZE;
347                 }
348
349                 audio_out_write(handle, buffer, nbytes);
350
351                 free(buffer);
352         }
353 }
354
355 static void _audio_in_state_cb(audio_in_h handle, audio_io_state_e previous, audio_io_state_e current, bool by_policy, void *user_data)
356 {
357         printf(">>> _audio_in_state_cb() : handle(%p), current(%d), previous(%d), by_policy(%d), user_data(%p)\n", handle, current, previous, by_policy, user_data);
358 }
359
360 static void _audio_out_state_cb(audio_in_h handle, audio_io_state_e previous, audio_io_state_e current, bool by_policy, void *user_data)
361 {
362         printf(">>> _audio_out_state_cb() : handle(%p), current(%d), previous(%d), by_policy(%d), user_data(%p)\n", handle, current, previous, by_policy, user_data);
363 }
364
365 int _convert_cmd_and_run(char cmd, int mode)
366 {
367         int ret = 0;
368         switch (cmd) {
369         case 'P':
370                 if (mode & 0x01)
371                         ret = audio_out_prepare(output);
372                 if (mode & 0x02)
373                         ret = audio_in_prepare(input);
374                 break;
375         case 'u':
376                 if (mode & 0x01)
377                         ret = audio_out_unprepare(output);
378                 if (mode & 0x02)
379                         ret = audio_in_unprepare(input);
380                 break;
381         case 'p':
382                 if (mode & 0x01)
383                         ret = audio_out_pause(output);
384                 if (mode & 0x02)
385                         ret = audio_in_pause(input);
386                 break;
387         case 'r':
388                 if (mode & 0x01)
389                         ret = audio_out_resume(output);
390                 if (mode & 0x02)
391                         ret = audio_in_resume(input);
392                 break;
393         case 'd':
394                 if (mode & 0x01)
395                         ret = audio_out_drain(output);
396                 break;
397         case 'f':
398                 if (mode & 0x01)
399                         ret = audio_out_flush(output);
400                 if (mode & 0x02)
401                         ret = audio_in_flush(input);
402                 break;
403         case 'i':
404                 ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, focus_callback, NULL, &g_stream_info_write_h);
405                 if (ret)
406                         printf("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
407                 break;
408         case 'q':                                       /* quit */
409                 ret = 1;
410                 break;
411         default:
412                 ret = 1;
413                 break;
414         }
415         return ret;
416 }
417
418 int audio_io_async_test(int mode)
419 {
420         int ret, size;
421         char *buffer = NULL;
422         int i = 0;
423
424         char cmd = 0;
425         int cmd_ret;
426
427         int write_mode = (mode & 0x01);
428         int read_mode = (mode & 0x02);
429
430         sound_stream_focus_state_e playback_focus_state;
431         sound_stream_focus_state_e recording_focus_state;
432
433         if ((write_mode == 0) && (read_mode == 0)) {
434                 printf("not vaild mode.\n");
435                 return 0;
436         }
437
438         if (read_mode) {
439
440                 printf("audio_in_create\n");
441                 ret = audio_in_create(44100, AUDIO_CHANNEL_STEREO, AUDIO_SAMPLE_TYPE_S16_LE, &input);
442                 if (ret != AUDIO_IO_ERROR_NONE) {
443                         printf("audio_in_create_ex failed. \n");
444                         return 0;
445                 }
446                 printf("audio_in_create success!!! [%p]\n", input);
447
448                 ret = audio_in_set_stream_cb(input, _audio_io_stream_read_cb, NULL);
449                 if (ret != AUDIO_IO_ERROR_NONE) {
450                         printf("audio_in_set_stream_cb failed. \n");
451                         goto EXIT;
452                 }
453                 printf("audio_in_set_stream_cb success!!! [%p]\n", input);
454
455                 ret = audio_in_set_state_changed_cb(input, _audio_in_state_cb, NULL);
456                 if (ret != AUDIO_IO_ERROR_NONE) {
457                         printf("audio_out_set_state_changed_cb failed. \n");
458                         goto EXIT;
459                 }
460                 printf("audio_out_set_state_changed_cb success!!! [%p]\n", input);
461
462                 ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, focus_callback, NULL, &g_stream_info_read_h);
463                 if (ret) {
464                         printf("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
465                         goto EXIT;
466                 }
467                 ret = audio_in_set_stream_info(input, g_stream_info_read_h);
468                 if (ret)
469                         printf("fail to audio_in_set_stream_info(), ret(0x%x)\n", ret);
470
471                 ret = sound_manager_acquire_focus(g_stream_info_read_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL);
472                 if (ret) {
473                         printf("fail to sound_manager_acquire_focus() for RECORDING, ret(0x%x)\n", ret);
474                         goto EXIT;
475                 }
476
477                 fp_w = fopen("/tmp/pcm_w.raw", "w");
478         }
479
480         if (write_mode) {
481                 printf("before audio_out_create\n");
482                 getchar();
483
484                 printf("audio_out_create\n");
485                 ret = audio_out_create_new(44100, AUDIO_CHANNEL_STEREO, AUDIO_SAMPLE_TYPE_S16_LE, &output);
486                 if (ret != AUDIO_IO_ERROR_NONE) {
487                         printf("audio_out_create failed. \n");
488                         goto EXIT;
489                 }
490                 printf("audio_out_create success!!! [%p]\n", output);
491
492                 ret = audio_out_set_stream_cb(output, _audio_io_stream_write_cb, NULL);
493                 if (ret != AUDIO_IO_ERROR_NONE) {
494                         printf("audio_out_set_stream_cb failed. \n");
495                         goto EXIT;
496                 }
497                 printf("audio_out_set_stream_cb success!!! [%p]\n", output);
498
499                 ret = audio_out_set_state_changed_cb(output, _audio_out_state_cb, NULL);
500                 if (ret != AUDIO_IO_ERROR_NONE) {
501                         printf("audio_out_set_state_changed_cb failed. \n");
502                         goto EXIT;
503                 }
504                 printf("audio_out_set_state_changed_cb success!!! [%p]\n", output);
505
506                 ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, focus_callback, NULL, &g_stream_info_write_h);
507                 if (ret) {
508                         printf("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret);
509                         goto EXIT;
510                 }
511                 ret = audio_out_set_stream_info(output, g_stream_info_write_h);
512                 if (ret)
513                         printf("fail to audio_out_set_stream_info(), ret(0x%x)\n", ret);
514
515                 ret = sound_manager_acquire_focus(g_stream_info_write_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
516                 if (ret) {
517                         printf("fail to sound_manager_acquire_focus() for PLAYBACK, ret(0x%x)\n", ret);
518                         goto EXIT;
519                 }
520
521                 /* generate wave data */
522                 for (i = 0; i < TABLE_SIZE; i++)
523                         test_wav.sine[i] = 0.9 * (float)sin(((double)i / (double)TABLE_SIZE) * M_PI * 2.);
524                 test_wav.left_channel = test_wav.right_channel = 0;
525         }
526
527         if (read_mode) {
528                 printf("before audio_in_prepare\n");
529                 getchar();
530                 printf("audio_in_prepare\n");
531                 ret = audio_in_prepare(input);
532                 if (ret != 0) {
533                         printf("audio_in_prepare failed, err(0x%x)\n", ret);
534                         audio_in_destroy(input);
535                         goto EXIT;
536                 } else {
537                         ret = audio_in_get_buffer_size(input, &size);
538                         if (ret != AUDIO_IO_ERROR_NONE) {
539                                 printf("audio_in_get_buffer_size failed, err(0x%x)\n", ret);
540                                 goto EXIT;
541                         } else {
542                                 printf("size(%d)\n", size);
543                                 buffer = alloca(size);
544                         }
545                 }
546
547                 if (buffer == NULL) {
548                         printf("buffer is null\n");
549                         goto EXIT;
550                 }
551         }
552
553         if (write_mode) {
554                 printf("before audio_out_prepare\n");
555                 getchar();
556                 printf("audio_out_prepare\n");
557                 ret = audio_out_prepare(output);
558                 if (ret != 0) {
559                         printf("audio_out_prepare failed, err(0x%x)\n", ret);
560                         audio_out_destroy(output);
561                         goto EXIT;
562                 }
563         }
564
565         do {
566                 int gotchar;
567                 printf("command(q:quit) : ");
568                 gotchar = getchar();
569                 if (gotchar == EOF)
570                         goto EXIT;
571                 if (cmd != '\n')
572                         getchar();
573                 cmd_ret = _convert_cmd_and_run(cmd, mode);
574                 printf("  - result code : %d\n", cmd_ret);
575         } while (cmd != 'q');
576
577 EXIT:
578         if (read_mode) {
579                 if (input) {
580                         printf("audio_in_unprepare\n");
581                         audio_in_unprepare(input);
582                         printf("audio_in_destroy\n");
583                         audio_in_destroy(input);
584                         input = NULL;
585                 }
586
587                 if (fp_w) {
588                         fclose(fp_w);
589                         fp_w = NULL;
590                 }
591
592                 if (g_stream_info_read_h) {
593                         ret = sound_manager_get_focus_state(g_stream_info_read_h, NULL, &recording_focus_state);
594                         if (recording_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
595                                 ret = sound_manager_release_focus(g_stream_info_read_h, SOUND_STREAM_FOCUS_FOR_RECORDING, NULL);
596                                 if (ret)
597                                         printf("fail to sound_manager_release_focus() for recording, ret(0x%x)\n", ret);
598                         }
599                         ret = sound_manager_destroy_stream_information(g_stream_info_read_h);
600                         if (ret)
601                                 printf("fail to sound_manager_destroy_stream_information(), ret(0x%x)\n", ret);
602                         g_stream_info_read_h = NULL;
603                 }
604         }
605
606         if (write_mode) {
607                 if (output) {
608                         printf("audio_out_unprepare\n");
609                         audio_out_unprepare(output);
610                         printf("audio_out_destroy\n");
611                         audio_out_destroy(output);
612                 }
613
614                 if (g_stream_info_write_h) {
615                         ret = sound_manager_get_focus_state(g_stream_info_write_h, &playback_focus_state, NULL);
616                         if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
617                                 ret = sound_manager_release_focus(g_stream_info_write_h, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
618                                 if (ret)
619                                         printf("fail to sound_manager_release_focus() for playback, ret(0x%x)\n", ret);
620                         }
621                         ret = sound_manager_destroy_stream_information(g_stream_info_write_h);
622                         if (ret)
623                                 printf("fail to sound_manager_destroy_stream_information(), ret(0x%x)\n", ret);
624                         g_stream_info_write_h = NULL;
625                 }
626         }
627
628         return 0;
629 }
630
631 int main(int argc, char **argv)
632 {
633         if (argc == 2 && !strcmp(argv[1], "call-forwarding-loop")) {
634                 audio_io_loopback_test();
635         } else if (argc == 2 && !strcmp(argv[1], "call-forwarding-in")) {
636                 audio_io_loopback_in_test();
637         } else if (argc == 3 && !strcmp(argv[1], "async")) {
638                 audio_io_async_test(atoi(argv[2]));
639         } else if (argc == 4) {
640                 int channel_idx = atoi(argv[3]);
641                 if (channel_idx < 0 || channel_idx > 2) {
642                         printf("Invalid channel\n");
643                         return 0;
644                 }
645                 printf("run with [%s][%s][%s]\n", argv[1], argv[2], argv[3]);
646                 audio_io_test(atoi(argv[1]), atoi(argv[2]), channel_idx);
647         } else if (argc == 6) {
648                 play_file_sample(argv[2], atoi(argv[3]), atoi(argv[4]), atoi(argv[5]));
649         } else {
650                 printf("1. usage : audio_io_test call-forwarding-loop\n");
651                 printf("2. usage : audio_io_test call-forwarding-in\n");
652                 printf("3. usage : audio_io_test [length to read] [number of iteration] [channels]\n");
653                 printf("4. usage : audio_io_test async [write(1) | read(2)]\n");
654                 printf("5. Uasge : audio_io_test play [filename] [sample rate] [channels] [type(0:U8)]\n");
655         }
656         return 0;
657 }