1- #define TAG "jamesdsp:: "
1+ #define TAG "jamesdsp:"
22#include <android/log.h>
33#define LOGI (...) __android_log_print(ANDROID_LOG_INFO,TAG,__VA_ARGS__)
44#define LOGE (...) __android_log_print(ANDROID_LOG_ERROR,TAG,__VA_ARGS__)
99#include <errno.h>
1010#include "essential.h"
1111
12- static effect_descriptor_t jamesdsp_descriptor =
12+ const effect_descriptor_t jamesdsp_descriptor =
1313{
1414 { 0xf98765f4 , 0xc321 , 0x5de6 , 0x9a45 , { 0x12 , 0x34 , 0x59 , 0x49 , 0x5a , 0xb2 } },
1515 { 0xf27317f4 , 0xc984 , 0x4de6 , 0x9a90 , { 0x54 , 0x57 , 0x59 , 0x49 , 0x5b , 0xf2 } }, // own UUID
@@ -22,48 +22,36 @@ static effect_descriptor_t jamesdsp_descriptor =
2222};
2323__attribute__((constructor )) static void initialize (void )
2424{
25- LOGI ("jamesdspProcessor : DLL loaded" );
25+ LOGI ("Initialization : DLL loaded" );
2626}
2727__attribute__((destructor )) static void destruction (void )
2828{
29- LOGI ("jamesdspProcessor : Unload DLL" );
29+ LOGI ("Initialization : Unload DLL" );
3030}
3131typedef struct
3232{
33- int dummy ;
34- int32_t (* process )(audio_buffer_t * in , audio_buffer_t * out );
35- int32_t (* command )(uint32_t , uint32_t , void * , uint32_t * , void * );
33+ int mEnable ;
3634} Effect ;
3735/* Library mandatory methods. */
3836struct effect_module_s
3937{
4038 const struct effect_interface_s * itfe ;
41- Effect * effect ;
42- effect_descriptor_t * descriptor ;
39+ Effect jdsp ;
4340};
41+ int counter ;
4442static int32_t generic_process (effect_handle_t self , audio_buffer_t * in , audio_buffer_t * out )
4543{
4644 struct effect_module_s * e = (struct effect_module_s * ) self ;
47- return e -> effect -> process (in , out );
48- }
49- static int32_t generic_command (effect_handle_t self , uint32_t cmdCode , uint32_t cmdSize , void * pCmdData , uint32_t * replySize , void * pReplyData )
50- {
51- struct effect_module_s * e = (struct effect_module_s * ) self ;
52- return e -> effect -> command (cmdCode , cmdSize , pCmdData , replySize , pReplyData );
53- }
54- static int32_t generic_getDescriptor (effect_handle_t self , effect_descriptor_t * pDescriptor )
55- {
56- struct effect_module_s * e = (struct effect_module_s * ) self ;
57- memcpy (pDescriptor , e -> descriptor , sizeof (effect_descriptor_t ));
58- return 0 ;
45+ Effect * jdsp = & e -> jdsp ;
46+ int i , actualFrameCount = in -> frameCount ;
47+ counter ++ ;
48+ if (counter == 128 )
49+ {
50+ LOGI ("Processing loop: Processing %d samples" , actualFrameCount );
51+ counter = 0 ;
52+ }
53+ return jdsp -> mEnable ? 0 : - ENODATA ;
5954}
60- static const struct effect_interface_s generic_interface =
61- {
62- generic_process ,
63- generic_command ,
64- generic_getDescriptor ,
65- NULL
66- };
6755int32_t formatConfigure (void * pCmdData , effect_buffer_access_e * mAccessMode )
6856{
6957 int mSamplingRate , formatFloatModeInt32Mode ;
@@ -125,15 +113,33 @@ int32_t formatConfigure(void* pCmdData, effect_buffer_access_e* mAccessMode)
125113 * mAccessMode = (effect_buffer_access_e )out .accessMode ;
126114 return 0 ;
127115}
128- int mEnable ;
129- int32_t transferCmd (uint32_t cmdCode , uint32_t cmdSize , void * pCmdData , uint32_t * replySize , void * pReplyData )
116+ static int32_t generic_command (effect_handle_t self , uint32_t cmdCode , uint32_t cmdSize , void * pCmdData , uint32_t * replySize , void * pReplyData )
130117{
118+ struct effect_module_s * e = (struct effect_module_s * ) self ;
119+ Effect * jdsp = & e -> jdsp ;
120+ if (cmdCode == EFFECT_CMD_SET_CONFIG )
121+ {
122+ effect_buffer_access_e mAccessMode ;
123+ int32_t * replyData = (int32_t * )pReplyData ;
124+ int32_t ret = formatConfigure (pCmdData , & mAccessMode );
125+ if (ret != 0 )
126+ {
127+ * replyData = ret ;
128+ return 0 ;
129+ }
130+ * replyData = 0 ;
131+ return 0 ;
132+ }
133+ if (cmdCode == EFFECT_CMD_GET_PARAM )
134+ {
135+ effect_param_t * cep = (effect_param_t * )pCmdData ;
136+ }
131137 switch (cmdCode )
132138 {
133139 case EFFECT_CMD_ENABLE :
134140 case EFFECT_CMD_DISABLE :
135141 {
136- mEnable = cmdCode == EFFECT_CMD_ENABLE ;
142+ jdsp -> mEnable = cmdCode == EFFECT_CMD_ENABLE ;
137143 int32_t * replyData = (int32_t * )pReplyData ;
138144 * replyData = 0 ;
139145 break ;
@@ -164,58 +170,35 @@ int32_t transferCmd(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t
164170 }
165171 return 0 ;
166172}
167- int32_t effectCommand ( uint32_t cmdCode , uint32_t cmdSize , void * pCmdData , uint32_t * replySize , void * pReplyData )
173+ static int32_t generic_getDescriptor ( effect_handle_t self , effect_descriptor_t * pDescriptor )
168174{
169- if (cmdCode == EFFECT_CMD_SET_CONFIG )
170- {
171- effect_buffer_access_e mAccessMode ;
172- int32_t * replyData = (int32_t * )pReplyData ;
173- int32_t ret = formatConfigure (pCmdData , & mAccessMode );
174- if (ret != 0 )
175- {
176- * replyData = ret ;
177- return 0 ;
178- }
179- * replyData = 0 ;
180- return 0 ;
181- }
182- if (cmdCode == EFFECT_CMD_GET_PARAM )
175+ LOGI ("Effect control interface: Copying descriptor info" );
176+ if (pDescriptor == NULL )
183177 {
184- effect_param_t * cep = (effect_param_t * )pCmdData ;
178+ LOGI ("Effect control interface: generic_getDescriptor() called with NULL pointer" );
179+ return - EINVAL ;
185180 }
186- return transferCmd (cmdCode , cmdSize , pCmdData , replySize , pReplyData );
181+ * pDescriptor = jamesdsp_descriptor ;
182+ return 0 ;
187183}
188- int counter ;
189- int32_t effectProcess (audio_buffer_t * in , audio_buffer_t * out )
184+ static const struct effect_interface_s generic_interface =
190185{
191- int i , actualFrameCount = in -> frameCount ;
192- counter ++ ;
193- if (counter == 128 )
194- {
195- LOGI ("jamesdspProcessor: Processing %d samples" , actualFrameCount );
196- counter = 0 ;
197- }
198- return mEnable ? 0 : - ENODATA ;
199- }
200- Effect jdsp ;
186+ generic_process ,
187+ generic_command ,
188+ generic_getDescriptor ,
189+ NULL
190+ };
201191int32_t EffectCreate (const effect_uuid_t * uuid , int32_t sessionId , int32_t ioId , effect_handle_t * pEffect )
202192{
203- LOGI ("jamesdspProcessor : Creating effect with %d sessionId" , sessionId );
193+ LOGI ("Initialization : Creating effect with %d sessionId" , sessionId );
204194 // Debug init start
205- mEnable = 0 ;
206195 counter = 0 ;
207- memset (& jdsp , 0 , sizeof (Effect ));
208- jdsp .command = effectCommand ;
209- jdsp .process = effectProcess ;
210196 // Debug init end
211197 struct effect_module_s * e = (struct effect_module_s * ) calloc (1 , sizeof (struct effect_module_s ));
212198 e -> itfe = & generic_interface ;
213- e -> effect = & jdsp ;
214199 // Initialize effect here
215-
216- e -> descriptor = & jamesdsp_descriptor ;
217200 * pEffect = (effect_handle_t )e ;
218- LOGI ("jamesdspProcessor : Effect created" );
201+ LOGI ("Initialization : Effect created" );
219202 return 0 ;
220203}
221204int32_t EffectRelease (effect_handle_t ei )
@@ -226,10 +209,10 @@ int32_t EffectRelease(effect_handle_t ei)
226209}
227210int32_t EffectGetDescriptor (const effect_uuid_t * uuid , effect_descriptor_t * pDescriptor )
228211{
229- LOGI ("jamesdspProcessor : Copying descriptor info" );
212+ LOGI ("Initialization : Copying descriptor info" );
230213 if (pDescriptor == NULL || uuid == NULL )
231214 {
232- LOGI ("jamesdspProcessor : EffectGetDescriptor() called with NULL pointer" );
215+ LOGI ("Initialization : EffectGetDescriptor() called with NULL pointer" );
233216 return - EINVAL ;
234217 }
235218 * pDescriptor = jamesdsp_descriptor ;
0 commit comments