Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_EFFECTSFACTORYAPI_H_ |
| 18 | #define ANDROID_EFFECTSFACTORYAPI_H_ |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 19 | |
| 20 | #include <errno.h> |
| 21 | #include <stdint.h> |
| 22 | #include <sys/types.h> |
Eric Laurent | 0fb66c2 | 2011-05-17 19:16:02 -0700 | [diff] [blame] | 23 | #include <hardware/audio_effect.h> |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 24 | |
| 25 | #if __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | |
| 29 | ///////////////////////////////////////////////// |
| 30 | // Effect factory interface |
| 31 | ///////////////////////////////////////////////// |
| 32 | |
| 33 | //////////////////////////////////////////////////////////////////////////////// |
| 34 | // |
| 35 | // Function: EffectQueryNumberEffects |
| 36 | // |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 37 | // Description: Returns the number of different effects in all loaded libraries. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 38 | // Each effect must have a different effect uuid (see |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 39 | // effect_descriptor_t). This function together with EffectQueryEffect() |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 40 | // is used to enumerate all effects present in all loaded libraries. |
| 41 | // Each time EffectQueryNumberEffects() is called, the factory must |
| 42 | // reset the index of the effect descriptor returned by next call to |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 43 | // EffectQueryEffect() to restart enumeration from the beginning. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 44 | // |
| 45 | // Input/Output: |
| 46 | // pNumEffects: address where the number of effects should be returned. |
| 47 | // |
| 48 | // Output: |
| 49 | // returned value: 0 successful operation. |
| 50 | // -ENODEV factory failed to initialize |
| 51 | // -EINVAL invalid pNumEffects |
| 52 | // *pNumEffects: updated with number of effects in factory |
| 53 | // |
| 54 | //////////////////////////////////////////////////////////////////////////////// |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 55 | int EffectQueryNumberEffects(uint32_t *pNumEffects); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 56 | |
| 57 | //////////////////////////////////////////////////////////////////////////////// |
| 58 | // |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 59 | // Function: EffectQueryEffect |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 60 | // |
| 61 | // Description: Returns a descriptor of the next available effect. |
| 62 | // See effect_descriptor_t for a details on effect descriptor. |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 63 | // This function together with EffectQueryNumberEffects() is used to enumerate all |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 64 | // effects present in all loaded libraries. The enumeration sequence is: |
| 65 | // EffectQueryNumberEffects(&num_effects); |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 66 | // for (i = 0; i < num_effects; i++) |
| 67 | // EffectQueryEffect(i,...); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 68 | // |
| 69 | // Input/Output: |
| 70 | // pDescriptor: address where to return the effect descriptor. |
| 71 | // |
| 72 | // Output: |
| 73 | // returned value: 0 successful operation. |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 74 | // -ENOENT no more effect available |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 75 | // -ENODEV factory failed to initialize |
| 76 | // -EINVAL invalid pDescriptor |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 77 | // -ENOSYS effect list has changed since last execution of EffectQueryNumberEffects() |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 78 | // *pDescriptor: updated with the effect descriptor. |
| 79 | // |
| 80 | //////////////////////////////////////////////////////////////////////////////// |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 81 | int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 82 | |
| 83 | //////////////////////////////////////////////////////////////////////////////// |
| 84 | // |
| 85 | // Function: EffectCreate |
| 86 | // |
| 87 | // Description: Creates an effect engine of the specified type and returns an |
| 88 | // effect control interface on this engine. The function will allocate the |
| 89 | // resources for an instance of the requested effect engine and return |
Glenn Kasten | b3db213 | 2012-01-19 08:59:58 -0800 | [diff] [blame] | 90 | // a handle on the effect control interface. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 91 | // |
| 92 | // Input: |
| 93 | // pEffectUuid: pointer to the effect uuid. |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 94 | // sessionId: audio session to which this effect instance will be attached. All effects created |
| 95 | // with the same session ID are connected in series and process the same signal stream. |
| 96 | // Knowing that two effects are part of the same effect chain can help the library implement |
| 97 | // some kind of optimizations. |
| 98 | // ioId: identifies the output or input stream this effect is directed to at audio HAL. For future |
| 99 | // use especially with tunneled HW accelerated effects |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 100 | // |
| 101 | // Input/Output: |
Eric Laurent | 0fb66c2 | 2011-05-17 19:16:02 -0700 | [diff] [blame] | 102 | // pHandle: address where to return the effect handle. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 103 | // |
| 104 | // Output: |
| 105 | // returned value: 0 successful operation. |
| 106 | // -ENODEV factory failed to initialize |
Eric Laurent | 0fb66c2 | 2011-05-17 19:16:02 -0700 | [diff] [blame] | 107 | // -EINVAL invalid pEffectUuid or pHandle |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 108 | // -ENOENT no effect with this uuid found |
Eric Laurent | 0fb66c2 | 2011-05-17 19:16:02 -0700 | [diff] [blame] | 109 | // *pHandle: updated with the effect handle. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 110 | // |
| 111 | //////////////////////////////////////////////////////////////////////////////// |
Glenn Kasten | 6731333 | 2012-01-30 07:40:52 -0800 | [diff] [blame] | 112 | int EffectCreate(const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 113 | |
| 114 | //////////////////////////////////////////////////////////////////////////////// |
| 115 | // |
| 116 | // Function: EffectRelease |
| 117 | // |
Glenn Kasten | b3db213 | 2012-01-19 08:59:58 -0800 | [diff] [blame] | 118 | // Description: Releases the effect engine whose handle is given as argument. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 119 | // All resources allocated to this particular instance of the effect are |
| 120 | // released. |
| 121 | // |
| 122 | // Input: |
Glenn Kasten | b3db213 | 2012-01-19 08:59:58 -0800 | [diff] [blame] | 123 | // handle: handle on the effect interface to be released. |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 124 | // |
| 125 | // Output: |
| 126 | // returned value: 0 successful operation. |
| 127 | // -ENODEV factory failed to initialize |
Glenn Kasten | b3db213 | 2012-01-19 08:59:58 -0800 | [diff] [blame] | 128 | // -EINVAL invalid interface handle |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 129 | // |
| 130 | //////////////////////////////////////////////////////////////////////////////// |
Eric Laurent | 0fb66c2 | 2011-05-17 19:16:02 -0700 | [diff] [blame] | 131 | int EffectRelease(effect_handle_t handle); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 132 | |
| 133 | //////////////////////////////////////////////////////////////////////////////// |
| 134 | // |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 135 | // Function: EffectGetDescriptor |
| 136 | // |
| 137 | // Description: Returns the descriptor of the effect which uuid is pointed |
| 138 | // to by first argument. |
| 139 | // |
| 140 | // Input: |
| 141 | // pEffectUuid: pointer to the effect uuid. |
| 142 | // |
| 143 | // Input/Output: |
| 144 | // pDescriptor: address where to return the effect descriptor. |
| 145 | // |
| 146 | // Output: |
| 147 | // returned value: 0 successful operation. |
| 148 | // -ENODEV factory failed to initialize |
| 149 | // -EINVAL invalid pEffectUuid or pDescriptor |
Eric Laurent | 65b6545 | 2010-06-01 23:49:17 -0700 | [diff] [blame] | 150 | // -ENOENT no effect with this uuid found |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 151 | // *pDescriptor: updated with the effect descriptor. |
| 152 | // |
| 153 | //////////////////////////////////////////////////////////////////////////////// |
Glenn Kasten | 6731333 | 2012-01-30 07:40:52 -0800 | [diff] [blame] | 154 | int EffectGetDescriptor(const effect_uuid_t *pEffectUuid, effect_descriptor_t *pDescriptor); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 155 | |
| 156 | //////////////////////////////////////////////////////////////////////////////// |
| 157 | // |
| 158 | // Function: EffectIsNullUuid |
| 159 | // |
| 160 | // Description: Helper function to compare effect uuid to EFFECT_UUID_NULL |
| 161 | // |
| 162 | // Input: |
| 163 | // pEffectUuid: pointer to effect uuid to compare to EFFECT_UUID_NULL. |
| 164 | // |
| 165 | // Output: |
| 166 | // returned value: 0 if uuid is different from EFFECT_UUID_NULL. |
| 167 | // 1 if uuid is equal to EFFECT_UUID_NULL. |
| 168 | // |
| 169 | //////////////////////////////////////////////////////////////////////////////// |
Glenn Kasten | 6731333 | 2012-01-30 07:40:52 -0800 | [diff] [blame] | 170 | int EffectIsNullUuid(const effect_uuid_t *pEffectUuid); |
Eric Laurent | 5fe37c6 | 2010-05-21 06:05:13 -0700 | [diff] [blame] | 171 | |
| 172 | #if __cplusplus |
| 173 | } // extern "C" |
| 174 | #endif |
| 175 | |
| 176 | |
Eric Laurent | 53334cd | 2010-06-23 17:38:20 -0700 | [diff] [blame] | 177 | #endif /*ANDROID_EFFECTSFACTORYAPI_H_*/ |