summaryrefslogtreecommitdiffstats
path: root/media/libeffects/proxy/EffectProxy.h
blob: 046b93ef2d2c87e8da07b838b339828633ffdb31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <hardware/audio.h>
#include <hardware/audio_effect.h>
#include "EffectsFactory.h"

namespace android {
enum {
    SUB_FX_HOST,       // Index of HOST in the descriptor and handle arrays
                       // of the Proxy context
    SUB_FX_OFFLOAD,    // Index of OFFLOAD in the descriptor and handle arrays
                       // of the Proxy context
    SUB_FX_COUNT       // The number of sub effects for a Proxy(1 HW, 1 SW)
};
#if __cplusplus
extern "C" {
#endif

int EffectProxyCreate(const effect_uuid_t *uuid,
                          int32_t             sessionId,
                          int32_t             ioId,
                          effect_handle_t  *pHandle);
int EffectProxyRelease(effect_handle_t handle);
int EffectProxyGetDescriptor(const effect_uuid_t *uuid,
                                 effect_descriptor_t *pDescriptor);
/* Effect Control Interface Implementation: Process */
int Effect_process(effect_handle_t     self,
                            audio_buffer_t         *inBuffer,
                            audio_buffer_t         *outBuffer);

/* Effect Control Interface Implementation: Command */
int Effect_command(effect_handle_t  self,
                            uint32_t            cmdCode,
                            uint32_t            cmdSize,
                            void                *pCmdData,
                            uint32_t            *replySize,
                            void                *pReplyData);
int Effect_getDescriptor(effect_handle_t   self,
                       effect_descriptor_t *pDescriptor);

const struct effect_interface_s gEffectInterface = {
  Effect_process,
  Effect_command,
  Effect_getDescriptor,
  NULL,
};

#define PROXY_REPLY_SIZE_MAX     (64 * 1024) // must be power of two
#define PROXY_REPLY_SIZE_DEFAULT 32          // must be power of two

struct EffectContext {
  const struct effect_interface_s  *common_itfe; // Holds the itfe of the Proxy
  sub_effect_entry_t** sube;                     // Points to the sub effects
  effect_descriptor_t*  desc;                    // Points to the sub effect descriptors
  audio_effect_library_t**  aeli;                // Points to the sub effect aeli
  effect_handle_t       eHandle[SUB_FX_COUNT];   // The effect handles of the sub effects
  int                   index;       // The index that is currently active - HOST or OFFLOAD
  int32_t               sessionId;   // The sessiond in which the effect is created.
                                     // Stored in context to pass on to sub effect creation
  int32_t               ioId;        // The ioId in which the effect is created.
                                     // Stored in context to pass on to sub effect creation
  effect_uuid_t         uuid;        // UUID of the Proxy
  char*                 replyData;   // temporary buffer for non active sub effect command reply
  uint32_t              replySize;   // current size of temporary reply buffer
};

#if __cplusplus
}  // extern "C"
#endif
} //namespace android