Support multi-thread 67/315767/4 accepted/tizen_9.0_unified accepted/tizen_unified accepted/tizen_unified_dev accepted/tizen_unified_toolchain accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen tizen_9.0 accepted/tizen/9.0/unified/20241030.232338 accepted/tizen/unified/20240903.110731 accepted/tizen/unified/dev/20240910.111500 accepted/tizen/unified/toolchain/20241004.101329 accepted/tizen/unified/x/20240904.025227 accepted/tizen/unified/x/asan/20241013.235637 tizen_9.0_m2_release
authorJaechul Lee <jcsing.lee@samsung.com>
Wed, 7 Aug 2024 08:31:39 +0000 (17:31 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Tue, 13 Aug 2024 08:25:21 +0000 (17:25 +0900)
 * refactoring
 * remove global variables

[Version] 0.0.26
[Issue Type] Update

Change-Id: Ie8ef599ae970934e8de04121fd887316463f9e78
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
25 files changed:
include/audio_effect.h
include/audio_effect_interface.h
include/audio_effect_log.h
include/audio_effect_util.h
packaging/libaudio-effect.spec
src/audio_effect.c
src/audio_effect_interface.c
src/audio_effect_util.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
src/plugin_ns_srid.c
src/plugin_refcopy.c
test/aec_speex_test.c
test/aec_webrtc_test.c
test/agc_speex_test.c
test/amplify_test.c
test/integration_test.c
test/meson.build
test/multi_thread.cpp [new file with mode: 0644]
test/ns_rnnoise_test.c
test/ns_srid_test.c
test/refcopy_test.c

index b89c130b389717abbc62db2a5a747931f62f4186..321b01e7634f0eb98f8f658b7d070b830d810a1c 100644 (file)
@@ -21,8 +21,6 @@
 extern "C" {
 #endif
 
-#include <stddef.h>
-
 typedef struct audio_effect_interface audio_effect_interface_s;
 typedef enum {
        AUDIO_EFFECT_METHOD_REFCOPY,    /* Synthesis the reference source into the recording source */
@@ -48,18 +46,21 @@ typedef enum {
 } audio_effect_format_e;
 
 typedef struct audio_effect {
+       void *dl_handle;
        void *priv;
        audio_effect_interface_s *intf;
-       size_t request_framesize;
+       audio_effect_method_e method;
 } audio_effect_s;
 
-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);
-int audio_effect_process_reference(audio_effect_s *ae, void *in, void *ref, void *out);
+audio_effect_s *audio_effect_create(audio_effect_method_e method,
+                                       int rate,
+                                       int channels,
+                                       audio_effect_format_e format,
+                                       size_t request_frames,
+                                       size_t *adjust_frames);
+int audio_effect_process(audio_effect_s *ae, const void *in, void *out);
+int audio_effect_process_reference(audio_effect_s *ae, const void *in, const void *ref, void *out);
 void audio_effect_destroy(audio_effect_s *ae);
-size_t audio_effect_get_process_framesize(audio_effect_s *ae);
 
 #ifdef __cplusplus
 }
index 826a40f0a4e2a1f01713c63f6130f419a685543f..7afbc3ee0c0947ef743e1d742c14c18bd9f42f7c 100644 (file)
@@ -24,8 +24,8 @@ extern "C" {
 #include "audio_effect.h"
 
 typedef void *(*dl_create_t)(int, int, audio_effect_format_e, size_t);
-typedef int (*dl_process_t)(void *, char *, char *);
-typedef int (*dl_process_reference_t)(void *, char *, char *, char *);
+typedef int (*dl_process_t)(void *, const void *, void *);
+typedef int (*dl_process_reference_t)(void *, const void *, const void *, void *);
 typedef void (*dl_destroy_t)(void *);
 
 typedef struct audio_effect_interface {
@@ -41,7 +41,6 @@ typedef struct audio_effect_plugin_info {
        const char *name;
        audio_effect_interface_s interface;
        struct {
-               size_t frames;
                size_t frames_msec;
                int min_rate;
                int max_rate;
@@ -52,11 +51,12 @@ typedef struct audio_effect_plugin_info {
        } constraint;
 } audio_effect_plugin_info_s;
 
-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);
-void audio_effect_interface_free(audio_effect_interface_s *intf);
+audio_effect_interface_s *audio_effect_interface_get(void *dl_handle,
+                                               int rate,
+                                               int channels,
+                                               audio_effect_format_e format,
+                                               size_t request_frames,
+                                               size_t *adjust_frames);
 
 #define PLUGIN_ENTRY_POINT __audio_effect_plugin_entry_point__
 #define PLUGIN_ENTRY_POINT_DEFINE_FUNC(s) \
@@ -66,6 +66,8 @@ void audio_effect_interface_free(audio_effect_interface_s *intf);
 #define PLUGIN_ENTRY_POINT_CONVERT(X) PLUGIN_CONVERT_TO_STRING(X)
 #define PLUGIN_ENTRY_POINT_STRING PLUGIN_ENTRY_POINT_CONVERT(PLUGIN_ENTRY_POINT)
 
+typedef audio_effect_plugin_info_s *(*entry_point_t)(void);
+
 #ifdef __cplusplus
 }
 #endif
index 3936f10dc7c898b9f48647014d9191e6d8931426..20dcbbb3b066bdf286b1c9da1e1fa5a60076a9e6 100644 (file)
@@ -34,11 +34,11 @@ extern "C" {
 #define LOG_VERBOSE(...)       SLOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
 #else
 #include <stdio.h>
-#define LOG_ERROR(...)         { printf(__VA_ARGS__); printf("\n"); }
-#define LOG_WARN(...)          { printf(__VA_ARGS__); printf("\n"); }
-#define LOG_INFO(...)          { printf(__VA_ARGS__); printf("\n"); }
-#define LOG_DEBUG(...)         { printf(__VA_ARGS__); printf("\n"); }
-#define LOG_VERBOSE(...)       { printf(__VA_ARGS__); printf("\n"); }
+#define LOG_ERROR(...)         { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
+#define LOG_WARN(...)          { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
+#define LOG_INFO(...)          { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
+#define LOG_DEBUG(...)         { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
+#define LOG_VERBOSE(...)       { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
 #endif
 
 #ifdef __cplusplus
index cf0f0676c3de3baa65d232f3492c1c70aef8d02a..402ac87a8d3e71450e88a4e070fff46b501bc8aa 100644 (file)
@@ -25,6 +25,7 @@ extern "C" {
 
 size_t audio_effect_util_get_sample_size(audio_effect_format_e format);
 size_t audio_effect_util_get_frame_size(audio_effect_format_e format, int channels);
+size_t audio_effect_util_frame_to_msec(size_t frame, int rate);
 size_t audio_effect_util_msec_to_frame(size_t msec, int rate);
 size_t audio_effect_util_msec_to_bytes(size_t msec, int rate, int channels, audio_effect_format_e format);
 void audio_effect_util_convert_s16le_to_float(size_t n, const short *a, float *b);
index 46c54748b2e6dc69ff512e503baf84cb08e1ab24..05fa8028c00c9d4674868c9a4a00b70e2746f5c3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libaudio-effect
 Summary:    audio effect library
-Version:    0.0.25
+Version:    0.0.26
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 3df374da71dafea6552b5861051e91680dff3353..c7c78b3c1ed0f70599f4c719ff025426e0f9e2ae 100644 (file)
@@ -17,6 +17,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <dlfcn.h>
+#include <string.h>
+#include <config.h>
 
 #include <audio_effect.h>
 #include <audio_effect_interface.h>
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
 
-audio_effect_s *audio_effect_create(audio_effect_method_e method, int rate, int channels,
-                                       audio_effect_format_e format, size_t frames)
+static const char *effect_path_list[] = {
+       [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_REFCOPY] = DL_PLUGIN_PATH "libaudio-effect-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_NS_SRID] = DL_PLUGIN_PATH "libaudio-effect-ns-srid.so",
+       [AUDIO_EFFECT_METHOD_AGC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-agc-speex.so",
+       [AUDIO_EFFECT_METHOD_AMPLIFY] = DL_PLUGIN_PATH "libaudio-effect-amplify.so",
+};
+
+static_assert(sizeof(effect_path_list) / sizeof(char *) == AUDIO_EFFECT_METHOD_MAX);
+
+static const char *_get_plugin_name(const char *name)
 {
-       audio_effect_s *ae;
-       audio_effect_interface_s *intf;
+       assert(name);
+       return name + strlen(DL_PLUGIN_PATH);
+}
 
-       intf = audio_effect_interface_new(method, rate, channels, format, frames);
-       if (!intf) {
-               LOG_ERROR("failed to create interface,"
-                              "method(%d) rate(%d), channels(%d), format(%d), frames(%zu)",
-                              method, rate, channels, format, frames);
+audio_effect_s *audio_effect_create(audio_effect_method_e method,
+                                       int rate,
+                                       int channels,
+                                       audio_effect_format_e format,
+                                       size_t request_frames,
+                                       size_t *adjust_frames)
+{
+       audio_effect_s *ae = NULL;
+       audio_effect_interface_s *intf = NULL;
+       void *dl_handle = NULL;
+       size_t _adjust_frames;
+
+       LOG_INFO("Trys to open plugin. name(%s)", _get_plugin_name(effect_path_list[method]));
+
+       dl_handle = dlopen(effect_path_list[method], RTLD_LAZY);
+       if (!dl_handle) {
+               LOG_ERROR("Failed to open handle. path(%s) dlerror(%s)", _get_plugin_name(effect_path_list[method]), dlerror());
                return NULL;
        }
 
+       LOG_INFO("dlopened plugin. name(%s)", _get_plugin_name(effect_path_list[method]));
+
+       intf = audio_effect_interface_get(dl_handle, rate, channels, format, request_frames, &_adjust_frames);
+       if (!intf) {
+               LOG_ERROR("Failed to create interface,"
+                              "method(%d) rate(%d), channels(%d), format(%d), request_frames(%zu)",
+                              method, rate, channels, format, request_frames);
+               goto fail;
+       }
+
        ae = (audio_effect_s *)calloc(1, sizeof(audio_effect_s));
-       assert(ae);
+       if (!ae) {
+               LOG_ERROR("Failed to allocate memory");
+               goto fail;
+       }
 
+       ae->dl_handle = dl_handle;
        ae->intf = intf;
-       ae->priv = intf->create(rate, channels, format, frames);
-       ae->request_framesize = frames;
-
+       ae->method = method;
+       ae->priv = intf->create(rate, channels, format, _adjust_frames);
        if (!ae->priv) {
-               audio_effect_interface_free(ae->intf);
-               free(ae);
-
                LOG_ERROR("Failed to create plugin function");
-               return NULL;
+               goto fail;
        }
 
+       *adjust_frames = _adjust_frames;
+
+       LOG_INFO("audio-effect created. method(%d), rate(%d), channels(%d), "
+                       "foramt(%d), request_frames(%zu), adjust_framesize(%zu)",
+                       method, rate, channels, format, request_frames, *adjust_frames);
+
        return ae;
+
+fail:
+       if (dl_handle)
+               dlclose(dl_handle);
+       if (ae)
+               free(ae);
+
+       return NULL;
 }
 
-int audio_effect_process(audio_effect_s *ae, void *in, void *out)
+int audio_effect_process(audio_effect_s *ae, const void *in, void *out)
 {
        assert(in);
        assert(out);
@@ -74,7 +126,7 @@ int audio_effect_process(audio_effect_s *ae, void *in, void *out)
        return ae->intf->process(ae->priv, in, out);
 }
 
-int audio_effect_process_reference(audio_effect_s *ae, void *in, void *ref, void *out)
+int audio_effect_process_reference(audio_effect_s *ae, const void *in, const void *ref, void *out)
 {
        assert(in);
        assert(out);
@@ -92,27 +144,22 @@ int audio_effect_process_reference(audio_effect_s *ae, void *in, void *ref, void
 
 void audio_effect_destroy(audio_effect_s *ae)
 {
+       int ret;
+
        assert(ae);
        assert(ae->intf);
        assert(ae->priv);
        assert(ae->intf->destroy);
 
        ae->intf->destroy(ae->priv);
-       audio_effect_interface_free(ae->intf);
 
-       free(ae);
-}
+       LOG_INFO("unloading the plugin. (%s)", _get_plugin_name(effect_path_list[ae->method]));
 
-size_t audio_effect_get_process_framesize(audio_effect_s *ae)
-{
-       audio_effect_plugin_info_s *plugin_info;
+       if ((ret = dlclose(ae->dl_handle)) != 0)
+               LOG_ERROR("Failed to close plugin. ret(%d), dlerror(%s)", ret, dlerror());
 
-       assert(ae);
+       LOG_INFO("unloaded the plugin. (%s)", _get_plugin_name(effect_path_list[ae->method]));
 
-       plugin_info = container_of(ae->intf, audio_effect_plugin_info_s, interface);
-
-       if (plugin_info->constraint.frames != 0)
-               return plugin_info->constraint.frames;
-       else
-               return ae->request_framesize;
+       free(ae);
 }
+
index e507a70ae392a427fb2b0e96da9ea0d4a7d3d4c9..8821008fade7452e15f861cdd8a193a01683e234 100644 (file)
 #include <assert.h>
 #include <stdlib.h>
 #include <dlfcn.h>
-#include <config.h>
+#include <stdbool.h>
 
 /* Remove annoying errors like below
  * ISO C forbids conversion of object pointer to function pointer type
  * when I convert void pointer to function pointer */
 #include <stdint.h>
-#include <string.h>
 
 #include <audio_effect_interface.h>
 #include <audio_effect_util.h>
 #include <audio_effect_log.h>
 
-typedef audio_effect_plugin_info_s *(*entry_point_t)(void);
+static bool _audio_effect_interface_verify_constraint(audio_effect_plugin_info_s *plugin_info,
+                                                       int rate,
+                                                       int channels,
+                                                       audio_effect_format_e format,
+                                                       size_t request_frames,
+                                                       size_t *adjust_frames)
+{
+       /* check constraint */
+       if (plugin_info->constraint.min_rate > rate || rate > plugin_info->constraint.max_rate) {
+               LOG_ERROR("Not supported. name(%s), rate(%d), min_rate(%d), max_rate(%d)",
+                               plugin_info->name, rate, plugin_info->constraint.min_rate, plugin_info->constraint.max_rate);
+               return false;
+       }
+
+       if (plugin_info->constraint.min_channels > channels || channels > plugin_info->constraint.max_channels) {
+               LOG_ERROR("Not supported. name(%s), channels(%d), min_channels(%d), max_channels(%d)",
+                               plugin_info->name, channels, plugin_info->constraint.min_channels, plugin_info->constraint.max_channels);
+               return false;
+       }
 
-static const char *effect_path_list[] = {
-       [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_REFCOPY] = DL_PLUGIN_PATH "libaudio-effect-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_NS_SRID] = DL_PLUGIN_PATH "libaudio-effect-ns-srid.so",
-       [AUDIO_EFFECT_METHOD_AGC_SPEEX] = DL_PLUGIN_PATH "libaudio-effect-agc-speex.so",
-       [AUDIO_EFFECT_METHOD_AMPLIFY] = DL_PLUGIN_PATH "libaudio-effect-amplify.so",
-};
+       if (plugin_info->constraint.min_format > format || format > plugin_info->constraint.max_format) {
+               LOG_ERROR("Not supported. name(%s), format(%d), min_format(%d), max_format(%d)",
+                               plugin_info->name, format, plugin_info->constraint.min_format, plugin_info->constraint.max_format);
+               return false;
+       }
 
-static_assert(sizeof(effect_path_list) / sizeof(char *) == AUDIO_EFFECT_METHOD_MAX);
+       if (plugin_info->constraint.frames_msec == 0) {
+               LOG_INFO("Can't find frame size in plugin_info");
+               return false;
+       }
 
-static void *dl_handles[AUDIO_EFFECT_METHOD_MAX];
+       *adjust_frames = audio_effect_util_msec_to_frame(plugin_info->constraint.frames_msec, rate);
 
-static const char *get_plugin_name(const char *name)
-{
-       assert(name);
-       return name + strlen(DL_PLUGIN_PATH);
+       return true;
 }
 
-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)
+audio_effect_interface_s *audio_effect_interface_get(void *dl_handle,
+                                               int rate,
+                                               int channels,
+                                               audio_effect_format_e format,
+                                               size_t request_frames,
+                                               size_t *adjust_frames)
 {
        audio_effect_plugin_info_s *plugin_info;
        entry_point_t entry_point;
-       void *handle;
-
-       assert(method < AUDIO_EFFECT_METHOD_MAX);
-
-       LOG_INFO("Trying to create the plugin. method(%s)", get_plugin_name(effect_path_list[method]));
-
-       if (dl_handles[method]) {
-               LOG_ERROR("Failed to load plugin. It's already loaded. method(%s)", get_plugin_name(effect_path_list[method]));
-               return NULL;
-       }
 
-       handle = dlopen(effect_path_list[method], RTLD_LAZY);
-       if (!handle) {
-               LOG_ERROR("Failed to open handle. path(%s) dlerror(%s)", get_plugin_name(effect_path_list[method]), dlerror());
-               return NULL;
-       }
-
-       entry_point = dlsym(handle, PLUGIN_ENTRY_POINT_STRING);
+       entry_point = dlsym(dl_handle, PLUGIN_ENTRY_POINT_STRING);
        if (!entry_point) {
                LOG_ERROR("Failed to get the symbol(%s)", PLUGIN_ENTRY_POINT_STRING);
-               goto fail;
+               return NULL;
        }
 
        plugin_info = entry_point();
        if (!plugin_info) {
                LOG_ERROR("Failed to get plugin_info");
-               goto fail;
-       }
-
-       /* check constraint */
-       if (plugin_info->constraint.min_rate > rate || rate > plugin_info->constraint.max_rate) {
-               LOG_ERROR("Not supported rate(%d), min_rate(%d), max_rate(%d)",
-                               rate, plugin_info->constraint.min_rate, plugin_info->constraint.max_rate);
-               goto fail;
-       }
-
-       if (plugin_info->constraint.min_channels > channels || channels > plugin_info->constraint.max_channels) {
-               LOG_ERROR("Not supported channels(%d), min_channels(%d), max_channels(%d)",
-                               channels, plugin_info->constraint.min_channels, plugin_info->constraint.max_channels);
-               goto fail;
+               return NULL;
        }
 
-       if (plugin_info->constraint.min_format > format || format > plugin_info->constraint.max_format) {
-               LOG_ERROR("Not supported format(%d), min_format(%d), max_format(%d)",
-                               format, plugin_info->constraint.min_format, plugin_info->constraint.max_format);
-               goto fail;
+       if (!_audio_effect_interface_verify_constraint(plugin_info, rate, channels,
+                                               format, request_frames, adjust_frames)) {
+               LOG_WARN("Failed to verify the method with constraint");
+               return NULL;
        }
 
-       if (plugin_info->constraint.frames_msec != 0)
-               plugin_info->constraint.frames = audio_effect_util_msec_to_frame(plugin_info->constraint.frames_msec, rate);
-
-       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");
-
-       dl_handles[method] = handle;
-
-       LOG_INFO("plugin(%s) was created successfully. handle(%p)", get_plugin_name(effect_path_list[method]), dl_handles[method]);
-
        return &plugin_info->interface;
-
-fail:
-       dlclose(handle);
-
-       return NULL;
-}
-
-void audio_effect_interface_free(audio_effect_interface_s *intf)
-{
-       audio_effect_method_e method;
-       int ret;
-
-       assert(intf);
-       assert(dl_handles[intf->method]);
-       assert(intf->method < AUDIO_EFFECT_METHOD_MAX);
-
-       method = intf->method;
-
-       LOG_INFO("unloading the plugin. (%s). handle(%p)", get_plugin_name(effect_path_list[method]), dl_handles[method]);
-
-       if ((ret = dlclose(dl_handles[method])) != 0)
-               LOG_ERROR("Failed to close plugin. ret(%d), dlerror(%s)", ret, dlerror());
-
-       dl_handles[method] = NULL;
-
-       LOG_INFO("unloaded the plugin. (%s)", get_plugin_name(effect_path_list[method]));
 }
 
index 2cfdda615bfdd25938bf5ed737777ac4ef0f6176..e0e59cea90fa852387f1220230247fc699193803 100644 (file)
@@ -43,6 +43,11 @@ size_t audio_effect_util_get_frame_size(audio_effect_format_e format, int channe
        return sample_size_table[format] * channels;
 }
 
+size_t audio_effect_util_frame_to_msec(size_t frame, int rate)
+{
+       return (frame * 1000) / rate;
+}
+
 size_t audio_effect_util_msec_to_frame(size_t msec, int rate)
 {
        return rate * msec / 1000;
index bcafbf785d709b71559fd1cf64c342f0b29e9662..5cd02b32ef4d5d1bac2bee87311e31ca7f559861 100644 (file)
@@ -24,6 +24,8 @@
 #include <speex/speex_preprocess.h>
 #include <speex/speex_echo.h>
 
+#define FRAMES_MSEC    10
+
 struct userdata {
        SpeexEchoState *echo_state;
        SpeexPreprocessState *preprocess;
@@ -89,7 +91,7 @@ fail:
        return NULL;
 }
 
-static int aec_speex_process_reference(void *priv, char *rec, char *ref, char *out)
+static int aec_speex_process_reference(void *priv, const void *rec, const void *ref, void *out)
 {
        struct userdata *u = (struct userdata *)priv;
 
@@ -131,6 +133,7 @@ static audio_effect_plugin_info_s aec_speex_desc= {
                .destroy = aec_speex_destroy,
        },
        .constraint = {
+               .frames_msec = FRAMES_MSEC,
                .min_rate = 8000,
                .max_rate = 48000,
                .min_channels = 1,
index 160bee6d6e7ef31f43eee289d66e171a0c3c2bfd..28ea991f707f9633ebd2ad65da8deb55c9fa7839 100644 (file)
@@ -118,7 +118,7 @@ fail:
        return NULL;
 }
 
-static int aec_webrtc_process_reference(void *priv, char *rec, char *ref, char *out)
+static int aec_webrtc_process_reference(void *priv, const void *rec, const void *ref, void *out)
 {
        struct userdata *u = (struct userdata *)priv;
        size_t frames;
index e0dcc0eb6ff033b081f135fa1f5fc733487867f1..783533616756f659e14ec1e69234f3a1fa8a96e1 100644 (file)
@@ -95,10 +95,10 @@ fail:
        return NULL;
 }
 
-static int agc_speex_process(void *priv, char *in, char *out)
+static int agc_speex_process(void *priv, const void *in, void *out)
 {
        int i;
-       char *src = in;
+       const char *src = (const char *)in;
        char *dst = out;
        struct userdata *u = (struct userdata *)priv;
 
index 3f8490ad37ecb5c3f050a189abafdfadcf7f21eb..ad99e2b082f5b3012b5779341568e852fabdef18 100644 (file)
@@ -19,6 +19,7 @@
 #include <assert.h>
 #include <audio_effect_interface.h>
 
+#define FRAMES_MSEC    10
 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
 
 struct userdata {
@@ -42,7 +43,7 @@ static void *amplify_create(int rate, int channels, audio_effect_format_e format
        return (void *)u;
 }
 
-static int amplify_process(void *priv, char *in, char *out)
+static int amplify_process(void *priv, const void *in, void *out)
 {
        size_t i;
        struct userdata *u = (struct userdata *)priv;
@@ -76,6 +77,7 @@ static audio_effect_plugin_info_s amplify_desc = {
                .destroy = amplify_destroy,
        },
        .constraint = {
+               .frames_msec = FRAMES_MSEC,
                .min_rate = 8000,
                .max_rate = 48000,
                .min_channels = 1,
index da056d2bdb8381862e3215c8506c0487a88802f3..b01a8b5ebebd8bae6313dfdb7dbb5e97d018b547 100644 (file)
@@ -279,7 +279,7 @@ fail:
        return NULL;
 }
 
-static int ns_rnnoise_process(void *priv, char *in, char *out)
+static int ns_rnnoise_process(void *priv, const void *in, void *out)
 {
        struct userdata *u = (struct userdata *)priv;
 
index ec42620cb4189cd4273496f262a01e34aaa0d8d4..14f1242ae5e177c15ac03331d319028a8b68657e 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <noise-suppression.h>
 
+#define FIXED_FRAME_SIZE_MSEC  20
 #define MAX_DELAY_MSEC 20
 
 struct userdata {
@@ -63,8 +64,6 @@ static void *ns_srid_create(int rate, int channels, audio_effect_format_e format
        u->frames = (size_t)frame_size;
        u->buffer = (float *)malloc(sizeof(float) * u->frames);
 
-       ns_srid_desc.constraint.frames = u->frames;
-
        noise_suppression_set_level(u->handle, NOISE_SUPPRESSION_LEVEL_MID);
 
        LOG_INFO("plugin noise-suppression srid init. rate(%d), channels(%d), format(%d), frames(%zu)",
@@ -73,7 +72,7 @@ static void *ns_srid_create(int rate, int channels, audio_effect_format_e format
        return u;
 }
 
-static int ns_srid_process(void *priv, char *in, char *out)
+static int ns_srid_process(void *priv, const void *in, void *out)
 {
        struct userdata *u = (struct userdata *)priv;
        int16_t *rec = (int16_t *)in;
@@ -123,7 +122,7 @@ static audio_effect_plugin_info_s ns_srid_desc = {
                .destroy = ns_srid_destroy,
        },
        .constraint = {
-               .frames = 480,
+               .frames_msec = FIXED_FRAME_SIZE_MSEC,
                .min_rate = 16000,
                .max_rate = 48000,
                .min_channels = 1,
index ab491e9b0f7bb35d79121e9becdc43f74ac4259a..17c0ed5919e82969902d230d617d28f1adc113fd 100644 (file)
@@ -22,6 +22,8 @@
 #include <audio_effect_util.h>
 #include <audio_effect_log.h>
 
+#define FRAMES_MSEC 10
+
 struct userdata {
        size_t frames;
        size_t sample_size;
@@ -47,23 +49,24 @@ static void *reference_copy_create(int rate, int channels, audio_effect_format_e
        return (void *)u;
 }
 
-static int reference_copy_process_reference(void *priv, char *rec, char *ref, char *out)
+static int reference_copy_process_reference(void *priv, const void *rec, const void *ref, void *out)
 {
        struct userdata *u = (struct userdata *)priv;
        size_t rec_bytes, ref_bytes, actual_bytes, total_bytes;
        char *dst = out;
+       char *_out = out;
 
        assert(u);
        assert(rec);
        assert(ref);
-       assert(out);
+       assert(_out);
 
        rec_bytes = u->frame_size;
        ref_bytes = u->sample_size; /* reference must be mono channel */
        actual_bytes = rec_bytes - ref_bytes;
        total_bytes = rec_bytes * u->frames;
 
-       while ((size_t)(dst - out) < total_bytes) {
+       while ((size_t)(dst - _out) < total_bytes) {
                memcpy(dst, rec, actual_bytes);
                memcpy(dst + actual_bytes, ref, ref_bytes);
                dst += rec_bytes;
@@ -90,6 +93,7 @@ static audio_effect_plugin_info_s reference_copy_desc = {
                .destroy = reference_copy_destroy,
        },
        .constraint = {
+               .frames_msec = FRAMES_MSEC,
                .min_rate = 8000,
                .max_rate = 48000,
                .min_channels = 1,
index 1433853225bea73e3eeb3851a84abc1ed649425f..922dfb700a83ee80d1e527a29aef264f54b627dd 100644 (file)
@@ -28,6 +28,7 @@ int main(void)
        int loop;
 
        size_t process_framesize = FRAME_SIZE;
+       size_t adjust_framesize;
 
        int i=1;
 
@@ -57,12 +58,11 @@ int main(void)
                exit(-1);
        }
 
-       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);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_SPEEX, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize, &adjust_framesize);
 
-       printf("process_framesize (%zu)\n", process_framesize);
+       printf("adjust_framesize (%zu)\n", adjust_framesize);
 
-       loop = MIN(rec_size / (process_framesize * sizeof(short)), ref_size / (process_framesize * sizeof(short)));
+       loop = MIN(rec_size / (adjust_framesize * sizeof(short)), ref_size / (adjust_framesize * sizeof(short)));
 
        while (loop-- > 0) {
                ret = fread(in, sizeof(in), 1, f_rec);
index f34608b7120644a5f9d92dce705270a1b1c6ef27..26f59e4ddcb75f81ed641e8906c29dd918b0c563 100644 (file)
@@ -28,6 +28,7 @@ int main(void)
        int loop;
 
        size_t process_framesize = FRAME_SIZE;
+       size_t adjust_framesize;
 
        int i=1;
 
@@ -57,12 +58,11 @@ int main(void)
                exit(-1);
        }
 
-       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);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_WEBRTC, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize, &adjust_framesize);
 
-       printf("process_framesize (%zu)\n", process_framesize);
+       printf("adjust_framesize (%zu)\n", adjust_framesize);
 
-       loop = MIN(rec_size / (process_framesize * sizeof(short)), ref_size / (process_framesize * sizeof(short)));
+       loop = MIN(rec_size / (adjust_framesize * sizeof(short)), ref_size / (adjust_framesize * sizeof(short)));
 
        while (loop-- > 0) {
                ret = fread(in, sizeof(in), 1, f_rec);
index d440d073a28cd797884c4dbc25b4394eaeeb9de2..74d6d6c57e1dc16edd47ddd583e3ed39fa5f14cc 100644 (file)
@@ -27,8 +27,8 @@ int main(void)
 
        int rate[] = { 16000, 16000, 48000 };
        int channels[] = { 1, 2, 2 };
-       int frames[] = { 160, 160, 480 };
-       size_t fs;
+       size_t frames[] = { 160, 160, 480 };
+       size_t adjust_frames;
 
        printf("--- agc speex start ---\n");
 
@@ -45,20 +45,17 @@ int main(void)
                        exit(-1);
                }
 
-               ae = audio_effect_create(AUDIO_EFFECT_METHOD_AGC_SPEEX, rate[i], channels[i], AUDIO_EFFECT_FORMAT_S16, frames[i]);
+               ae = audio_effect_create(AUDIO_EFFECT_METHOD_AGC_SPEEX, rate[i], channels[i], AUDIO_EFFECT_FORMAT_S16, frames[i], &adjust_frames);
                assert(ae);
 
-               fs = audio_effect_get_process_framesize(ae);
-               printf("frame size %zu\n", fs);
-
-               in = (char *)malloc(fs * channels[i] * FORMAT_SIZE);
+               in = (char *)malloc(adjust_frames * channels[i] * FORMAT_SIZE);
                assert(in);
 
-               out = (char *)malloc(fs * channels[i] * FORMAT_SIZE);
+               out = (char *)malloc(adjust_frames * channels[i] * FORMAT_SIZE);
                assert(out);
 
                while (!feof(fin)) {
-                       if (fread(in, channels[i] * FORMAT_SIZE, fs, fin) < 0)
+                       if (fread(in, channels[i] * FORMAT_SIZE, adjust_frames, fin) < 0)
                                break;
 
                        printf("#%d frame. ", n++);
@@ -67,7 +64,7 @@ int main(void)
                                printf("(failed!)\n");
                        } else {
                                printf("(success!)\n");
-                               fwrite(out, channels[i] * FORMAT_SIZE, fs, fout);
+                               fwrite(out, channels[i] * FORMAT_SIZE, adjust_frames, fout);
                        }
                }
 
index 06f41b1df884393d90425368ef17ec5a218e81e0..8f0153210b3234171d5bf2d599050abe595efe1a 100644 (file)
@@ -16,6 +16,7 @@ int main(void)
        char in[FRAME_SIZE*2];
        char out[FRAME_SIZE*2];
        size_t ret;
+       size_t adjust_frames;
 
        int i=0;
 
@@ -33,15 +34,17 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_METHOD_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, &adjust_frames);
+       assert(ae);
+
        while (!feof(fin)) {
                printf("#%d frame. ", i++);
-               ret = fread(in, FRAME_SIZE*sizeof(short), 1, fin);
+               ret = fread(in, adjust_frames*sizeof(short), 1, fin);
                if (audio_effect_process(ae, in, out) < 0) {
                        printf("(failed!)\n");
                } else {
                        printf("(success!), ret(%zu)\n", ret);
-                       fwrite(out, FRAME_SIZE*sizeof(short), 1, fout);
+                       fwrite(out, adjust_frames*sizeof(short), 1, fout);
                }
        }
 
index 6b3c00a2c75b6b9a1326d55cec42bbdbee32ce01..c8208cd076f18e4b4a5f502aa7a4ab2c953d6dd9 100644 (file)
@@ -15,6 +15,7 @@
 #define OUTPUT_FILE_NAME "output_integration.raw"
 #define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
 #define FRAME_SIZE_IN_BYTES(size) (sizeof(short) * CHANNELS * size)
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 static short in[FRAME_SIZE];
 static short ns_out[FRAME_SIZE];
@@ -28,13 +29,13 @@ int main(void)
        FILE *fin = NULL;
        FILE *fref = NULL;
        FILE *fout = NULL;
-       size_t framesize = FRAME_SIZE;
        struct stat st;
        off_t input_file_size;
        audio_effect_method_e methods[3] = { AUDIO_EFFECT_METHOD_NS_RNNOISE,
                                                AUDIO_EFFECT_METHOD_AEC_WEBRTC,
                                                AUDIO_EFFECT_METHOD_AGC_SPEEX };
        int i;
+       size_t adjust_frames = -1;
 
        assert(!stat(AEC_RECORDING_16K_1CH_FILE_NAME, &st));
        input_file_size = st.st_size;
@@ -48,24 +49,26 @@ int main(void)
        fout = fopen(OUTPUT_FILE_NAME, "wb");
        assert(fout);
 
-       for (i=0; i<ARRAY_SIZE(ae); i++)
-               assert((ae[i] = audio_effect_create(methods[i], SAMPLERATE, CHANNELS, AUDIO_EFFECT_FORMAT_S16, FIXED_FRAME_SIZE)));
+       for (i=0; i<ARRAY_SIZE(ae); i++) {
+               size_t _adjust_frames;
+               assert((ae[i] = audio_effect_create(methods[i], SAMPLERATE, CHANNELS, AUDIO_EFFECT_FORMAT_S16, FIXED_FRAME_SIZE, &_adjust_frames)));
+               adjust_frames = MIN(adjust_frames, _adjust_frames);
+       }
 
-       framesize = audio_effect_get_process_framesize(ae[0]);
-       printf("frame size %zu\n", framesize);
+       printf("adjust_frames %zu\n", adjust_frames);
 
-       assert(input_file_size > framesize);
+       assert(input_file_size > adjust_frames);
 
-       input_file_size /= framesize;
-       input_file_size *= framesize;
+       input_file_size /= adjust_frames;
+       input_file_size *= adjust_frames;
 
-       for (i=0; i<(int)input_file_size; i+=FRAME_SIZE_IN_BYTES(framesize)) {
-               assert(fread(in, FRAME_SIZE_IN_BYTES(framesize), 1, fin));
+       for (i=0; i<(int)input_file_size; i+=FRAME_SIZE_IN_BYTES(adjust_frames)) {
+               assert(fread(in, FRAME_SIZE_IN_BYTES(adjust_frames), 1, fin));
                assert(!audio_effect_process(ae[0], in, ns_out));
-               assert(fread(ref, FRAME_SIZE_IN_BYTES(framesize), 1, fref) > 0);
+               assert(fread(ref, FRAME_SIZE_IN_BYTES(adjust_frames), 1, fref) > 0);
                assert(audio_effect_process_reference(ae[1], ns_out, ref, aec_out) >= 0);
                assert(!audio_effect_process(ae[2], aec_out, out));
-               assert(fwrite(out, FRAME_SIZE_IN_BYTES(framesize), 1, fout) > 0);
+               assert(fwrite(out, FRAME_SIZE_IN_BYTES(adjust_frames), 1, fout) > 0);
        }
 
        for (i=0; i<ARRAY_SIZE(ae); i++)
index c9e0ba26c1262425a3030c0f92c438efd766853c..2ba3bcbbcd93f4f2d723de24fe9f40d25de345dd 100644 (file)
@@ -43,6 +43,7 @@ endif
 
 if get_option('aec-webrtc').enabled()
   test_list += [[ 'aec_webrtc_test', 'aec_webrtc_test.c' ]]
+  test_list += [[ 'multi_thread', 'multi_thread.cpp' ]]
 endif
 
 if get_option('agc-speex').enabled()
diff --git a/test/multi_thread.cpp b/test/multi_thread.cpp
new file mode 100644 (file)
index 0000000..eb5ee35
--- /dev/null
@@ -0,0 +1,114 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <sys/stat.h>
+
+#include <vector>
+#include <thread>
+
+#include "audio_effect.h"
+#include "resources.h"
+
+#define FRAME_SIZE 160
+
+#define OUTPUT_FILE "output_multi_thread"
+#define MIN(a, b) (a > b ? b : a)
+
+void thread_func(int i)
+{
+       audio_effect_s *ae;
+       FILE *f_rec;
+       FILE *f_ref;
+       FILE *f_out;
+
+       struct stat st;
+       short in[FRAME_SIZE];
+       short ref[FRAME_SIZE];
+       short out[FRAME_SIZE];
+       off_t rec_size;
+       off_t ref_size;
+       size_t ret;
+       int loop;
+       char output_file[256];
+
+       size_t process_framesize = FRAME_SIZE;
+       size_t adjust_framesize;
+
+       printf("--- aec webrtc test start ---\n");
+
+       stat(AEC_RECORDING_16K_1CH_FILE_NAME, &st);
+       rec_size = st.st_size;
+
+       stat(AEC_REFERENCE_16K_1CH_FILE_NAME, &st);
+       ref_size = st.st_size;
+
+       f_rec = fopen(AEC_RECORDING_16K_1CH_FILE_NAME, "r");
+       if (!f_rec) {
+               printf("failed to find rec.raw\n");
+               exit(-1);
+       }
+
+       f_ref = fopen(AEC_REFERENCE_16K_1CH_FILE_NAME, "r");
+       if (!f_ref) {
+               printf("failed to find ref.raw\n");
+               exit(-1);
+       }
+
+       sprintf(output_file, "%s_%d.raw", OUTPUT_FILE, i);
+       f_out = fopen(output_file, "wb");
+       if (!f_out) {
+               printf("failed to open raw\n");
+               exit(-1);
+       }
+
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_AEC_WEBRTC, 16000, 1, AUDIO_EFFECT_FORMAT_S16, process_framesize, &adjust_framesize);
+
+       printf("adjust_framesize (%zu)\n", adjust_framesize);
+
+       loop = MIN(rec_size / (adjust_framesize * sizeof(short)), ref_size / (adjust_framesize * sizeof(short)));
+
+       while (loop-- > 0) {
+               ret = fread(in, sizeof(in), 1, f_rec);
+               if (ret == 0) {
+                       printf("Failed to read from rec file\n");
+                       exit(-1);
+               }
+
+               ret = fread(ref, sizeof(ref), 1, f_ref);
+               if (ret == 0) {
+                       printf("Failed to read from ref file\n");
+                       exit(-1);
+               }
+
+               if (audio_effect_process_reference(ae, in, ref, out) < 0) {
+                       printf("(failed!)\n");
+                       exit(-1);
+               }
+
+               fwrite(out, sizeof(out), 1, f_out);
+
+               printf("#%d frame done.\n", i++);
+       }
+
+       fclose(f_rec);
+       fclose(f_ref);
+       fclose(f_out);
+
+       audio_effect_destroy(ae);
+
+       printf("--- test end ---\n");
+
+}
+
+int main(void)
+{
+       const int thread_max = 10;
+       std::vector<std::thread> threads;
+
+       for (int i=0; i<thread_max; i++)
+               threads.emplace_back(thread_func, i);
+       for (int i=0; i<thread_max; i++)
+               threads[i].join();
+
+       return 0;
+}
index 868317d18607a3db9feb2d39bca8bfc755fae6df..8058a89268b30e5fa643071a58e28952eb6e7d96 100644 (file)
@@ -16,12 +16,12 @@ int main(void)
        FILE *fout;
        short *in;
        short *out;
-       size_t framesize;
        int i;
 
        int channels[] = { 1, 2, 1 };
        int rate[] = { 44100, 44100, 48000 };
-       int frame_size[] = { 441, 441, 480 };
+       size_t frame_size[] = { 441, 441, 480 };
+       size_t adjust_frames;
        char *test_file[] = { NOISE_441K_MONO_FILE_NAME, NOISE_441K_STEREO_FILE_NAME, NOISE_48K_FILE_NAME };
        char *output_file[] = { OUTPUT_441K_1CH_FILE_NAME, OUTPUT_441K_2CH_FILE_NAME, OUTPUT_48K_FILE_NAME };
 
@@ -52,20 +52,19 @@ int main(void)
                        exit(-1);
                }
 
-               ae = audio_effect_create(AUDIO_EFFECT_METHOD_NS_RNNOISE, rate[i], channels[i], AUDIO_EFFECT_FORMAT_S16, frame_size[i]);
+               ae = audio_effect_create(AUDIO_EFFECT_METHOD_NS_RNNOISE, rate[i], channels[i], AUDIO_EFFECT_FORMAT_S16, frame_size[i], &adjust_frames);
                assert(ae);
 
-               framesize = audio_effect_get_process_framesize(ae);
-               printf("frame size %zu\n", framesize);
+               printf("&adjust_frames %zu\n", adjust_frames);
 
                while (!feof(fin)) {
-                       if (fread(in, sizeof(short) * channels[i] * framesize, 1, fin) < 0)
+                       if (fread(in, sizeof(short) * channels[i] * adjust_frames, 1, fin) < 0)
                                break;
 
                        if (audio_effect_process(ae, in, out) < 0) {
                                printf("(failed!)\n");
                        } else {
-                               fwrite(out, sizeof(short) * channels[i] * framesize, 1, fout);
+                               fwrite(out, sizeof(short) * channels[i] * adjust_frames, 1, fout);
                        }
                }
 
index 579e0fad805a3f46507b6dc39a2d4ebb57ddea9a..df5d6cb1def97eb2cf0670aa91fe05f3dea373ea 100644 (file)
@@ -18,6 +18,7 @@ int main(void)
        short in[FRAME_SIZE];
        short out[FRAME_SIZE];
        size_t framesize = FRAME_SIZE;
+       size_t adjust_frames;
 
        int i, n = 0;
 
@@ -48,14 +49,13 @@ int main(void)
 
                printf("Try to create with framesize(%zu)", framesize);
 
-               ae = audio_effect_create(AUDIO_EFFECT_METHOD_NS_SRID, rate[i], 1, AUDIO_EFFECT_FORMAT_S16, framesize);
+               ae = audio_effect_create(AUDIO_EFFECT_METHOD_NS_SRID, rate[i], 1, AUDIO_EFFECT_FORMAT_S16, framesize, &adjust_frames);
                assert(ae);
 
-               framesize = audio_effect_get_process_framesize(ae);
-               assert(framesize == fixed_frame_size[i]);
+               assert(adjust_frames == fixed_frame_size[i]);
 
                while (!feof(fin)) {
-                       if (fread(in, sizeof(short), framesize, fin) < 0)
+                       if (fread(in, sizeof(short), adjust_frames, fin) < 0)
                                break;
 
                        printf("#%d frame. ", n++);
@@ -64,7 +64,7 @@ int main(void)
                                printf("(failed!)\n");
                        } else {
                                printf("(success!)\n");
-                               fwrite(out, sizeof(short), framesize, fout);
+                               fwrite(out, sizeof(short), adjust_frames, fout);
                        }
                }
 
index 30621cd79b04b563f95d3a28523d42e65f24e97c..f6fef17837e52211d17cc4c5b5e6b81746b91cd4 100644 (file)
@@ -29,6 +29,7 @@ int main(void)
        int loop;
 
        size_t process_framesize = FRAME_SIZE;
+       size_t adjust_frames;
 
        int i=1;
 
@@ -58,12 +59,11 @@ int main(void)
                exit(-1);
        }
 
-       ae = audio_effect_create(AUDIO_EFFECT_METHOD_REFCOPY, 16000, 5, AUDIO_EFFECT_FORMAT_S16, process_framesize);
-       process_framesize = audio_effect_get_process_framesize(ae);
+       ae = audio_effect_create(AUDIO_EFFECT_METHOD_REFCOPY, 16000, 5, AUDIO_EFFECT_FORMAT_S16, process_framesize, &adjust_frames);
 
-       printf("process_framesize (%zu)\n", process_framesize);
+       printf("adjust_frames (%zu)\n", adjust_frames);
 
-       loop = MIN(rec_size / (process_framesize * CHANNELS * sizeof(short)), ref_size / (process_framesize * sizeof(short)));
+       loop = MIN(rec_size / (adjust_frames * CHANNELS * sizeof(short)), ref_size / (adjust_frames * sizeof(short)));
 
        while (loop-- > 0) {
                ret = fread(in, sizeof(in), 1, f_rec);