From 1d93cf72472d684867b8ae7b7e4eb10ca6988f8d Mon Sep 17 00:00:00 2001 From: Jaechul Lee Date: Thu, 24 Mar 2022 16:30:43 +0900 Subject: [PATCH] Revert "Adds aec testcase" This reverts commit 1dc3848eb79d608cc8abc3d71d99f06dec2d443f. Change-Id: Idc034ad89c4d1cab7fd5a9324e1b3257012d99c4 Signed-off-by: Jaechul Lee --- CMakeLists.txt | 1 - packaging/capi-media-audio-io.spec | 1 - test/CMakeLists.txt | 1 - test/audio_io_test_ec.c | 275 ------------------------------------- 4 files changed, 278 deletions(-) delete mode 100644 test/audio_io_test_ec.c diff --git a/CMakeLists.txt b/CMakeLists.txt index b83d867..1c72833 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,6 @@ ENDIF(TIZEN_FEATURE_DISABLE_SESSION_BACKWARD_COMP) IF(TIZEN_FEATURE_PRODUCT_TV) ADD_DEFINITIONS("-DDISABLE_MOBILE_BACK_COMP") - ADD_DEFINITIONS("-DTIZEN_FEATURE_TV_PROD") ENDIF(TIZEN_FEATURE_PRODUCT_TV) SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") diff --git a/packaging/capi-media-audio-io.spec b/packaging/capi-media-audio-io.spec index 2103c6c..6b06cdf 100644 --- a/packaging/capi-media-audio-io.spec +++ b/packaging/capi-media-audio-io.spec @@ -94,7 +94,6 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name} %files tool %manifest %{name}.manifest %{_prefix}/bin/audio_io_test -%{_prefix}/bin/audio_io_test_ec %if 0%{?gcov:1} %files gcov diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e225884..9505dff 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,4 +17,3 @@ FOREACH(src ${sources}) ENDFOREACH() INSTALL(TARGETS audio_io_test DESTINATION bin) -INSTALL(TARGETS audio_io_test_ec DESTINATION bin) diff --git a/test/audio_io_test_ec.c b/test/audio_io_test_ec.c deleted file mode 100644 index 1559cb3..0000000 --- a/test/audio_io_test_ec.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifndef TIZEN_FEATURE_TV_PROD -static double _get_rand_double_range(double min, double max) -{ - double ret; - int r; - - r = rand(); - ret = (max / RAND_MAX) * r * (r & 0x1 ? 1 : -1); - - return ret; -} - -static void _white_noise_stream_write_cb(audio_out_h handle, size_t nbytes, void *user_data) -{ - int i; - short *ptr; - char *buffer; - double amp = 0.3 * 32767.0; - - buffer = (char *)malloc(nbytes); - if (!buffer) - return; - - ptr = (short *)buffer; - for (i = 0; i < nbytes; i += 2, ptr++) - ptr[0] = (short)(amp * _get_rand_double_range(-1.0, 1.0)); - - audio_out_write(handle, buffer, nbytes); - - free(buffer); -} - -int play_white_noise_async(audio_out_h *output) -{ - audio_out_h _output = NULL; - int ret; - - srand(time(NULL)); - - ret = audio_out_create_new(48000, AUDIO_CHANNEL_STEREO, AUDIO_SAMPLE_TYPE_S16_LE, &_output); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to create audio out\n"); - return -1; - } - - ret = audio_out_set_stream_cb(_output, _white_noise_stream_write_cb, NULL); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to set stream callback\n"); - goto fail; - } - - ret = audio_out_prepare(_output); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to prepare \n"); - goto fail; - } - - *output = _output; - - return 0; - -fail: - audio_out_destroy(_output); - - return -1; -} - -int stop_white_noise_async(audio_out_h output) -{ - int ret; - - ret = audio_out_unprepare(output); - if (ret != AUDIO_IO_ERROR_NONE) - printf("failed to prepare\n"); - - ret = audio_out_destroy(output); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to destroy output\n"); - return -1; - } - - return 0; -} - -int capture_sound(char **buffer, int *length, int sec) -{ - int ret; - char *_buffer = NULL; - audio_in_h input = NULL; - int _length = 16000 * 1 * 2 * sec; // 16Khz, mono, S16LE - - if (!buffer) { - printf("buffer is null\n"); - return -1; - } - - ret = audio_in_create(16000, AUDIO_CHANNEL_MONO, AUDIO_SAMPLE_TYPE_S16_LE, &input); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to create audio_input\n"); - return -1; - } - - ret = audio_in_prepare(input); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to prepare %x0x\n", ret); - goto fail; - } - - _buffer = malloc(_length); - if (!_buffer) { - printf("_buffer is null\n"); - goto fail; - } - - ret = audio_in_read(input, _buffer, _length); - if (ret <= 0) { - printf("failed to read ret(0x%x), length(%d)\n", ret, _length); - goto fail; - } - ret = audio_in_unprepare(input); - if (ret != AUDIO_IO_ERROR_NONE) { - printf("failed to unprepare 0x%x", ret); - goto fail; - } - - *buffer = _buffer; - *length = _length; - - return 0; - -fail: - if (input) - audio_in_destroy(input); - if (buffer) - free(buffer); - - return -1; -} - -int enable_echo_cancellation(bool enable) -{ - int ret; - - if (enable) - ret = sound_manager_start_aec(); - else - ret = sound_manager_stop_aec(); - - if (ret != 0) { - printf("failed to %s echo cancellation. ret(0x%x)\n", - enable ? "start" : "stop", ret); - return -1; - } - - return 0; -} - -int test_echo_cancellation(char **buffer, bool enable_ec, bool enable_ref, int time_sec) -{ - audio_out_h output = NULL; - char *_buffer = NULL; - int length; - - if (enable_ec && enable_echo_cancellation(true)) - goto exit; - - if (enable_ref && play_white_noise_async(&output)) - goto exit; - - printf("Say something for %d seconds.. enable_ec(%s) enable_ref(%s)\n", - time_sec, - enable_ec ? "on" : "off", - enable_ref? "on" : "off"); - - if (capture_sound(&_buffer, &length, time_sec)) - goto exit; - - if (output && stop_white_noise_async(output)) - goto exit; - - output = NULL; - - if (enable_ec && enable_echo_cancellation(false)) - goto exit; - - *buffer = _buffer; - - return length; - -exit: - if (output) - stop_white_noise_async(output); - - if (enable_ec) - enable_echo_cancellation(false); - - if (_buffer) - free(_buffer); - - return -1; -} - -int dump_to_file(const char *filename, char *buffer, int length) -{ - int fd, ret; - - fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0644); - if (fd < 0) { - printf("failed to open file\n"); - return -1; - } - - ret = write(fd, buffer, length); - if (ret < 0) - printf("failed to write\n"); - - close(fd); - - return 0; -} -#endif - -int main(int argc, char **argv) -{ -#ifndef TIZEN_FEATURE_TV_PROD - bool enable_ec; - bool enable_ref; - int time_sec; - char *filename; - - char *buffer; - int size; - - if (argc != 5) { - printf("- Usages :\n"); - printf("- # audio_io_test_ec [filename] [on/off 0:1] [noise 0:1] [seconds]\n"); - return -1; - } - - filename = argv[1]; - enable_ec = !!atoi(argv[2]); - enable_ref = !!atoi(argv[3]); - time_sec = atoi(argv[4]); - - size = test_echo_cancellation(&buffer, enable_ec, enable_ref, time_sec); - if (size <= 0) { - printf("failed to test aec\n"); - return -1; - } - - if (dump_to_file(filename, buffer, size)) - printf("failed to save file %s\n", filename); - - if (buffer) - free(buffer); -#else - printf("not supported yet\n"); -#endif - - return 0; -} - -- 2.7.4