blob: d19c6b9fdbcb333de459d78a15878f576c3cba48 [file] [log] [blame]
Eric Laurent135ad072010-05-21 06:05:13 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "Equalizer"
18#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
19//#define LOG_NDEBUG 0
20#include <cutils/log.h>
21#include <assert.h>
22#include <stdlib.h>
Eric Laurent17217ab2010-05-25 12:38:34 -070023#include <string.h>
Eric Laurent135ad072010-05-21 06:05:13 -070024#include <new>
25#include "AudioEqualizer.h"
26#include "AudioBiquadFilter.h"
27#include "AudioFormatAdapter.h"
28#include <media/EffectEqualizerApi.h>
29
30// effect_interface_t interface implementation for equalizer effect
31extern "C" const struct effect_interface_s gEqualizerInterface;
32
33namespace android {
34namespace {
35
36// Google Graphic Equalizer UUID: e25aa840-543b-11df-98a5-0002a5d5c51b
37const effect_descriptor_t gEqualizerDescriptor = {
38 {0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // type
39 {0xe25aa840, 0x543b, 0x11df, 0x98a5, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid
40 EFFECT_API_VERSION,
41 (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_LAST),
Eric Laurentffe9c252010-06-23 17:38:20 -070042 0, // TODO
43 1,
Eric Laurent135ad072010-05-21 06:05:13 -070044 "Graphic Equalizer",
45 "Google Inc.",
46};
Eric Laurent135ad072010-05-21 06:05:13 -070047
48/////////////////// BEGIN EQ PRESETS ///////////////////////////////////////////
49const int kNumBands = 5;
50const uint32_t gFreqs[kNumBands] = { 50000, 125000, 900000, 3200000, 6300000 };
51const uint32_t gBandwidths[kNumBands] = { 0, 3600, 3600, 2400, 0 };
52
53const AudioEqualizer::BandConfig gBandsClassic[kNumBands] = {
54 { 300, gFreqs[0], gBandwidths[0] },
55 { 400, gFreqs[1], gBandwidths[1] },
56 { 0, gFreqs[2], gBandwidths[2] },
57 { 200, gFreqs[3], gBandwidths[3] },
58 { -300, gFreqs[4], gBandwidths[4] }
59};
60
61const AudioEqualizer::BandConfig gBandsJazz[kNumBands] = {
62 { -600, gFreqs[0], gBandwidths[0] },
63 { 200, gFreqs[1], gBandwidths[1] },
64 { 400, gFreqs[2], gBandwidths[2] },
65 { -400, gFreqs[3], gBandwidths[3] },
66 { -600, gFreqs[4], gBandwidths[4] }
67};
68
69const AudioEqualizer::BandConfig gBandsPop[kNumBands] = {
70 { 400, gFreqs[0], gBandwidths[0] },
71 { -400, gFreqs[1], gBandwidths[1] },
72 { 300, gFreqs[2], gBandwidths[2] },
73 { -400, gFreqs[3], gBandwidths[3] },
74 { 600, gFreqs[4], gBandwidths[4] }
75};
76
77const AudioEqualizer::BandConfig gBandsRock[kNumBands] = {
78 { 700, gFreqs[0], gBandwidths[0] },
79 { 400, gFreqs[1], gBandwidths[1] },
80 { -400, gFreqs[2], gBandwidths[2] },
81 { 400, gFreqs[3], gBandwidths[3] },
82 { 200, gFreqs[4], gBandwidths[4] }
83};
84
85const AudioEqualizer::PresetConfig gEqualizerPresets[] = {
86 { "Classic", gBandsClassic },
87 { "Jazz", gBandsJazz },
88 { "Pop", gBandsPop },
89 { "Rock", gBandsRock }
90};
91
92/////////////////// END EQ PRESETS /////////////////////////////////////////////
93
94static const size_t kBufferSize = 32;
95
96typedef AudioFormatAdapter<AudioEqualizer, kBufferSize> FormatAdapter;
97
98struct EqualizerContext {
99 const struct effect_interface_s *itfe;
100 effect_config_t config;
101 FormatAdapter adapter;
102 AudioEqualizer * pEqualizer;
103};
104
Eric Laurent135ad072010-05-21 06:05:13 -0700105//--- local function prototypes
106
107int Equalizer_init(EqualizerContext *pContext);
108int Equalizer_configure(EqualizerContext *pContext, effect_config_t *pConfig);
109int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t *pValueSize, void *pValue);
110int Equalizer_setParameter(AudioEqualizer * pEqualizer, int32_t *pParam, void *pValue);
111
112
113//
114//--- Effect Library Interface Implementation
115//
116
Eric Laurentbe916aa2010-06-01 23:49:17 -0700117extern "C" int EffectQueryNumberEffects(uint32_t *pNumEffects) {
Eric Laurent135ad072010-05-21 06:05:13 -0700118 *pNumEffects = 1;
Eric Laurent135ad072010-05-21 06:05:13 -0700119 return 0;
120} /* end EffectQueryNumberEffects */
121
Eric Laurentffe9c252010-06-23 17:38:20 -0700122extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor) {
Eric Laurent135ad072010-05-21 06:05:13 -0700123 if (pDescriptor == NULL) {
124 return -EINVAL;
125 }
Eric Laurentffe9c252010-06-23 17:38:20 -0700126 if (index > 0) {
127 return -EINVAL;
Eric Laurent135ad072010-05-21 06:05:13 -0700128 }
129 memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
130 return 0;
131} /* end EffectQueryNext */
132
133extern "C" int EffectCreate(effect_uuid_t *uuid,
Eric Laurentffe9c252010-06-23 17:38:20 -0700134 int32_t sessionId,
135 int32_t ioId,
Eric Laurent135ad072010-05-21 06:05:13 -0700136 effect_interface_t *pInterface) {
137 int ret;
138 int i;
139
140 LOGV("EffectLibCreateEffect start");
141
142 if (pInterface == NULL || uuid == NULL) {
143 return -EINVAL;
144 }
145
146 if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) != 0) {
147 return -EINVAL;
148 }
149
150 EqualizerContext *pContext = new EqualizerContext;
151
152 pContext->itfe = &gEqualizerInterface;
153 pContext->pEqualizer = NULL;
154
155 ret = Equalizer_init(pContext);
156 if (ret < 0) {
157 LOGW("EffectLibCreateEffect() init failed");
158 delete pContext;
159 return ret;
160 }
161
162 *pInterface = (effect_interface_t)pContext;
163
Eric Laurentffe9c252010-06-23 17:38:20 -0700164 LOGV("EffectLibCreateEffect %p, size %d", pContext, AudioEqualizer::GetInstanceSize(kNumBands)+sizeof(EqualizerContext));
Eric Laurent135ad072010-05-21 06:05:13 -0700165
166 return 0;
167
168} /* end EffectCreate */
169
170extern "C" int EffectRelease(effect_interface_t interface) {
171 EqualizerContext * pContext = (EqualizerContext *)interface;
172
173 LOGV("EffectLibReleaseEffect %p", interface);
174 if (pContext == NULL) {
175 return -EINVAL;
176 }
177
178 pContext->pEqualizer->free();
179 delete pContext;
180
181 return 0;
182} /* end EffectRelease */
183
184
185//
186//--- local functions
187//
188
189#define CHECK_ARG(cond) { \
190 if (!(cond)) { \
191 LOGV("Invalid argument: "#cond); \
192 return -EINVAL; \
193 } \
194}
195
196//----------------------------------------------------------------------------
197// Equalizer_configure()
198//----------------------------------------------------------------------------
199// Purpose: Set input and output audio configuration.
200//
201// Inputs:
202// pContext: effect engine context
203// pConfig: pointer to effect_config_t structure holding input and output
204// configuration parameters
205//
206// Outputs:
207//
208//----------------------------------------------------------------------------
209
210int Equalizer_configure(EqualizerContext *pContext, effect_config_t *pConfig)
211{
212 LOGV("Equalizer_configure start");
213
214 CHECK_ARG(pContext != NULL);
215 CHECK_ARG(pConfig != NULL);
216
217 CHECK_ARG(pConfig->inputCfg.samplingRate == pConfig->outputCfg.samplingRate);
218 CHECK_ARG(pConfig->inputCfg.channels == pConfig->outputCfg.channels);
219 CHECK_ARG(pConfig->inputCfg.format == pConfig->outputCfg.format);
220 CHECK_ARG((pConfig->inputCfg.channels == CHANNEL_MONO) || (pConfig->inputCfg.channels == CHANNEL_STEREO));
221 CHECK_ARG(pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_WRITE
222 || pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
Eric Laurentffe9c252010-06-23 17:38:20 -0700223 CHECK_ARG(pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S7_24
224 || pConfig->inputCfg.format == SAMPLE_FORMAT_PCM_S15);
Eric Laurent135ad072010-05-21 06:05:13 -0700225
226 int channelCount;
227 if (pConfig->inputCfg.channels == CHANNEL_MONO) {
228 channelCount = 1;
229 } else {
230 channelCount = 2;
231 }
232 CHECK_ARG(channelCount <= AudioBiquadFilter::MAX_CHANNELS);
233
Eric Laurentffe9c252010-06-23 17:38:20 -0700234 memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
235
Eric Laurent135ad072010-05-21 06:05:13 -0700236 pContext->pEqualizer->configure(channelCount,
237 pConfig->inputCfg.samplingRate);
238
239 pContext->adapter.configure(*pContext->pEqualizer, channelCount,
240 pConfig->inputCfg.format,
241 pConfig->outputCfg.accessMode);
242
243 return 0;
244} // end Equalizer_configure
245
246
247//----------------------------------------------------------------------------
248// Equalizer_init()
249//----------------------------------------------------------------------------
250// Purpose: Initialize engine with default configuration and creates
251// AudioEqualizer instance.
252//
253// Inputs:
254// pContext: effect engine context
255//
256// Outputs:
257//
258//----------------------------------------------------------------------------
259
260int Equalizer_init(EqualizerContext *pContext)
261{
262 int status;
263
264 LOGV("Equalizer_init start");
265
266 CHECK_ARG(pContext != NULL);
267
268 if (pContext->pEqualizer != NULL) {
269 pContext->pEqualizer->free();
270 }
271
272 pContext->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ;
273 pContext->config.inputCfg.channels = CHANNEL_STEREO;
Eric Laurentffe9c252010-06-23 17:38:20 -0700274 pContext->config.inputCfg.format = SAMPLE_FORMAT_PCM_S15;
Eric Laurent135ad072010-05-21 06:05:13 -0700275 pContext->config.inputCfg.samplingRate = 44100;
276 pContext->config.inputCfg.bufferProvider.getBuffer = NULL;
277 pContext->config.inputCfg.bufferProvider.releaseBuffer = NULL;
278 pContext->config.inputCfg.bufferProvider.cookie = NULL;
279 pContext->config.inputCfg.mask = EFFECT_CONFIG_ALL;
280 pContext->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE;
281 pContext->config.outputCfg.channels = CHANNEL_STEREO;
Eric Laurentffe9c252010-06-23 17:38:20 -0700282 pContext->config.outputCfg.format = SAMPLE_FORMAT_PCM_S15;
Eric Laurent135ad072010-05-21 06:05:13 -0700283 pContext->config.outputCfg.samplingRate = 44100;
284 pContext->config.outputCfg.bufferProvider.getBuffer = NULL;
285 pContext->config.outputCfg.bufferProvider.releaseBuffer = NULL;
286 pContext->config.outputCfg.bufferProvider.cookie = NULL;
287 pContext->config.outputCfg.mask = EFFECT_CONFIG_ALL;
288
289 pContext->pEqualizer = AudioEqualizer::CreateInstance(
290 NULL,
291 kNumBands,
292 AudioBiquadFilter::MAX_CHANNELS,
293 44100,
294 gEqualizerPresets,
295 ARRAY_SIZE(gEqualizerPresets));
296
297 for (int i = 0; i < kNumBands; ++i) {
298 pContext->pEqualizer->setFrequency(i, gFreqs[i]);
299 pContext->pEqualizer->setBandwidth(i, gBandwidths[i]);
300 }
301
302 pContext->pEqualizer->enable(true);
303
304 Equalizer_configure(pContext, &pContext->config);
305
306 return 0;
307} // end Equalizer_init
308
309
310//----------------------------------------------------------------------------
311// Equalizer_getParameter()
312//----------------------------------------------------------------------------
313// Purpose:
314// Get a Equalizer parameter
315//
316// Inputs:
317// pEqualizer - handle to instance data
318// pParam - pointer to parameter
319// pValue - pointer to variable to hold retrieved value
320// pValueSize - pointer to value size: maximum size as input
321//
322// Outputs:
323// *pValue updated with parameter value
324// *pValueSize updated with actual value size
325//
326//
327// Side Effects:
328//
329//----------------------------------------------------------------------------
330
331int Equalizer_getParameter(AudioEqualizer * pEqualizer, int32_t *pParam, size_t *pValueSize, void *pValue)
332{
333 int status = 0;
334 int32_t param = *pParam++;
335 int32_t param2;
336 char *name;
337
338 switch (param) {
339 case EQ_PARAM_NUM_BANDS:
340 case EQ_PARAM_CUR_PRESET:
341 case EQ_PARAM_GET_NUM_OF_PRESETS:
342 if (*pValueSize < sizeof(int16_t)) {
343 return -EINVAL;
344 }
345 *pValueSize = sizeof(int16_t);
346 break;
347
348 case EQ_PARAM_LEVEL_RANGE:
349 case EQ_PARAM_BAND_FREQ_RANGE:
350 if (*pValueSize < 2 * sizeof(int32_t)) {
351 return -EINVAL;
352 }
353 *pValueSize = 2 * sizeof(int32_t);
354 break;
355 case EQ_PARAM_BAND_LEVEL:
356 case EQ_PARAM_GET_BAND:
357 case EQ_PARAM_CENTER_FREQ:
358 if (*pValueSize < sizeof(int32_t)) {
359 return -EINVAL;
360 }
361 *pValueSize = sizeof(int32_t);
362 break;
363
364 case EQ_PARAM_GET_PRESET_NAME:
365 break;
366
367 default:
368 return -EINVAL;
369 }
370
371 switch (param) {
372 case EQ_PARAM_NUM_BANDS:
373 *(int16_t *)pValue = kNumBands;
374 LOGV("Equalizer_getParameter() EQ_PARAM_NUM_BANDS %d", *(int16_t *)pValue);
375 break;
376
377 case EQ_PARAM_LEVEL_RANGE:
378 *(int32_t *)pValue = -9600;
379 *((int32_t *)pValue + 1) = 4800;
380 LOGV("Equalizer_getParameter() EQ_PARAM_LEVEL_RANGE min %d, max %d", *(int32_t *)pValue, *((int32_t *)pValue + 1));
381 break;
382
383 case EQ_PARAM_BAND_LEVEL:
384 param2 = *pParam;
385 if (param2 >= kNumBands) {
386 status = -EINVAL;
387 break;
388 }
389 *(int32_t *)pValue = pEqualizer->getGain(param2);
390 LOGV("Equalizer_getParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", param2, *(int32_t *)pValue);
391 break;
392
393 case EQ_PARAM_CENTER_FREQ:
394 param2 = *pParam;
395 if (param2 >= kNumBands) {
396 status = -EINVAL;
397 break;
398 }
399 *(int32_t *)pValue = pEqualizer->getFrequency(param2);
400 LOGV("Equalizer_getParameter() EQ_PARAM_CENTER_FREQ band %d, frequency %d", param2, *(int32_t *)pValue);
401 break;
402
403 case EQ_PARAM_BAND_FREQ_RANGE:
404 param2 = *pParam;
405 if (param2 >= kNumBands) {
406 status = -EINVAL;
407 break;
408 }
409 pEqualizer->getBandRange(param2, *(uint32_t *)pValue, *((uint32_t *)pValue + 1));
410 LOGV("Equalizer_getParameter() EQ_PARAM_BAND_FREQ_RANGE band %d, min %d, max %d", param2, *(int32_t *)pValue, *((int32_t *)pValue + 1));
411 break;
412
413 case EQ_PARAM_GET_BAND:
414 param2 = *pParam;
415 *(int32_t *)pValue = pEqualizer->getMostRelevantBand(param2);
416 LOGV("Equalizer_getParameter() EQ_PARAM_GET_BAND frequency %d, band %d", param2, *(int32_t *)pValue);
417 break;
418
419 case EQ_PARAM_CUR_PRESET:
420 *(int16_t *)pValue = pEqualizer->getPreset();
421 LOGV("Equalizer_getParameter() EQ_PARAM_CUR_PRESET %d", *(int32_t *)pValue);
422 break;
423
424 case EQ_PARAM_GET_NUM_OF_PRESETS:
425 *(int16_t *)pValue = pEqualizer->getNumPresets();
426 LOGV("Equalizer_getParameter() EQ_PARAM_GET_NUM_OF_PRESETS %d", *(int16_t *)pValue);
427 break;
428
429 case EQ_PARAM_GET_PRESET_NAME:
430 param2 = *pParam;
431 if (param2 >= pEqualizer->getNumPresets()) {
432 status = -EINVAL;
433 break;
434 }
435 name = (char *)pValue;
436 strncpy(name, pEqualizer->getPresetName(param2), *pValueSize - 1);
437 name[*pValueSize - 1] = 0;
438 *pValueSize = strlen(name) + 1;
439 LOGV("Equalizer_getParameter() EQ_PARAM_GET_PRESET_NAME preset %d, name %s len %d", param2, gEqualizerPresets[param2].name, *pValueSize);
440 break;
441
442 default:
443 LOGV("Equalizer_getParameter() invalid param %d", param);
444 status = -EINVAL;
445 break;
446 }
447
448 return status;
449} // end Equalizer_getParameter
450
451
452//----------------------------------------------------------------------------
453// Equalizer_setParameter()
454//----------------------------------------------------------------------------
455// Purpose:
456// Set a Equalizer parameter
457//
458// Inputs:
459// pEqualizer - handle to instance data
460// pParam - pointer to parameter
461// pValue - pointer to value
462//
463// Outputs:
464//
465//
466// Side Effects:
467//
468//----------------------------------------------------------------------------
469
470int Equalizer_setParameter (AudioEqualizer * pEqualizer, int32_t *pParam, void *pValue)
471{
472 int status = 0;
473 int32_t preset;
474 int32_t band;
475 int32_t level;
476 int32_t param = *pParam++;
477
478
479 switch (param) {
480 case EQ_PARAM_CUR_PRESET:
481 preset = *(int16_t *)pValue;
482
483 LOGV("setParameter() EQ_PARAM_CUR_PRESET %d", preset);
484 if (preset >= pEqualizer->getNumPresets()) {
485 status = -EINVAL;
486 break;
487 }
488 pEqualizer->setPreset(preset);
489 pEqualizer->commit(true);
490 break;
491 case EQ_PARAM_BAND_LEVEL:
492 band = *pParam;
493 level = *(int32_t *)pValue;
494 LOGV("setParameter() EQ_PARAM_BAND_LEVEL band %d, level %d", band, level);
495 if (band >= kNumBands) {
496 status = -EINVAL;
497 break;
498 }
499 pEqualizer->setGain(band, level);
500 pEqualizer->commit(true);
501 break;
502 default:
503 LOGV("setParameter() invalid param %d", param);
504 break;
505 }
506
507 return status;
508} // end Equalizer_setParameter
509
510} // namespace
511} // namespace
512
513
514//
515//--- Effect Control Interface Implementation
516//
517
518extern "C" int Equalizer_process(effect_interface_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer)
519{
520 android::EqualizerContext * pContext = (android::EqualizerContext *) self;
521
522 if (pContext == NULL) {
523 return -EINVAL;
524 }
525 if (inBuffer == NULL || inBuffer->raw == NULL ||
526 outBuffer == NULL || outBuffer->raw == NULL ||
527 inBuffer->frameCount != outBuffer->frameCount) {
528 return -EINVAL;
529 }
530
531 pContext->adapter.process(inBuffer->raw, outBuffer->raw, outBuffer->frameCount);
Eric Laurentffe9c252010-06-23 17:38:20 -0700532
Eric Laurent135ad072010-05-21 06:05:13 -0700533 return 0;
534} // end Equalizer_process
535
536extern "C" int Equalizer_command(effect_interface_t self, int cmdCode, int cmdSize,
537 void *pCmdData, int *replySize, void *pReplyData) {
538
539 android::EqualizerContext * pContext = (android::EqualizerContext *) self;
540 int retsize;
541
542 if (pContext == NULL) {
543 return -EINVAL;
544 }
545
546 android::AudioEqualizer * pEqualizer = pContext->pEqualizer;
547
548 LOGV("Equalizer_command command %d cmdSize %d",cmdCode, cmdSize);
549
550 switch (cmdCode) {
551 case EFFECT_CMD_INIT:
552 if (pReplyData == NULL || *replySize != sizeof(int)) {
553 return -EINVAL;
554 }
555 *(int *) pReplyData = Equalizer_init(pContext);
556 break;
557 case EFFECT_CMD_CONFIGURE:
558 if (pCmdData == NULL || cmdSize != sizeof(effect_config_t)
559 || pReplyData == NULL || *replySize != sizeof(int)) {
560 return -EINVAL;
561 }
562 *(int *) pReplyData = Equalizer_configure(pContext,
563 (effect_config_t *) pCmdData);
564 break;
565 case EFFECT_CMD_RESET:
566 Equalizer_configure(pContext, &pContext->config);
567 break;
568 case EFFECT_CMD_GET_PARAM: {
569 if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
570 pReplyData == NULL || *replySize < (int) (sizeof(effect_param_t) + sizeof(int32_t))) {
571 return -EINVAL;
572 }
573 effect_param_t *p = (effect_param_t *)pCmdData;
574 memcpy(pReplyData, pCmdData, sizeof(effect_param_t) + p->psize);
575 p = (effect_param_t *)pReplyData;
576 int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t);
577 p->status = android::Equalizer_getParameter(pEqualizer, (int32_t *)p->data, &p->vsize,
578 p->data + voffset);
579 *replySize = sizeof(effect_param_t) + voffset + p->vsize;
580 LOGV("Equalizer_command EFFECT_CMD_GET_PARAM *pCmdData %d, *replySize %d, *pReplyData %08x %08x",
581 *(int32_t *)((char *)pCmdData + sizeof(effect_param_t)), *replySize,
582 *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset),
583 *(int32_t *)((char *)pReplyData + sizeof(effect_param_t) + voffset + sizeof(int32_t)));
584
585 } break;
586 case EFFECT_CMD_SET_PARAM: {
587 LOGV("Equalizer_command EFFECT_CMD_SET_PARAM cmdSize %d pCmdData %p, *replySize %d, pReplyData %p", cmdSize, pCmdData, *replySize, pReplyData);
588 if (pCmdData == NULL || cmdSize < (int)(sizeof(effect_param_t) + sizeof(int32_t)) ||
589 pReplyData == NULL || *replySize != sizeof(int32_t)) {
590 return -EINVAL;
591 }
592 effect_param_t *p = (effect_param_t *) pCmdData;
593 *(int *)pReplyData = android::Equalizer_setParameter(pEqualizer, (int32_t *)p->data,
594 p->data + p->psize);
595 } break;
Eric Laurentffe9c252010-06-23 17:38:20 -0700596 case EFFECT_CMD_ENABLE:
597 case EFFECT_CMD_DISABLE:
598 if (pReplyData == NULL || *replySize != sizeof(int)) {
599 return -EINVAL;
600 }
601 *(int *)pReplyData = 0;
602 break;
603 case EFFECT_CMD_SET_DEVICE:
604 case EFFECT_CMD_SET_VOLUME:
605 case EFFECT_CMD_SET_AUDIO_MODE:
606 break;
Eric Laurent135ad072010-05-21 06:05:13 -0700607 default:
608 LOGW("Equalizer_command invalid command %d",cmdCode);
609 return -EINVAL;
610 }
611
612 return 0;
613}
614
615// effect_interface_t interface implementation for equalizer effect
616const struct effect_interface_s gEqualizerInterface = {
617 Equalizer_process,
618 Equalizer_command
619};
620
621