1/* 2 * Copyright (C) 2013 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#include <hardware/audio.h> 18#include <hardware/audio_effect.h> 19#include "EffectsFactory.h" 20 21namespace android { 22enum { 23 SUB_FX_HOST, // Index of HOST in the descriptor and handle arrays 24 // of the Proxy context 25 SUB_FX_OFFLOAD, // Index of OFFLOAD in the descriptor and handle arrays 26 // of the Proxy context 27 SUB_FX_COUNT // The number of sub effects for a Proxy(1 HW, 1 SW) 28}; 29#if __cplusplus 30extern "C" { 31#endif 32 33int EffectProxyCreate(const effect_uuid_t *uuid, 34 int32_t sessionId, 35 int32_t ioId, 36 effect_handle_t *pHandle); 37int EffectProxyRelease(effect_handle_t handle); 38int EffectProxyGetDescriptor(const effect_uuid_t *uuid, 39 effect_descriptor_t *pDescriptor); 40/* Effect Control Interface Implementation: Process */ 41int Effect_process(effect_handle_t self, 42 audio_buffer_t *inBuffer, 43 audio_buffer_t *outBuffer); 44 45/* Effect Control Interface Implementation: Command */ 46int Effect_command(effect_handle_t self, 47 uint32_t cmdCode, 48 uint32_t cmdSize, 49 void *pCmdData, 50 uint32_t *replySize, 51 void *pReplyData); 52int Effect_getDescriptor(effect_handle_t self, 53 effect_descriptor_t *pDescriptor); 54 55const struct effect_interface_s gEffectInterface = { 56 Effect_process, 57 Effect_command, 58 Effect_getDescriptor, 59 NULL, 60}; 61 62#define PROXY_REPLY_SIZE_MAX (64 * 1024) // must be power of two 63#define PROXY_REPLY_SIZE_DEFAULT 32 // must be power of two 64 65struct EffectContext { 66 const struct effect_interface_s *common_itfe; // Holds the itfe of the Proxy 67 sub_effect_entry_t** sube; // Points to the sub effects 68 effect_descriptor_t* desc; // Points to the sub effect descriptors 69 audio_effect_library_t** aeli; // Points to the sub effect aeli 70 effect_handle_t eHandle[SUB_FX_COUNT]; // The effect handles of the sub effects 71 int index; // The index that is currently active - HOST or OFFLOAD 72 int32_t sessionId; // The sessiond in which the effect is created. 73 // Stored in context to pass on to sub effect creation 74 int32_t ioId; // The ioId in which the effect is created. 75 // Stored in context to pass on to sub effect creation 76 effect_uuid_t uuid; // UUID of the Proxy 77 char* replyData; // temporary buffer for non active sub effect command reply 78 uint32_t replySize; // current size of temporary reply buffer 79}; 80 81#if __cplusplus 82} // extern "C" 83#endif 84} //namespace android 85