diff options
author | Tai Vuong <tvuong@audiokinetic.com> | 2017-10-04 14:21:28 -0400 |
---|---|---|
committer | Tai Vuong <tvuong@audiokinetic.com> | 2017-10-04 14:21:28 -0400 |
commit | 539f65bb5ad87238422a5ca26c5b524c3be44bd1 (patch) | |
tree | 01fa955edf1e9b597a4a4247b3a35390c7b6ddbc /src/ahl-binding.h | |
parent | d69dc9732886074e9f400961b500e70d5c8305d7 (diff) |
Post AudioWorkshop Work phase v1
Diffstat (limited to 'src/ahl-binding.h')
-rw-r--r-- | src/ahl-binding.h | 106 |
1 files changed, 70 insertions, 36 deletions
diff --git a/src/ahl-binding.h b/src/ahl-binding.h index 2422963..508ca0a 100644 --- a/src/ahl-binding.h +++ b/src/ahl-binding.h @@ -29,45 +29,71 @@ #define PUBLIC #endif -/////////////// Binding private information ////////////////// +#define AHL_POLICY_ACCEPT 1 +#define AHL_POLICY_REJECT 0 -#define AUDIOHL_MAX_DEVICE_URI_LENGTH 256 -#define AUDIOHL_MAX_DEVICE_NAME_LENGTH 256 -#define AUDIOHL_MAX_AUDIOROLE_LENGTH 128 -#define AUDIOHL_MAX_HALAPINAME_LENGTH 64 -#define AUDIOHL_POLICY_ACCEPT 1 -#define AUDIOHL_POLICY_REJECT 0 +#define AHL_UNDEFINED -1 + +typedef int endpointID_t; +typedef int streamID_t; + +typedef enum EndpointSelectionMode { + AHL_ENDPOINTSELMODE_AUTO = 0, // Automatic endpoint selection based on config priority + AHL_ENDPOINTSELMODE_MANUAL, // Explicit endpoint selection + AHL_ENDPOINTSELMODEMAXVALUE, // Enum count, keep at the end +} EndpointSelectionModeT; + +typedef struct AudioFormat { + int sampleRate; // Sample rate + int numChannels; // Number of channels + SampleTypeT sampleType; // Sample type + // TODO: Interleaving? + // TODO: Sample sub format? +} AudioFormatT; + +typedef struct AlsaDeviceInfo { + int cardNum; // HW card number + int deviceNum; // HW device number + int subDeviceNum; // HW sub device number +} AlsaDeviceInfoT; typedef struct EndpointInfo { - endpointID_t endpointID; // Unique endpoint ID (per type) - EndpointTypeT type; // Source or sink device - char deviceName[AUDIOHL_MAX_DEVICE_NAME_LENGTH]; // Device name for applications to display - char deviceURI[AUDIOHL_MAX_DEVICE_URI_LENGTH]; // Associated URI - DeviceURITypeT deviceURIType; // Device URI type (includes audio domain information) - char audioRole[AUDIOHL_MAX_AUDIOROLE_LENGTH]; // Audio role that registered this endpoint -> private - char halAPIName[AUDIOHL_MAX_AUDIOROLE_LENGTH]; // HAL associated with the device (for volume control) -> private - int cardNum; // HW card number -> private - int deviceNum; // HW device number -> private - int subDeviceNum; // HW sub device number -> private - // Cached endpoint properties - GHashTable * pStatesHT; // Keep all known states in key value pairs + endpointID_t endpointID; // Unique endpoint ID (per type) + EndpointTypeT type; // Source or sink device + GString * gsDeviceName; // Device name for applications to display + GString * gsDeviceURI; // Associated URI + DeviceURITypeT deviceURIType; // Device URI type (includes audio domain information) + GString * gsAudioRole; // Audio role that registered this endpoint + GString * gsHALAPIName; // HAL associated with the device (for volume control) + AlsaDeviceInfoT alsaInfo; // ALSA specific device information + AudioFormatT format; // Preferred audio format supported (later could be array of supported formats) + int iVolume; // Storage for current endpoint volume (policy effected). Target volume during ramping? + GHashTable * pPropTable; // Storage for array of properties (policy effected) } EndpointInfoT; typedef struct StreamInfo { - streamID_t streamID; - EndpointInfoT endpointInfo; + streamID_t streamID; // Stream unique ID + EndpointInfoT * pEndpointInfo; // Associated endpoint information + StreamStateT streamState; // Stream activity state + StreamMuteT streamMute; // Stream mute state + struct afb_event streamStateEvent; // Stream specific event for stream state changes + EndpointSelectionModeT endpointSelMode; // Automatic (priority based) or manual endpoint selection } StreamInfoT; // Parts of the context that are visible to the policy (for state based decisions) typedef struct AHLPolicyCtx { GPtrArray * pSourceEndpoints; // Array of source end points for each audio role (GArray*) GPtrArray * pSinkEndpoints; // Array of sink end points for each audio role (GArray*) - GArray * pRolePriority; // List of role priorities (int). TODO: Should be hash table with role name as key + GPtrArray * pEventList; // Event list per audio roles (GArray*) + GHashTable * pRolePriority; // List of role priorities (int). + GArray * pInterruptBehavior; // List of interrupt behavior per audio role (int/enum). GArray * pAudioRoles; // List of audio roles (GString) GArray * pActiveStreams; // List of active streams (StreamInfoT) - int iNumberRoles; // Number of audio roles from configuration - // TODO: Global properties -> exposed to policy + int iNumberRoles; // Number of audio roles from configuration + struct afb_event propertyEvent; // AGL event used when property changes + struct afb_event volumeEvent; // AGL event used when volume changes + struct afb_event postEvent; // AGL event used on post event call } AHLPolicyCtxT; // Global binding context @@ -77,23 +103,31 @@ typedef struct AHLCtx { endpointID_t nextSinkEndpointID; // Counter to assign new ID endpointID_t nextStreamID; // Counter to assign new ID GArray * pHALList; // List of HAL dependencies - GHashTable * pDefaultStatesHT; // List of states and default values known to configuration } AHLCtxT; +// ahl-binding.c PUBLIC int AhlBindingInit(); +PUBLIC void AhlOnEvent(const char *evtname, json_object *eventJ); + // ahl-deviceenum.c -PUBLIC int EnumerateSources(json_object * in_jSourceArray, int in_iRoleIndex, char * in_pRoleName); -PUBLIC int EnumerateSinks(json_object * in_jSinkArray, int in_iRoleIndex, char * in_pRoleName); +int EnumerateSources(json_object * in_jSourceArray, int in_iRoleIndex, char * in_pRoleName); +int EnumerateSinks(json_object * in_jSinkArray, int in_iRoleIndex, char * in_pRoleName); +void TermEndpoints(); // ahl-config.c -PUBLIC int ParseHLBConfig(); +int ParseHLBConfig(); // ahl-policy.c -PUBLIC int Policy_OpenStream(char *pAudioRole, EndpointTypeT endpointType, endpointID_t endpointID); -PUBLIC int Policy_SetVolume(EndpointTypeT endpointType, endpointID_t endpointID, char *volumeStr, int rampTimeMS); -PUBLIC int Policy_SetProperty(EndpointTypeT endpointType, endpointID_t endpointID, char *propertyName, char *propValueStr, int rampTimeMS); -PUBLIC int Policy_SetState(EndpointTypeT endpointType, endpointID_t endpointID, char *pStateName, char *pStateValue); -PUBLIC int Policy_PostSoundEvent(char *eventName, char *audioRole, char *mediaName, void *audioContext); -PUBLIC int Policy_AudioDeviceChange(); - -#define AUDIOHL_MAXHALCONTROLNAME_LENGTH 128 +int Policy_Endpoint_Property_Init(EndpointInfoT * io_pEndpointInfo); +int Policy_Init(); +void Policy_Term(); +int Policy_OpenStream(char *pAudioRole, EndpointTypeT endpointType, endpointID_t endpointID); +int Policy_CloseStream(streamID_t streamID); +int Policy_SetStreamState(streamID_t streamID, StreamStateT streamState ); +int Policy_SetStreamMute(streamID_t streamID, StreamMuteT streamMute); +int Policy_SetVolume(EndpointTypeT endpointType, endpointID_t endpointID, char *volumeStr); +int Policy_SetProperty(EndpointTypeT endpointType, endpointID_t endpointID, char *propertyName, char *propValueStr); +int Policy_PostEvent(char *eventName, char *audioRole, char *mediaName, void *audioContext); +int Policy_AudioDeviceChange(); + + #endif // AHL_BINDING_INCLUDE |