EffectDownmix.h revision 6035cb5a61a7606cc8e4ecddec32b2eb37a9fd56
1/* 2 * Copyright (C) 2012 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#ifndef ANDROID_EFFECTDOWNMIX_H_ 18#define ANDROID_EFFECTDOWNMIX_H_ 19 20#include <audio_effects/effect_downmix.h> 21#include <audio_utils/primitives.h> 22#include <system/audio.h> 23 24/*------------------------------------ 25 * definitions 26 *------------------------------------ 27*/ 28 29#define DOWNMIX_OUTPUT_CHANNELS AUDIO_CHANNEL_OUT_STEREO 30 31typedef enum { 32 DOWNMIX_STATE_UNINITIALIZED, 33 DOWNMIX_STATE_INITIALIZED, 34 DOWNMIX_STATE_ACTIVE, 35} downmix_state_t; 36 37/* parameters for each downmixer */ 38typedef struct { 39 downmix_state_t state; 40 downmix_type_t type; 41 bool apply_volume_correction; 42 uint8_t input_channel_count; 43} downmix_object_t; 44 45 46typedef struct downmix_module_s { 47 const struct effect_interface_s *itfe; 48 effect_config_t config; 49 downmix_object_t context; 50} downmix_module_t; 51 52const uint32_t kSides = AUDIO_CHANNEL_OUT_SIDE_LEFT | AUDIO_CHANNEL_OUT_SIDE_RIGHT; 53const uint32_t kBacks = AUDIO_CHANNEL_OUT_BACK_LEFT | AUDIO_CHANNEL_OUT_BACK_RIGHT; 54const uint32_t kUnsupported = 55 AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER | AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | 56 AUDIO_CHANNEL_OUT_TOP_CENTER | 57 AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT | 58 AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER | 59 AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT | 60 AUDIO_CHANNEL_OUT_TOP_BACK_LEFT | 61 AUDIO_CHANNEL_OUT_TOP_BACK_CENTER | 62 AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT; 63 64/*------------------------------------ 65 * Effect API 66 *------------------------------------ 67*/ 68int32_t DownmixLib_Create(const effect_uuid_t *uuid, 69 int32_t sessionId, 70 int32_t ioId, 71 effect_handle_t *pHandle); 72int32_t DownmixLib_Release(effect_handle_t handle); 73int32_t DownmixLib_GetDescriptor(const effect_uuid_t *uuid, 74 effect_descriptor_t *pDescriptor); 75 76static int Downmix_Process(effect_handle_t self, 77 audio_buffer_t *inBuffer, 78 audio_buffer_t *outBuffer); 79static int Downmix_Command(effect_handle_t self, 80 uint32_t cmdCode, 81 uint32_t cmdSize, 82 void *pCmdData, 83 uint32_t *replySize, 84 void *pReplyData); 85static int Downmix_GetDescriptor(effect_handle_t self, 86 effect_descriptor_t *pDescriptor); 87 88 89/*------------------------------------ 90 * internal functions 91 *------------------------------------ 92*/ 93int Downmix_Init(downmix_module_t *pDwmModule); 94int Downmix_Configure(downmix_module_t *pDwmModule, effect_config_t *pConfig, bool init); 95int Downmix_Reset(downmix_object_t *pDownmixer, bool init); 96int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, size_t size, void *pValue); 97int Downmix_getParameter(downmix_object_t *pDownmixer, int32_t param, size_t *pSize, void *pValue); 98 99void Downmix_foldFromQuad(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); 100void Downmix_foldFromSurround(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); 101void Downmix_foldFrom5Point1(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); 102void Downmix_foldFrom7Point1(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); 103bool Downmix_foldGeneric( 104 uint32_t mask, int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate); 105 106#endif /*ANDROID_EFFECTDOWNMIX_H_*/ 107