From da1497d9f883abfd3c6984ca9062b011e429fef4 Mon Sep 17 00:00:00 2001 From: Mok Jeongho Date: Fri, 1 Apr 2016 11:41:38 +0900 Subject: [PATCH] Apply tizen coding convention [Version] 0.3.27 [Profile] Common [Issue Type] Coding Convention Change-Id: I093c8bcecdf108b975e2a5b73ce91aa499a8cbb6 --- packaging/capi-media-audio-io.spec | 2 +- src/audio_io.c | 92 +++++++++++++++++++------------------- test/audio_io_test.c | 53 +++++----------------- 3 files changed, 59 insertions(+), 88 deletions(-) diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index e1a86c2..0378f57 100644 --- a/packaging/capi-media-audio-io.spec +++ b/packaging/capi-media-audio-io.spec @@ -1,6 +1,6 @@ Name: capi-media-audio-io Summary: An Audio Input & Audio Output library in Tizen Native API -Version: 0.3.26 +Version: 0.3.27 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/audio_io.c b/src/audio_io.c index d399328..0945815 100644 --- a/src/audio_io.c +++ b/src/audio_io.c @@ -21,232 +21,232 @@ int audio_in_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type , audio_in_h* input) { - return cpp_audio_in_create(sample_rate, channel, type, input); + return cpp_audio_in_create(sample_rate, channel, type, input); } int audio_in_create_loopback(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_in_h* input) { - return cpp_audio_in_create_loopback(sample_rate, channel, type, input); + return cpp_audio_in_create_loopback(sample_rate, channel, type, input); } int audio_in_destroy(audio_in_h input) { - return cpp_audio_in_destroy(input); + return cpp_audio_in_destroy(input); } int audio_in_set_stream_info(audio_in_h input, sound_stream_info_h stream_info) { - return cpp_audio_in_set_stream_info(input, stream_info); + return cpp_audio_in_set_stream_info(input, stream_info); } int audio_in_prepare(audio_in_h input) { - return cpp_audio_in_prepare(input); + return cpp_audio_in_prepare(input); } int audio_in_unprepare(audio_in_h input) { - return cpp_audio_in_unprepare(input); + return cpp_audio_in_unprepare(input); } int audio_in_pause(audio_in_h input) { - return cpp_audio_in_pause(input); + return cpp_audio_in_pause(input); } int audio_in_resume(audio_in_h input) { - return cpp_audio_in_resume(input); + return cpp_audio_in_resume(input); } int audio_in_flush(audio_in_h input) { - return cpp_audio_in_flush(input); + return cpp_audio_in_flush(input); } int audio_in_read(audio_in_h input, void *buffer, unsigned int length) { - return cpp_audio_in_read(input, buffer, length); + return cpp_audio_in_read(input, buffer, length); } int audio_in_get_buffer_size(audio_in_h input, int *size) { - return cpp_audio_in_get_buffer_size(input, size); + return cpp_audio_in_get_buffer_size(input, size); } int audio_in_get_sample_rate(audio_in_h input, int *sample_rate) { - return cpp_audio_in_get_sample_rate(input, sample_rate); + return cpp_audio_in_get_sample_rate(input, sample_rate); } int audio_in_get_channel(audio_in_h input, audio_channel_e *channel) { - return cpp_audio_in_get_channel(input, channel); + return cpp_audio_in_get_channel(input, channel); } int audio_in_get_sample_type(audio_in_h input, audio_sample_type_e *type) { - return cpp_audio_in_get_sample_type(input, type); + return cpp_audio_in_get_sample_type(input, type); } int audio_in_set_interrupted_cb(audio_in_h input, audio_io_interrupted_cb callback, void *user_data) { - return cpp_audio_in_set_interrupted_cb(input, callback, user_data); + return cpp_audio_in_set_interrupted_cb(input, callback, user_data); } int audio_in_unset_interrupted_cb(audio_in_h input) { - return cpp_audio_in_unset_interrupted_cb(input); + return cpp_audio_in_unset_interrupted_cb(input); } int audio_in_ignore_session(audio_in_h input) { - return cpp_audio_in_ignore_session(input); + return cpp_audio_in_ignore_session(input); } int audio_in_set_stream_cb(audio_in_h input, audio_in_stream_cb callback, void* user_data) { - return cpp_audio_in_set_stream_cb(input, callback, user_data); + return cpp_audio_in_set_stream_cb(input, callback, user_data); } int audio_in_unset_stream_cb(audio_in_h input) { - return cpp_audio_in_unset_stream_cb(input); + return cpp_audio_in_unset_stream_cb(input); } int audio_in_peek(audio_in_h input, const void **buffer, unsigned int *length) { - return cpp_audio_in_peek(input, buffer, length); + return cpp_audio_in_peek(input, buffer, length); } int audio_in_drop(audio_in_h input) { - return cpp_audio_in_drop(input); + return cpp_audio_in_drop(input); } int audio_in_set_state_changed_cb(audio_in_h input, audio_in_state_changed_cb callback, void* user_data) { - return cpp_audio_in_set_state_changed_cb(input, callback, user_data); + return cpp_audio_in_set_state_changed_cb(input, callback, user_data); } int audio_in_unset_state_changed_cb(audio_in_h input) { - return cpp_audio_in_unset_state_changed_cb(input); + return cpp_audio_in_unset_state_changed_cb(input); } /* Audio Out */ int audio_out_create(int sample_rate, audio_channel_e channel, audio_sample_type_e type, sound_type_e sound_type, audio_out_h* output) { - return cpp_audio_out_create(sample_rate, channel, type, sound_type, output); + return cpp_audio_out_create(sample_rate, channel, type, sound_type, output); } int audio_out_create_new(int sample_rate, audio_channel_e channel, audio_sample_type_e type, audio_out_h *output) { - return cpp_audio_out_create_new(sample_rate, channel, type, output); + return cpp_audio_out_create_new(sample_rate, channel, type, output); } int audio_out_destroy(audio_out_h output) { - return cpp_audio_out_destroy(output); + return cpp_audio_out_destroy(output); } int audio_out_set_stream_info(audio_out_h output, sound_stream_info_h stream_info) { - return cpp_audio_out_set_stream_info(output, stream_info); + return cpp_audio_out_set_stream_info(output, stream_info); } int audio_out_prepare(audio_out_h output) { - return cpp_audio_out_prepare(output); + return cpp_audio_out_prepare(output); } int audio_out_unprepare(audio_out_h output) { - return cpp_audio_out_unprepare(output); + return cpp_audio_out_unprepare(output); } int audio_out_pause(audio_out_h output) { - return cpp_audio_out_pause(output); + return cpp_audio_out_pause(output); } int audio_out_resume(audio_out_h output) { - return cpp_audio_out_resume(output); + return cpp_audio_out_resume(output); } int audio_out_drain(audio_out_h output) { - return cpp_audio_out_drain(output); + return cpp_audio_out_drain(output); } int audio_out_flush(audio_out_h output) { - return cpp_audio_out_flush(output); + return cpp_audio_out_flush(output); } int audio_out_write(audio_out_h output, void* buffer, unsigned int length) { - return cpp_audio_out_write(output, buffer, length); + return cpp_audio_out_write(output, buffer, length); } int audio_out_get_buffer_size(audio_out_h output, int *size) { - return cpp_audio_out_get_buffer_size(output, size); + return cpp_audio_out_get_buffer_size(output, size); } int audio_out_get_sample_rate(audio_out_h output, int *sample_rate) { - return cpp_audio_out_get_sample_rate(output, sample_rate); + return cpp_audio_out_get_sample_rate(output, sample_rate); } int audio_out_get_channel(audio_out_h output, audio_channel_e *channel) { - return cpp_audio_out_get_channel(output, channel); + return cpp_audio_out_get_channel(output, channel); } int audio_out_get_sample_type(audio_out_h output, audio_sample_type_e *type) { - return cpp_audio_out_get_sample_type(output, type); + return cpp_audio_out_get_sample_type(output, type); } int audio_out_get_sound_type(audio_out_h output, sound_type_e *type) { - return cpp_audio_out_get_sound_type(output, type); + return cpp_audio_out_get_sound_type(output, type); } int audio_out_set_interrupted_cb(audio_out_h output, audio_io_interrupted_cb callback, void *user_data) { - return cpp_audio_out_set_interrupted_cb(output, callback, user_data); + return cpp_audio_out_set_interrupted_cb(output, callback, user_data); } int audio_out_unset_interrupted_cb(audio_out_h output) { - return cpp_audio_out_unset_interrupted_cb(output); + return cpp_audio_out_unset_interrupted_cb(output); } int audio_out_ignore_session(audio_out_h output) { - return cpp_audio_out_ignore_session(output); + return cpp_audio_out_ignore_session(output); } int audio_out_set_stream_cb(audio_out_h output, audio_out_stream_cb callback, void* user_data) { - return cpp_audio_out_set_stream_cb(output, callback, user_data); + return cpp_audio_out_set_stream_cb(output, callback, user_data); } int audio_out_unset_stream_cb(audio_out_h output) { - return cpp_audio_out_unset_stream_cb(output); + return cpp_audio_out_unset_stream_cb(output); } int audio_out_set_state_changed_cb(audio_out_h output, audio_out_state_changed_cb callback, void* user_data) { - return cpp_audio_out_set_state_changed_cb(output, callback, user_data); + return cpp_audio_out_set_state_changed_cb(output, callback, user_data); } int audio_out_unset_state_changed_cb(audio_out_h output) { - return cpp_audio_out_unset_state_changed_cb(output); + return cpp_audio_out_unset_state_changed_cb(output); } diff --git a/test/audio_io_test.c b/test/audio_io_test.c index d3ca4b7..edf6a8c 100644 --- a/test/audio_io_test.c +++ b/test/audio_io_test.c @@ -53,11 +53,9 @@ void play_file(char *file, int length, int ch) } printf("start to play [%s][%d][%d]\n", file, length, ch); - //audio_out_create(44100, ch_table[ch] ,AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_MEDIA, &output); audio_out_create_new(44100, ch_table[ch], AUDIO_SAMPLE_TYPE_S16_LE, &output); - if (fread(buf, 1, length, fp) != length) { + if (fread(buf, 1, length, fp) != length) printf("error!!!!\n"); - } audio_out_prepare(output); audio_out_write(output, buf, length); @@ -80,28 +78,25 @@ void play_file_sample(char *file, int frequency, int ch, int type) int buffer_size = 0; char *buf = NULL; - if (ch < 0 || ch > 2) { + if (ch < 0 || ch > 2) ch = 0; - } FILE *fp = fopen(file, "r"); if (fp == NULL) { printf("open failed\n"); return; } - /*Get the size */ + /* Get the size */ fseek(fp, 0, SEEK_END); file_size = ftell(fp); fseek(fp, 0, SEEK_SET); printf("start to play [%s] of size [%d] with [%d][%d][%d]\n", file, file_size, frequency, ch, type); - if (type) { - //audio_out_create(frequency, ch_table[ch] ,AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_MEDIA, &output); + if (type) audio_out_create_new(frequency, ch_table[ch], AUDIO_SAMPLE_TYPE_S16_LE, &output); - } else { - //audio_out_create(frequency, ch_table[ch] ,AUDIO_SAMPLE_TYPE_U8, SOUND_TYPE_MEDIA, &output); + else audio_out_create_new(frequency, ch_table[ch], AUDIO_SAMPLE_TYPE_U8, &output); - } + audio_out_prepare(output); audio_out_get_buffer_size(output, &buffer_size); @@ -113,7 +108,6 @@ void play_file_sample(char *file, int frequency, int ch, int type) fclose(fp); return; } - //audio_out_prepare(output); while (file_size > 0) { read_bytes = fread(buf, 1, buffer_size, fp); @@ -244,7 +238,6 @@ int audio_io_loopback_test() printf("audio_in_create_ex failed. \n"); return 0; } - //ret = audio_out_create(16000, AUDIO_CHANNEL_MONO , AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_CALL, &output); ret = audio_out_create_new(16000, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &output); if (ret != AUDIO_IO_ERROR_NONE) { printf("audio_out_create failed. \n"); @@ -283,11 +276,10 @@ int audio_io_loopback_test() ret = audio_in_read(input, (void *)buffer, size); if (ret > AUDIO_IO_ERROR_NONE) { ret = audio_out_write(output, buffer, size); - if (ret > AUDIO_IO_ERROR_NONE) { + if (ret > AUDIO_IO_ERROR_NONE) printf("audio read/write success. buffer(%p), size(%d)\n", buffer, size); - } else { + else printf("audio read success, write failed. buffer(%p), size(%d)\n", buffer, size); - } } else printf("audio read/write failed. buffer(%p), size(%d)\n", buffer, size); } @@ -321,13 +313,10 @@ static void _audio_io_stream_read_cb(audio_in_h handle, size_t nbytes, void *use const void *buffer = NULL; unsigned int len = (unsigned int)nbytes; - //printf("_audio_io_stream_read_cb : handle=%p, nbytes=%d, user_data=%p\n", handle, nbytes, user_data); - if (len > 0) { audio_in_peek(handle, &buffer, &len); - if (fp_w) { + if (fp_w) fwrite(buffer, sizeof(char), len, fp_w); - } audio_in_drop(handle); } } @@ -338,8 +327,6 @@ static void _audio_io_stream_write_cb(audio_out_h handle, size_t nbytes, void *u int ret = 0; int i = 0; - //printf("_audio_io_stream_write_cb : handle=%p, nbytes=%d, user_data=%p\n", handle, nbytes, user_data); - if (nbytes > 0) { buffer = (short *)malloc(nbytes); if (buffer == NULL) { @@ -360,9 +347,6 @@ static void _audio_io_stream_write_cb(audio_out_h handle, size_t nbytes, void *u } ret = audio_out_write(handle, buffer, nbytes); - if (ret > AUDIO_IO_ERROR_NONE) { - //printf("audio write success. buffer(%p), nbytes(%d)\n", buffer, nbytes); - } free(buffer); } @@ -409,7 +393,6 @@ int _convert_cmd_and_run(char cmd, int mode) case 'd': if (mode & 0x01) ret = audio_out_drain(output); - //if (mode & 0x02) ret = audio_in_drain(input); break; case 'f': if (mode & 0x01) @@ -419,9 +402,8 @@ int _convert_cmd_and_run(char cmd, int mode) break; case 'i': ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, focus_callback, NULL, &g_stream_info_write_h); - if (ret) { + if (ret) printf("fail to sound_manager_create_stream_information(), ret(0x%x)\n", ret); - } break; case 'q': /* quit */ ret = 1; @@ -500,7 +482,6 @@ int audio_io_async_test(int mode) getchar(); printf("audio_out_create\n"); - //ret = audio_out_create(44100, AUDIO_CHANNEL_STEREO , AUDIO_SAMPLE_TYPE_S16_LE, SOUND_TYPE_MEDIA, &output); ret = audio_out_create_new(44100, AUDIO_CHANNEL_STEREO, AUDIO_SAMPLE_TYPE_S16_LE, &output); if (ret != AUDIO_IO_ERROR_NONE) { printf("audio_out_create failed. \n"); @@ -537,10 +518,9 @@ int audio_io_async_test(int mode) goto EXIT; } - //generate wave data - for (i = 0; i < TABLE_SIZE; i++) { + /* generate wave data */ + for (i = 0; i < TABLE_SIZE; i++) test_wav.sine[i] = 0.9 * (float)sin(((double)i / (double)TABLE_SIZE) * M_PI * 2.); - } test_wav.left_channel = test_wav.right_channel = 0; } @@ -591,14 +571,6 @@ int audio_io_async_test(int mode) printf(" - result code : %d\n", cmd_ret); } while (cmd != 'q'); - //printf ("loop start\n"); - //for (i=0; i<10; i++) { - // printf ("-------- %d -------\n",i); - // usleep (1000000); - //} - - //getchar(); - EXIT: if (read_mode) { if (input) { @@ -627,7 +599,6 @@ EXIT: g_stream_info_read_h = NULL; } } - //getchar(); if (write_mode) { if (output) { -- 2.7.4