Change TYPE to METHOD 24/294324/3
authorJaechul Lee <jcsing.lee@samsung.com>
Fri, 16 Jun 2023 05:40:59 +0000 (14:40 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Tue, 20 Jun 2023 04:51:19 +0000 (13:51 +0900)
* changed AUDIO_EFFECT_TYPE_* to AUDIO_EFFECT_METHOD_*
* changed audio_effect_type_e to audio_effect_method_e

[Version] 0.0.2
[Issue Type] Update

Change-Id: Ie9ebd685d92c8b18cc14fda251da0de36f02ee38
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
16 files changed:
include/audio_effect.h
include/audio_effect_interface.h
packaging/libaudio-effect.spec
src/audio_effect.c
src/audio_effect_interface.c
src/plugin_aec_refcopy.c
src/plugin_aec_speex.c
src/plugin_aec_webrtc.cpp
src/plugin_agc_speex.c
src/plugin_amplify.c
src/plugin_ns_rnnoise.c
test/aec_refcopy_test.c
test/aec_speex_test.c
test/aec_webrtc_test.c
test/amplify_test.c
test/ns_rnnoise_test.c

index b7836d10c4fcf4167fb0dea96d21033fb805e3f7..d4ea45a43a07beb5f63884e0b3ae6cad35455084 100644 (file)
 typedef struct audio_effect_interface audio_effect_interface_s;
 typedef enum {
        /* Acoustic Echo Cancellation */
-       AUDIO_EFFECT_TYPE_AEC_SPEEX, /* aec from speexdsp */
-       AUDIO_EFFECT_TYPE_AEC_WEBRTC, /* aec from webrtc-audio-processing */
-       AUDIO_EFFECT_TYPE_AEC_REFCOPY, /* synthesis reference source into recording source */
+       AUDIO_EFFECT_METHOD_AEC_SPEEX, /* aec from speexdsp */
+       AUDIO_EFFECT_METHOD_AEC_WEBRTC, /* aec from webrtc-audio-processing */
+       AUDIO_EFFECT_METHOD_AEC_REFCOPY, /* synthesis reference source into recording source */
 
        /* Noise Suppression */
-       AUDIO_EFFECT_TYPE_NS_PSE, /* SAIC NS solution */
-       AUDIO_EFFECT_TYPE_NS_RNNOISE, /* RNNoise */
+       AUDIO_EFFECT_METHOD_NS_PSE, /* SAIC NS solution */
+       AUDIO_EFFECT_METHOD_NS_RNNOISE, /* RNNoise */
 
        /* Template */
-       AUDIO_EFFECT_TYPE_AMPLIFY,
+       AUDIO_EFFECT_METHOD_AMPLIFY,
 
        /* Experiment */
-       AUDIO_EFFECT_TYPE_AGC_SPEEX,
-       AUDIO_EFFECT_TYPE_MAX,
-} audio_effect_type_e;
+       AUDIO_EFFECT_METHOD_AGC_SPEEX,
+       AUDIO_EFFECT_METHOD_MAX,
+} audio_effect_method_e;
 
 typedef enum {
        AUDIO_EFFECT_FORMAT_S8,
@@ -53,7 +53,7 @@ typedef struct audio_effect {
        size_t request_framesize;
 } audio_effect_s;
 
-audio_effect_s *audio_effect_create(audio_effect_type_e type, int rate,
+audio_effect_s *audio_effect_create(audio_effect_method_e method, int rate,
                                        int channels, audio_effect_format_e format,
                                        size_t frames);
 int audio_effect_process(audio_effect_s *ae, void *in, void *out);
index b56e257aabb8a552fed21aa32f5285b1199ada56..bc16d7a2944ee6abb758ee1390b38d50ad62f093 100644 (file)
@@ -25,7 +25,7 @@ typedef int (*dl_process_reference_t)(void *, char *, char *, char *);
 typedef void (*dl_destroy_t)(void *);
 
 typedef struct audio_effect_interface {
-       audio_effect_type_e type;
+       audio_effect_method_e method;
        dl_create_t create;
        dl_process_t process;
        dl_process_reference_t process_reference;
@@ -48,7 +48,7 @@ typedef struct audio_effect_plugin_info {
        } constraint;
 } audio_effect_plugin_info_s;
 
-audio_effect_interface_s *audio_effect_interface_new(audio_effect_type_e type,
+audio_effect_interface_s *audio_effect_interface_new(audio_effect_method_e method,
                                                        int rate, int channels,
                                                        audio_effect_format_e format,
                                                        size_t frames);
index 655932c6c5a04cbd9bf3d363e0a0c1ef1ee0eefc..193618c55b0bccdbb0bf5c21c2a9352c355fadde 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libaudio-effect
 Summary:    audio effect library
-Version:    0.0.1
+Version:    0.0.2
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 992bd46d6f5a04f28d42edb2133f33f6d2a8d61c..a7baf485e50c5b824a2f8bcabee2311214b56d24 100644 (file)
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
 
-audio_effect_s *audio_effect_create(audio_effect_type_e type, int rate, int channels,
+audio_effect_s *audio_effect_create(audio_effect_method_e method, int rate, int channels,
                                        audio_effect_format_e format, size_t frames)
 {
        audio_effect_s *ae;
        audio_effect_interface_s *intf;
 
-       intf = audio_effect_interface_new(type, rate, channels, format, frames);
+       intf = audio_effect_interface_new(method, rate, channels, format, frames);
        if (!intf) {
                LOG_ERROR("failed to create interface");
                return NULL;
index 49f66bc61885551793fe23ad0dcaf0c2bd5c1ab6..be399d513c8009205c179c66316e2fa3cd604ddf 100644 (file)
 #include <audio_effect_log.h>
 
 static const char *effect_path_list[] = {
-       [AUDIO_EFFECT_TYPE_AEC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-aec-speex.so",
-       [AUDIO_EFFECT_TYPE_AEC_WEBRTC] = DL_PLUGIN_PATH "libaudio-effect-aec-webrtc.so",
-       [AUDIO_EFFECT_TYPE_AEC_REFCOPY] = DL_PLUGIN_PATH "libaudio-effect-aec-refcopy.so",
-       [AUDIO_EFFECT_TYPE_NS_PSE] = DL_PLUGIN_PATH "libaudio-effect-ns-pse.so",
-       [AUDIO_EFFECT_TYPE_NS_RNNOISE] = DL_PLUGIN_PATH "libaudio-effect-ns-rnnoise.so",
-       [AUDIO_EFFECT_TYPE_AMPLIFY] = DL_PLUGIN_PATH "libaudio-effect-amplify.so",
-       [AUDIO_EFFECT_TYPE_AGC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-agc-speex.so",
+       [AUDIO_EFFECT_METHOD_AEC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-aec-speex.so",
+       [AUDIO_EFFECT_METHOD_AEC_WEBRTC] = DL_PLUGIN_PATH "libaudio-effect-aec-webrtc.so",
+       [AUDIO_EFFECT_METHOD_AEC_REFCOPY] = DL_PLUGIN_PATH "libaudio-effect-aec-refcopy.so",
+       [AUDIO_EFFECT_METHOD_NS_PSE] = DL_PLUGIN_PATH "libaudio-effect-ns-pse.so",
+       [AUDIO_EFFECT_METHOD_NS_RNNOISE] = DL_PLUGIN_PATH "libaudio-effect-ns-rnnoise.so",
+       [AUDIO_EFFECT_METHOD_AMPLIFY] = DL_PLUGIN_PATH "libaudio-effect-amplify.so",
+       [AUDIO_EFFECT_METHOD_AGC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-agc-speex.so",
 };
 
 static struct plugin_list {
        void *handle;
        int refcnt;
        audio_effect_plugin_info_s *plugin_info;
-} plugin_list[AUDIO_EFFECT_TYPE_MAX];
+} plugin_list[AUDIO_EFFECT_METHOD_MAX];
 
-audio_effect_interface_s *audio_effect_interface_new(audio_effect_type_e type,
+audio_effect_interface_s *audio_effect_interface_new(audio_effect_method_e method,
                                                        int rate, int channels,
                                                        audio_effect_format_e format,
                                                        size_t frames)
@@ -53,18 +53,18 @@ audio_effect_interface_s *audio_effect_interface_new(audio_effect_type_e type,
        audio_effect_plugin_info_s *plugin_info;
        void *handle = NULL;
 
-       assert(type < AUDIO_EFFECT_TYPE_MAX);
+       assert(method < AUDIO_EFFECT_METHOD_MAX);
 
-       if (!plugin_list[type].plugin_info && plugin_list[type].refcnt == 0) {
-               handle = dlopen(effect_path_list[type], RTLD_LAZY);
+       if (!plugin_list[method].plugin_info && plugin_list[method].refcnt == 0) {
+               handle = dlopen(effect_path_list[method], RTLD_LAZY);
                if (!handle) {
-                       LOG_INFO("Failed to open handle. path(%s)", effect_path_list[type]);
+                       LOG_INFO("Failed to open handle. path(%s)", effect_path_list[method]);
                        return NULL;
                }
-               LOG_INFO("loaded module %s", effect_path_list[type]);
+               LOG_INFO("loaded module %s", effect_path_list[method]);
        }
 
-       plugin_info = plugin_list[type].plugin_info;
+       plugin_info = plugin_list[method].plugin_info;
        assert(plugin_info);
 
        /* check constraint */
@@ -92,9 +92,9 @@ audio_effect_interface_s *audio_effect_interface_new(audio_effect_type_e type,
        if (plugin_info->constraint.frames != 0 && plugin_info->constraint.frames != frames)
                LOG_WARN("This plugin uses fixed frames size. Check frames size with audio_effect_get_process_framesize api");
 
-       plugin_list[type].handle = handle;
+       plugin_list[method].handle = handle;
        /* TODO handle lock */
-       plugin_list[type].refcnt += 1;
+       plugin_list[method].refcnt += 1;
 
        return &plugin_info->interface;
 
@@ -109,35 +109,35 @@ void audio_effect_interface_free(audio_effect_interface_s *intf)
 {
        assert(intf);
 
-       plugin_list[intf->type].refcnt -= 1;
+       plugin_list[intf->method].refcnt -= 1;
 
-       if (plugin_list[intf->type].refcnt == 0) {
-               LOG_INFO("unloaded module %s", effect_path_list[intf->type]);
-               dlclose(plugin_list[intf->type].handle);
+       if (plugin_list[intf->method].refcnt == 0) {
+               LOG_INFO("unloaded module %s", effect_path_list[intf->method]);
+               dlclose(plugin_list[intf->method].handle);
        }
 }
 
 void audio_effect_register_module(audio_effect_plugin_info_s *plugin_info)
 {
-       audio_effect_type_e type;
+       audio_effect_method_e method;
 
        assert(plugin_info);
 
        /* TODO: Currently it's array */
-       type = plugin_info->interface.type;
+       method = plugin_info->interface.method;
 
-       plugin_list[type].plugin_info = plugin_info;
+       plugin_list[method].plugin_info = plugin_info;
 }
 
 void audio_effect_unregister_module(audio_effect_plugin_info_s *plugin_info)
 {
-       audio_effect_type_e type;
+       audio_effect_method_e method;
 
        assert(plugin_info);
 
-       type = plugin_info->interface.type;
+       method = plugin_info->interface.method;
 
-       plugin_list[type].handle = NULL;
-       plugin_list[type].refcnt = 0;
-       plugin_list[type].plugin_info = NULL;
+       plugin_list[method].handle = NULL;
+       plugin_list[method].refcnt = 0;
+       plugin_list[method].plugin_info = NULL;
 }
index 98c86176bd864571a706cfdab8e2ed9811e83033..40bd380d91c7bce8b109b14507f553812b47dc6f 100644 (file)
@@ -83,7 +83,7 @@ void reference_copy_destroy(void *priv)
 static audio_effect_plugin_info_s reference_copy = {
        .name = "reference_copy",
        .interface = {
-               .type = AUDIO_EFFECT_TYPE_AEC_REFCOPY,
+               .method = AUDIO_EFFECT_METHOD_AEC_REFCOPY,
                .create = reference_copy_create,
                .process_reference = reference_copy_process_reference,
                .destroy = reference_copy_destroy,
index a305c42f010b13963f8ec69e9ef5ad14fb4d9cba..6ba740dd0a2c36de5a3883339b1d80791d2a4e5a 100644 (file)
@@ -129,7 +129,7 @@ void speex_aec_destroy(void *priv)
 static audio_effect_plugin_info_s speex_aec = {
        .name = "speex_aec",
        .interface = {
-               .type = AUDIO_EFFECT_TYPE_AEC_SPEEX,
+               .method = AUDIO_EFFECT_METHOD_AEC_SPEEX,
                .create = speex_aec_create,
                .process_reference = speex_aec_process_reference,
                .destroy = speex_aec_destroy,
index 1545542a3a1036fe4acbb3b21238d68f3540cf3c..90a3f4bd3164a2ba8222baf7e49ba46357d5bb52 100644 (file)
@@ -239,7 +239,7 @@ static void allocate_stream_buffer(struct userdata *u, size_t frames, int channe
 static audio_effect_plugin_info_s webrtc_aec = {
        .name = "webrtc_aec",
        .interface = {
-               .type = AUDIO_EFFECT_TYPE_AEC_WEBRTC,
+               .method = AUDIO_EFFECT_METHOD_AEC_WEBRTC,
                .create = webrtc_aec_create,
                .process_reference = webrtc_aec_process_reference,
                .destroy = webrtc_aec_destroy,
index bc565ac11509cd735204a94e82a5d6ad31a786b6..566c3f70089945229e3fc80247cf4e4f35b08e54 100644 (file)
@@ -97,7 +97,7 @@ void speex_agc_destroy(void *priv)
 static audio_effect_plugin_info_s speex_agc = {
        .name = "speex-agc",
        .interface = {
-               .type = AUDIO_EFFECT_TYPE_AGC_SPEEX,
+               .method = AUDIO_EFFECT_METHOD_AGC_SPEEX,
                .create = speex_agc_create,
                .process = speex_agc_process,
                .destroy = speex_agc_destroy,
index 3f782b0c92caf9b2811eb9722bdb8f4ea9879da6..4d304b2d312d2a04675d3e0b3c6343c69ac26d7b 100644 (file)
@@ -73,7 +73,7 @@ void amplify_destroy(void *priv)
 static audio_effect_plugin_info_s amplify = {
        .name = "amplify",
        .interface = {
-               .type = AUDIO_EFFECT_TYPE_AMPLIFY,
+               .method = AUDIO_EFFECT_METHOD_AMPLIFY,
                .create = amplify_create,
                .process = amplify_process,
                .destroy = amplify_destroy,
index 232dbac3c585964e69d47276861ad39cf0f2e213..b510076a227e272fc0e299e4343b2bbbd3275689 100644 (file)
@@ -97,7 +97,7 @@ void noise_suppression_rnnoise_destroy(void *priv)
 static audio_effect_plugin_info_s noise_suppression_rnnoise = {
        .name = "noise-suppression-rnnoise",
        .interface = {
-               .type = AUDIO_EFFECT_TYPE_NS_RNNOISE,
+               .method = AUDIO_EFFECT_METHOD_NS_RNNOISE,
                .create = noise_suppression_rnnoise_create,
                .process = noise_suppression_rnnoise_process,
                .destroy = noise_suppression_rnnoise_destroy,
index 731deaf87ec6e979bcccce0ebfbda1ccb45fcb34..72457e7420089bdbd41099a6c9cc6bba84ab4e04 100644 (file)
@@ -59,7 +59,7 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_TYPE_AEC_REFCOPY, 16000, 5, AUDIO_EFFECT_FORMAT_S16, process_framesize);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_REFCOPY, 16000, 5, AUDIO_EFFECT_FORMAT_S16, process_framesize);
        process_framesize = audio_effect_get_process_framesize(ae);
 
        printf("process_framesize (%zu)\n", process_framesize);
index 67d8ed02970ee36daddc7de4031e689895e259f3..8a98acba59a1805a0f9893a486c621b8ba5f00c0 100644 (file)
@@ -58,7 +58,7 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_TYPE_AEC_SPEEX, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_SPEEX, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
        process_framesize = audio_effect_get_process_framesize(ae);
 
        printf("process_framesize (%zu)\n", process_framesize);
index 7b8f6f1e217ea2070b3804ce91ef53b81e2223a4..858f6d0d83d5118145950a099d2cbf3383c61194 100644 (file)
@@ -58,7 +58,7 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_TYPE_AEC_WEBRTC, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_WEBRTC, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize);
        process_framesize = audio_effect_get_process_framesize(ae);
 
        printf("process_framesize (%zu)\n", process_framesize);
index 1dd7e9abf2904e20f21aa2b6938f4058a20ff3b6..74e4b81ec04224bd5520896eb552091e56690c81 100644 (file)
@@ -31,7 +31,7 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_TYPE_AMPLIFY, 16000, 1, AUDIO_EFFECT_FORMAT_S16, FRAME_SIZE);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AMPLIFY, 16000, 1, AUDIO_EFFECT_FORMAT_S16, FRAME_SIZE);
        while (!feof(fin)) {
                printf("#%d frame. \n", i++);
                ret = fread(in, FRAME_SIZE*sizeof(short), 1, fin);
index 8ce98d2958889b4d667c97f9d83e3518bcd952a0..06cea22deaa4b39647f043bed5ec675ad6858dc8 100644 (file)
@@ -32,7 +32,7 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_TYPE_NS_RNNOISE, 48000, 1, AUDIO_EFFECT_FORMAT_S16, framesize);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_NS_RNNOISE, 48000, 1, AUDIO_EFFECT_FORMAT_S16, framesize);
        assert(ae);
 
        framesize = audio_effect_get_process_framesize(ae);