diff options
22 files changed, 195 insertions, 91 deletions
diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.c b/4a-hal-utilities/4a-hal-utilities-alsa-data.c new file mode 100644 index 0000000..ef2967a --- /dev/null +++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 "IoT.bzh" + * Author Jonathan Aillet <jonathan.aillet@iot.bzh> + * + * 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. + */ + +#define _GNU_SOURCE + +#include <stdio.h> + +#include <afb-definitions.h> + +#include "4a-hal-utilities-alsa-data.h" + +/******************************************************************************* + * Free contents of 'CtlHalAlsaMapT' data structure * + ******************************************************************************/ + +uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap) +{ + int idx; + + if(! alsaCtlsMap) + return -1; + + if(alsaCtlsMap->ctlsCount > 0 && ! alsaCtlsMap->ctls) + return -2; + + for(idx = 0; idx < alsaCtlsMap->ctlsCount; idx++) { + free(alsaCtlsMap->ctls[idx].action); + free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.enums); + free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.dbscale); + } + + free(alsaCtlsMap->ctls); + + free(alsaCtlsMap); + + return 0; +}
\ No newline at end of file diff --git a/4a-hal-utilities/4a-hal-utilities-alsa-data.h b/4a-hal-utilities/4a-hal-utilities-alsa-data.h new file mode 100644 index 0000000..5a998ae --- /dev/null +++ b/4a-hal-utilities/4a-hal-utilities-alsa-data.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2019 "IoT.bzh" +* Author Jonathan Aillet <jonathan.aillet@iot.bzh> +* +* 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. +*/ + +#ifndef _HAL_UTILITIES_ALSA_DATA_INCLUDE_ +#define _HAL_UTILITIES_ALSA_DATA_INCLUDE_ + +#include <stdio.h> + +#include <json-c/json.h> + +#include <alsa/asoundlib.h> + +#include <ctl-config.h> + +struct CtlHalAlsaDBScale { + int min; + int max; + int step; + int mute; +}; + +struct CtlHalAlsaCtlProperties { + snd_ctl_elem_type_t type; + int count; + int minval; + int maxval; + int step; + // TBD JAI : use them + const char **enums; + struct CtlHalAlsaDBScale *dbscale; +}; + +struct CtlHalAlsaCtl { + char *name; + int numid; + int value; + struct CtlHalAlsaCtlProperties alsaCtlProperties; + struct CtlHalAlsaCtlProperties *alsaCtlCreation; +}; + +struct CtlHalAlsaMap { + const char *uid; + char *info; + AFB_EventT alsaControlEvent; + struct CtlHalAlsaCtl ctl; + json_object *actionJ; + CtlActionT *action; +}; + +struct CtlHalAlsaMapT { + struct CtlHalAlsaMap *ctls; + unsigned int ctlsCount; +}; + +// Free contents of 'CtlHalAlsaMapT' data structure +uint8_t HalUtlFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap); + +#endif /* _HAL_UTILITIES_ALSA_DATA_INCLUDE_ */
\ No newline at end of file diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c index 40581ef..40581ef 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c +++ b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.c diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h index 923ca6b..923ca6b 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h +++ b/4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal-utilities/4a-hal-utilities-data.c index f3ee028..4bb19a8 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c +++ b/4a-hal-utilities/4a-hal-utilities-data.c @@ -23,8 +23,7 @@ #include <wrap-json.h> #include "4a-hal-utilities-data.h" - -#include "../4a-hal-controllers/4a-hal-controllers-alsacore-link.h" +#include "4a-hal-utilities-alsa-data.h" /******************************************************************************* * Specfic Hal controller streams data handling functions * @@ -124,7 +123,7 @@ int8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, st else { HalUtlRemoveAllCtlHalStreamsData(&matchingApi->ctlHalSpecificData->ctlHalStreamsData); - HalCtlsFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT); + HalUtlFreeAlsaCtlsMap(matchingApi->ctlHalSpecificData->ctlHalAlsaMapT); free(matchingApi->ctlHalSpecificData); } diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal-utilities/4a-hal-utilities-data.h index 01b3db7..031fa9b 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h +++ b/4a-hal-utilities/4a-hal-utilities-data.h @@ -26,7 +26,7 @@ #include <ctl-config.h> -#include "../4a-hal-controllers/4a-hal-controllers-alsacore-link.h" +#include "4a-hal-utilities-alsa-data.h" // Enum for sharing hal (controller or external) status enum HalStatus { diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c b/4a-hal-utilities/4a-hal-utilities-verbs-loader.c index f557f4c..f557f4c 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.c +++ b/4a-hal-utilities/4a-hal-utilities-verbs-loader.c diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h b/4a-hal-utilities/4a-hal-utilities-verbs-loader.h index 2bfa1cd..2bfa1cd 100644 --- a/4a-hal/4a-hal-utilities/4a-hal-utilities-verbs-loader.h +++ b/4a-hal-utilities/4a-hal-utilities-verbs-loader.h diff --git a/4a-hal-utilities/CMakeLists.txt b/4a-hal-utilities/CMakeLists.txt new file mode 100644 index 0000000..a45cb2c --- /dev/null +++ b/4a-hal-utilities/CMakeLists.txt @@ -0,0 +1,40 @@ +########################################################################### +# Copyright 2015, 2016, 2017, 2018, 2019 IoT.bzh +# +# author: Fulup Ar Foll <fulup@iot.bzh> +# contrib: Jonathan Aillet <jonathan.aillet@iot.bzh> +# +# 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. +########################################################################### + +# Add target to project dependency list +PROJECT_TARGET_ADD(4a-hal-utilities) + + # Define project Targets + ADD_LIBRARY(${TARGET_NAME} STATIC + 4a-hal-utilities-alsa-data.c + 4a-hal-utilities-appfw-responses-handler.c + 4a-hal-utilities-data.c + 4a-hal-utilities-verbs-loader.c) + + # Library dependencies (include updates automatically) + TARGET_LINK_LIBRARIES(${TARGET_NAME} + afb-helpers + ctl-utilities + ${link_libraries} + ) + + # Define target includes for this target client + TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ) diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c index 4ae5a13..f1f99a6 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.c @@ -24,10 +24,13 @@ #include <alsa/asoundlib.h> +#include <afb-definitions.h> + #include <ctl-config.h> -#include "../4a-hal-utilities/4a-hal-utilities-data.h" -#include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h" +#include "4a-hal-utilities-alsa-data.h" +#include "4a-hal-utilities-data.h" +#include "4a-hal-utilities-appfw-responses-handler.h" #include "4a-hal-controllers-alsacore-link.h" #include "4a-hal-controllers-value-handler.h" @@ -64,33 +67,6 @@ snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label) } /******************************************************************************* - * Free contents of 'CtlHalAlsaMapT' data structure * - ******************************************************************************/ - -uint8_t HalCtlsFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap) -{ - int idx; - - if(! alsaCtlsMap) - return -1; - - if(alsaCtlsMap->ctlsCount > 0 && ! alsaCtlsMap->ctls) - return -2; - - for(idx = 0; idx < alsaCtlsMap->ctlsCount; idx++) { - free(alsaCtlsMap->ctls[idx].action); - free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.enums); - free(alsaCtlsMap->ctls[idx].ctl.alsaCtlProperties.dbscale); - } - - free(alsaCtlsMap->ctls); - - free(alsaCtlsMap); - - return 0; -} - -/******************************************************************************* * HAL controllers alsacore calls funtions * ******************************************************************************/ diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h index 5d687aa..351ad59 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-alsacore-link.h @@ -26,6 +26,8 @@ #include <ctl-config.h> +#include "4a-hal-utilities-alsa-data.h" + #define ALSACORE_API "alsacore" #define ALSACORE_SUBSCRIBE_VERB "subscribe" #define ALSACORE_GETINFO_VERB "infoget" @@ -33,52 +35,9 @@ #define ALSACORE_CTLSET_VERB "ctlset" #define ALSACORE_ADDCTL_VERB "addcustomctl" -struct CtlHalAlsaDBScale { - int min; - int max; - int step; - int mute; -}; - -struct CtlHalAlsaCtlProperties { - snd_ctl_elem_type_t type; - int count; - int minval; - int maxval; - int step; - // TBD JAI : use them - const char **enums; - struct CtlHalAlsaDBScale *dbscale; -}; - -struct CtlHalAlsaCtl { - char *name; - int numid; - int value; - struct CtlHalAlsaCtlProperties alsaCtlProperties; - struct CtlHalAlsaCtlProperties *alsaCtlCreation; -}; - -struct CtlHalAlsaMap { - const char *uid; - char *info; - AFB_EventT alsaControlEvent; - struct CtlHalAlsaCtl ctl; - json_object *actionJ; - CtlActionT *action; -}; - -struct CtlHalAlsaMapT { - struct CtlHalAlsaMap *ctls; - unsigned int ctlsCount; -}; - // Alsa control types map from string function snd_ctl_elem_type_t HalCtlsMapsAlsaTypeToEnum(const char *label); -// Free contents of 'CtlHalAlsaMapT' data structure -uint8_t HalCtlsFreeAlsaCtlsMap(struct CtlHalAlsaMapT *alsaCtlsMap); - // HAL controllers alsacore calls funtions int HalCtlsGetCardIdByCardPath(AFB_ApiT apiHandle, char *devPath); int HalCtlsSubscribeToAlsaCardEvent(AFB_ApiT apiHandle, char *cardId); diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c index 4cac346..72515e7 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c @@ -27,7 +27,7 @@ #include <ctl-config.h> -#include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h" +#include "4a-hal-utilities-verbs-loader.h" #include "4a-hal-controllers-api-loader.h" #include "4a-hal-controllers-alsacore-link.h" diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h index 70e61cd..f1d3bfd 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.h @@ -22,7 +22,7 @@ #include <afb-definitions.h> -#include "../4a-hal-utilities/4a-hal-utilities-data.h" +#include "4a-hal-utilities-data.h" // Verbs that can be use to create api int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGlobalData); diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c index a8d0ee4..ba2454a 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-cb.c @@ -22,8 +22,10 @@ #include <wrap-json.h> -#include "../4a-hal-utilities/4a-hal-utilities-data.h" -#include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h" +#include <afb-definitions.h> + +#include "4a-hal-utilities-data.h" +#include "4a-hal-utilities-appfw-responses-handler.h" #include "4a-hal-controllers-cb.h" #include "4a-hal-controllers-alsacore-link.h" diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c index 807dbb8..fd42899 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.c @@ -22,9 +22,11 @@ #include <wrap-json.h> -#include "../4a-hal-utilities/4a-hal-utilities-appfw-responses-handler.h" -#include "../4a-hal-utilities/4a-hal-utilities-data.h" -#include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h" +#include <afb-definitions.h> + +#include "4a-hal-utilities-appfw-responses-handler.h" +#include "4a-hal-utilities-data.h" +#include "4a-hal-utilities-verbs-loader.h" #include "../4a-hal-manager/4a-hal-manager.h" diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h index 165b70d..9189664 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-mixer-link.h @@ -24,7 +24,7 @@ #include "afb-helpers-utils.h" -#include "../4a-hal-utilities/4a-hal-utilities-data.h" +#include "4a-hal-utilities-data.h" #define MIXER_ATTACH_VERB "attach" #define MIXER_INFO_VERB "info" diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c index 7a3dedd..4273def 100644 --- a/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c +++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-value-handler.c @@ -25,6 +25,8 @@ #include <wrap-json.h> +#include <afb-definitions.h> + #include "4a-hal-controllers-value-handler.h" #include "4a-hal-controllers-alsacore-link.h" diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c index ae86474..ba01394 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c @@ -22,7 +22,7 @@ #include <wrap-json.h> -#include "../4a-hal-utilities/4a-hal-utilities-data.h" +#include "4a-hal-utilities-data.h" #include "4a-hal-manager-cb.h" #include "4a-hal-manager-events.h" diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-events.c b/4a-hal/4a-hal-manager/4a-hal-manager-events.c index 96299a0..2b58501 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager-events.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager-events.c @@ -22,7 +22,8 @@ #include <wrap-json.h> -#include "../4a-hal-utilities/4a-hal-utilities-data.h" +#include "4a-hal-utilities-data.h" + #include "4a-hal-manager-events.h" // TBD JAI: implement events handlers functions
\ No newline at end of file diff --git a/4a-hal/4a-hal-manager/4a-hal-manager.c b/4a-hal/4a-hal-manager/4a-hal-manager.c index 43fbd49..c510d17 100644 --- a/4a-hal/4a-hal-manager/4a-hal-manager.c +++ b/4a-hal/4a-hal-manager/4a-hal-manager.c @@ -22,8 +22,9 @@ #include <afb-definitions.h> -#include "../4a-hal-utilities/4a-hal-utilities-data.h" -#include "../4a-hal-utilities/4a-hal-utilities-verbs-loader.h" +#include "4a-hal-utilities-data.h" +#include "4a-hal-utilities-verbs-loader.h" + #include "../4a-hal-controllers/4a-hal-controllers-api-loader.h" #include "4a-hal-manager.h" diff --git a/4a-hal/CMakeLists.txt b/4a-hal/CMakeLists.txt index 2968f23..5392075 100644 --- a/4a-hal/CMakeLists.txt +++ b/4a-hal/CMakeLists.txt @@ -23,9 +23,6 @@ PROJECT_TARGET_ADD(4a-hal) # Define project Targets add_library(${TARGET_NAME} MODULE - ${TARGET_NAME}-utilities/${TARGET_NAME}-utilities-appfw-responses-handler.c - ${TARGET_NAME}-utilities/${TARGET_NAME}-utilities-data.c - ${TARGET_NAME}-utilities/${TARGET_NAME}-utilities-verbs-loader.c ${TARGET_NAME}-manager/${TARGET_NAME}-manager.c ${TARGET_NAME}-manager/${TARGET_NAME}-manager-cb.c ${TARGET_NAME}-manager/${TARGET_NAME}-manager-events.c @@ -48,6 +45,7 @@ PROJECT_TARGET_ADD(4a-hal) TARGET_LINK_LIBRARIES(${TARGET_NAME} afb-helpers ctl-utilities + 4a-hal-utilities ${link_libraries} ) diff --git a/plugins/lib/bluealsa/CMakeLists.txt b/plugins/lib/bluealsa/CMakeLists.txt index 699ccc4..28a903a 100644 --- a/plugins/lib/bluealsa/CMakeLists.txt +++ b/plugins/lib/bluealsa/CMakeLists.txt @@ -39,6 +39,7 @@ PROJECT_TARGET_ADD(hal-bluealsa) TARGET_LINK_LIBRARIES(${TARGET_NAME} afb-helpers ctl-utilities + 4a-hal-utilities ${BLUEALSA_LIBRARIES} ${link_libraries} ) |