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