diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2018-04-29 20:52:58 +0200 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2018-04-29 20:52:58 +0200 |
commit | f83d651392b8556248600f2b1360b9306b845c3d (patch) | |
tree | 69498e049145fbafaa2e20dcd0b3005f44fb138d | |
parent | e26d497d74bf7e5926a84cf83d61857f27d75753 (diff) |
Initial push work in progress
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .gitmodules | 9 | ||||
-rw-r--r-- | CMakeLists.txt | 21 | ||||
-rw-r--r-- | README.md | 62 | ||||
m--------- | app-afb-helpers-submodule | 0 | ||||
m--------- | app-controller-submodule | 0 | ||||
-rw-r--r-- | conf.d/CMakeLists.txt | 22 | ||||
m--------- | conf.d/app-templates | 0 | ||||
-rwxr-xr-x | conf.d/autobuild/agl/autobuild | 67 | ||||
-rwxr-xr-x | conf.d/autobuild/linux/autobuild | 67 | ||||
-rw-r--r-- | conf.d/cmake/00-suse-osconfig.cmake | 2 | ||||
-rw-r--r-- | conf.d/cmake/config.cmake | 213 | ||||
-rw-r--r-- | conf.d/project/CMakeLists.txt | 22 | ||||
-rw-r--r-- | conf.d/project/etc/CMakeLists.txt | 31 | ||||
-rw-r--r-- | conf.d/project/etc/config-softmixer-4a.json | 81 | ||||
-rw-r--r-- | conf.d/project/etc/fiberdyme_hal_sample.json | 287 | ||||
-rw-r--r-- | conf.d/wgt/config.xml.in | 23 | ||||
-rw-r--r-- | conf.d/wgt/icon.png | bin | 0 -> 3934 bytes | |||
-rw-r--r-- | mixer-binding/CMakeLists.txt | 50 | ||||
-rw-r--r-- | mixer-binding/mixer-binding.c | 150 | ||||
-rw-r--r-- | mixer-binding/mixer-binding.h | 30 | ||||
-rw-r--r-- | nbproject/configurations.xml | 164 | ||||
-rw-r--r-- | nbproject/project.xml | 26 | ||||
-rw-r--r-- | plugins/CMakeLists.txt | 40 | ||||
-rw-r--r-- | plugins/alsa-router.c | 46 |
25 files changed, 1414 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8fa86ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build/ +/nbproject/private diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f6f0a14 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "conf.d/app-templates"] + path = conf.d/app-templates + url = https://gerrit.automotivelinux.org/gerrit/p/apps/app-templates.git +[submodule "app-afb-helpers-submodule"] + path = app-afb-helpers-submodule + url = https://gerrit.automotivelinux.org/gerrit/apps/app-afb-helpers-submodule +[submodule "app-controller-submodule"] + path = app-controller-submodule + url = https://gerrit.automotivelinux.org/gerrit/apps/app-controller-submodule diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b485097 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Romain Forlot <romain.forlot@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. +########################################################################### + +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) + +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) @@ -1 +1,61 @@ -# 4a-softmixer
\ No newline at end of file +# Controller Utilities + +* Object: Generic Controller Utilities to handle Policy, Small Business Logic, Glue in between components, ... +* Status: Release Candidate +* Author: Fulup Ar Foll fulup@iot.bzh +* Date : October-2017 + +## Usage + +0) Dependencies + +* AGL Application Framework + +1) Clone & build from source (temporally from github) + +```bash +git clone --recursive https://github.com/iotbzh/4a-softmixer +cd build +cmake .. +make +``` + +2) Activate ALSA loop driver + +```modprobe snd-aloop enable=1,1 index=4,5 id=loopback,softmix +``` + +3) Declare your controller config section in your binding + +```C +// CtlSectionT syntax: +// key: "section name in config file" +// loadCB: callback to process section +// handle: a void* pass to callback when processing section +static CtlSectionT ctlSections[]= { + {.key="plugins" , .loadCB= PluginConfig, .handle= &halCallbacks}, + {.key="onload" , .loadCB= OnloadConfig}, + {.key="halmap" , .loadCB= MapConfigLoad}, + {.key=NULL} +}; + +``` + +3) Do controller config parsing at binding pre-init + +```C + // check if config file exist + const char *dirList= getenv("CTL_CONFIG_PATH"); + if (!dirList) dirList=CONTROL_CONFIG_PATH; + + ctlConfig = CtlConfigLoad(dirList, ctlSections); + if (!ctlConfig) goto OnErrorExit; +``` + +4) Exec controller config during binding init + +```C + int err = CtlConfigExec (ctlConfig); +``` + +For sample usage look at https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps/app-controller-submodule.git diff --git a/app-afb-helpers-submodule b/app-afb-helpers-submodule new file mode 160000 +Subproject 27c0ffd6e475eba00aa8883a822a841a4555cf2 diff --git a/app-controller-submodule b/app-controller-submodule new file mode 160000 +Subproject 8ff0fe3c454ea32ba383a3cfa9c4e91237d6c49 diff --git a/conf.d/CMakeLists.txt b/conf.d/CMakeLists.txt new file mode 100644 index 0000000..28a0609 --- /dev/null +++ b/conf.d/CMakeLists.txt @@ -0,0 +1,22 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll <fulup@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. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) diff --git a/conf.d/app-templates b/conf.d/app-templates new file mode 160000 +Subproject 6e1a3c37e94f42f5307fd1fa749823b2d160a56 diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild new file mode 100755 index 0000000..83097ab --- /dev/null +++ b/conf.d/autobuild/agl/autobuild @@ -0,0 +1,67 @@ +#!/usr/bin/make -f +# Copyright (C) 2015, 2016 "IoT.bzh" +# Author "Romain Forlot" <romain.forlot@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. + +THISFILE := $(lastword $(MAKEFILE_LIST)) +BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target + +.PHONY: all clean distclean configure build package help update + +all: help + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build: compilation, link and prepare files for package into a widget" + @echo "- package: output a widget file '*.wgt'" + @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory" + @echo "" + @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +update: configure + @cmake --build ${BUILD_DIR} --target autobuild + +clean: + @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean + +distclean: + @rm -rf ${BUILD_DIR} + +configure: ${BUILD_DIR}/Makefile + +build: configure + @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all + +package: build + @mkdir -p ${BUILD_DIR}/$@/bin + @mkdir -p ${BUILD_DIR}/$@/etc + @mkdir -p ${BUILD_DIR}/$@/lib + @mkdir -p ${BUILD_DIR}/$@/htdocs + @mkdir -p ${BUILD_DIR}/$@/var + @cmake --build ${BUILD_DIR} --target widget + @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST} + +install: build + @cmake --build ${BUILD_DIR} --target install + +${BUILD_DIR}/Makefile: + @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} + @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..) diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild new file mode 100755 index 0000000..83097ab --- /dev/null +++ b/conf.d/autobuild/linux/autobuild @@ -0,0 +1,67 @@ +#!/usr/bin/make -f +# Copyright (C) 2015, 2016 "IoT.bzh" +# Author "Romain Forlot" <romain.forlot@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. + +THISFILE := $(lastword $(MAKEFILE_LIST)) +BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target + +.PHONY: all clean distclean configure build package help update + +all: help + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build: compilation, link and prepare files for package into a widget" + @echo "- package: output a widget file '*.wgt'" + @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory" + @echo "" + @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +update: configure + @cmake --build ${BUILD_DIR} --target autobuild + +clean: + @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean + +distclean: + @rm -rf ${BUILD_DIR} + +configure: ${BUILD_DIR}/Makefile + +build: configure + @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all + +package: build + @mkdir -p ${BUILD_DIR}/$@/bin + @mkdir -p ${BUILD_DIR}/$@/etc + @mkdir -p ${BUILD_DIR}/$@/lib + @mkdir -p ${BUILD_DIR}/$@/htdocs + @mkdir -p ${BUILD_DIR}/$@/var + @cmake --build ${BUILD_DIR} --target widget + @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST} + +install: build + @cmake --build ${BUILD_DIR} --target install + +${BUILD_DIR}/Makefile: + @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} + @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..) diff --git a/conf.d/cmake/00-suse-osconfig.cmake b/conf.d/cmake/00-suse-osconfig.cmake new file mode 100644 index 0000000..a1101ef --- /dev/null +++ b/conf.d/cmake/00-suse-osconfig.cmake @@ -0,0 +1,2 @@ +list(APPEND PKG_REQUIRED_LIST lua>=5.3) +add_compile_options(-DUSE_API_DYN) diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake new file mode 100644 index 0000000..3ee2f8f --- /dev/null +++ b/conf.d/cmake/config.cmake @@ -0,0 +1,213 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll <fulup@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. +########################################################################### + +# Project Info +# ------------------ +set(PROJECT_NAME softmixer-4a) +set(PROJECT_PRETTY_NAME "Audio SoftMixer") +set(PROJECT_DESCRIPTION "Soft Mixer for 4A (AGL Advanced Audio Architecture)") +set(PROJECT_URL "https://github.com/iotbzh/4a-softmixer") +set(PROJECT_ICON "icon.png") +set(PROJECT_AUTHOR "Ar Foll, Fulup") +set(PROJECT_AUTHOR_MAIL "fulup@iot.bzh") +set(PROJECT_LICENSE "APL2.0") +set(PROJECT_LANGUAGES "C") + +# Where are stored default templates files from submodule or subtree app-templates in your project tree +# relative to the root project directory +set(PROJECT_APP_TEMPLATES_DIR "conf.d/app-templates") + +# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain +# but used and must be built and linked. +# set(PROJECT_LIBDIR "libs") + +# Where are stored data for your application. Pictures, static resources must be placed in that folder. +# set(PROJECT_RESOURCES "data") + +# Which directories inspect to find CMakeLists.txt target files +# set(PROJECT_SRC_DIR_PATTERN "*") + +# Compilation Mode (DEBUG, RELEASE) +# ---------------------------------- +set(CMAKE_BUILD_TYPE "DEBUG") +set(USE_EFENCE 0) + +# Kernel selection if needed. You can choose between a +# mandatory version to impose a minimal version. +# Or check Kernel minimal version and just print a Warning +# about missing features and define a preprocessor variable +# to be used as preprocessor condition in code to disable +# incompatibles features. Preprocessor define is named +# KERNEL_MINIMAL_VERSION_OK. +# +# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and +# Yocto SDK Kernel version. +# ----------------------------------------------- +#set (kernel_mandatory_version 4.8) +#set (kernel_minimal_version 4.8) + +# Compiler selection if needed. Impose a minimal version. +# ----------------------------------------------- +set (gcc_minimal_version 4.9) + +# PKG_CONFIG required packages +# ----------------------------- +set (PKG_REQUIRED_LIST + json-c + libsystemd>=222 + afb-daemon>=4.0 + libmicrohttpd>=0.9.55 + uuid +) + +# Prefix path where will be installed the files +# Default: /usr/local (need root permission to write in) +# ------------------------------------------------------ +set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt) + +# Customize link option +# ----------------------------- +#list(APPEND link_libraries -an-option) +list(APPEND link_libraries afb-helpers) + +# Compilation options definition +# Use CMake generator expressions to specify only for a specific language +# Values are prefilled with default options that is currently used. +# Either separate options with ";", or each options must be quoted separately +# DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED ! +# ---------------------------------------------------------------------------- +#set(COMPILE_OPTIONS +# -Wall +# -Wextra +# -Wconversion +# -Wno-unused-parameter +# -Wno-sign-compare +# -Wno-sign-conversion +# -Werror=maybe-uninitialized +# -Werror=implicit-function-declaration +# -ffunction-sections +# -fdata-sections +# -fPIC +# CACHE STRING "Compilation flags") +#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.") +#set(CXX_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C++ language.") +#set(PROFILING_COMPILE_OPTIONS +# -g +# -O0 +# -pg +# -Wp,-U_FORTIFY_SOURCE +# CACHE STRING "Compilation flags for PROFILING build type.") +#set(DEBUG_COMPILE_OPTIONS +# -g +# -ggdb +# -Wp,-U_FORTIFY_SOURCE +# CACHE STRING "Compilation flags for DEBUG build type.") +#set(CCOV_COMPILE_OPTIONS +# -g +# -O2 +# --coverage +# CACHE STRING "Compilation flags for CCOV build type.") +#set(RELEASE_COMPILE_OPTIONS +# -g +# -O2 +# CACHE STRING "Compilation flags for RELEASE build type.") + +set(CONTROL_SUPPORT_LUA 1) +add_definitions(-DCONTROL_PLUGIN_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib/plugins:${CMAKE_BINARY_DIR}/package/lib/plugins") +add_definitions(-DCONTROL_CONFIG_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc:${CMAKE_BINARY_DIR}/package/etc") +add_definitions(-DCONTROL_LUA_PATH="${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/data:${CMAKE_BINARY_DIR}/package/data") +add_definitions(-DCTL_PLUGIN_MAGIC=987456123) +add_definitions(-DUSE_API_DYN=1 -DAFB_BINDING_VERSION=dyn) + + +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable] +# --------------------------------------------------------------------- +set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) + +# Optional location for config.xml.in +# ----------------------------------- +#set(WIDGET_ICON conf.d/wgt/${PROJECT_ICON} CACHE PATH "Path to the widget icon") +set(WIDGET_CONFIG_TEMPLATE "${CMAKE_SOURCE_DIR}/conf.d/wgt/config.xml.in" CACHE PATH "Path to widget config file template (config.xml.in)") + +# Mandatory widget Mimetype specification of the main unit +# -------------------------------------------------------------------------- +# Choose between : +#- text/html : HTML application, +# content.src designates the home page of the application +# +#- application/vnd.agl.native : AGL compatible native, +# content.src designates the relative path of the binary. +# +# - application/vnd.agl.service: AGL service, content.src is not used. +# +#- ***application/x-executable***: Native application, +# content.src designates the relative path of the binary. +# For such application, only security setup is made. +# +set(WIDGET_TYPE application/vnd.agl.service) + +# Mandatory Widget entry point file of the main unit +# -------------------------------------------------------------- +# This is the file that will be executed, loaded, +# at launch time by the application framework. +# +set(WIDGET_ENTRY_POINT lib/afb-signal-composer.so) + +# Optional dependencies order +# --------------------------- +#set(EXTRA_DEPENDENCIES_ORDER) + +# Optional Extra global include path +# ----------------------------------- +#set(EXTRA_INCLUDE_DIRS) + +# Optional extra libraries +# ------------------------- +#set(EXTRA_LINK_LIBRARIES) + +# Optional force binding Linking flag +# ------------------------------------ +# set(BINDINGS_LINK_FLAG LinkOptions ) + +# Optional force package prefix generation, like widget +# ----------------------------------------------------- +# set(PKG_PREFIX DestinationPath) + +# Optional Application Framework security token +# and port use for remote debugging. +#------------------------------------------------------------ +set(AFB_TOKEN "" CACHE PATH "Default binder security token") +set(AFB_REMPORT "1234" CACHE PATH "Default binder listening port") + +# Print a helper message when every thing is finished +# ---------------------------------------------------- +set(CLOSING_MESSAGE "Typical binding launch: afb-daemon --name afbd-${PROJECT_NAME} --port=${AFB_REMPORT} --workdir=${CMAKE_BINARY_DIR}/package --ldpaths=lib --roothttp=. --token=\"${AFB_TOKEN}\" --tracereq=common --verbose") +set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") + +# Optional schema validator about now only XML, LUA and JSON +# are supported +#------------------------------------------------------------ +#set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler") +#set(XML_CHECKER "xmllint" CACHE STRING "XML linter") +#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter") + +# This include is mandatory and MUST happens at the end +# of this file, else you expose you to unexpected behavior +# ----------------------------------------------------------- +include(${PROJECT_APP_TEMPLATES_DIR}/cmake/common.cmake) diff --git a/conf.d/project/CMakeLists.txt b/conf.d/project/CMakeLists.txt new file mode 100644 index 0000000..28a0609 --- /dev/null +++ b/conf.d/project/CMakeLists.txt @@ -0,0 +1,22 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll <fulup@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. +########################################################################### + + +# Include any directory not starting with _ +# ----------------------------------------------------- +PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) diff --git a/conf.d/project/etc/CMakeLists.txt b/conf.d/project/etc/CMakeLists.txt new file mode 100644 index 0000000..378effc --- /dev/null +++ b/conf.d/project/etc/CMakeLists.txt @@ -0,0 +1,31 @@ +########################################################################### +# Copyright 2017 IoT.bzh +# +# author: Fulup Ar Foll <fulup@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. +########################################################################### + +################################################## +# Control Policy Config file +################################################## +PROJECT_TARGET_ADD(soft-mixer-config) + + file(GLOB CONF_FILES "*.json") + + add_input_files("${CONF_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "BINDING-CONFIG" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/conf.d/project/etc/config-softmixer-4a.json b/conf.d/project/etc/config-softmixer-4a.json new file mode 100644 index 0000000..345dde4 --- /dev/null +++ b/conf.d/project/etc/config-softmixer-4a.json @@ -0,0 +1,81 @@ +{ + "schema": "To Be Defined", + "metadata": { + "uid": "Soft Mixer", + "version": "1.0", + "api": "soft-mixer", + "info": "Soft Mixer emulating hardware mixer", + "require": ["alsa-core"] + }, + "plugins": [ + { + "uid": "alsa-router", + "info": "Map alsa-loop subdevices to 4A HAL streams" + } + ], + + "sndcards": [ + { + "uid": "Focusrite_Scarlett_18i8", + "info": "Focusrite 18i8", + "device": "/dev/snd/by-id/usb-Focusrite_Scarlett_18i8_USB_10004EE6-00", + "action": { + "uid": "init-snd-card", + "function": "lua://init-focusrite" + }, + "channels": { + "sink": [ + { + "type": "FrontLeftFullRange", + "port": 0 + }, + { + "type": "FrontRightFullRange", + "port": 1 + }, + { + "type": "RearLeftFullRange", + "port": 2 + }, + { + "type": "FrontRightFullRange", + "port": 3 + }, + { + "type": "Center", + "port": 4 + }, + { + "type": "LFE", + "port": 5 + } + ], + "source": [ + { + "uid": "FrontRightMic", + "type": "Directional", + "port": 0 + } + ] + } + } + ], + + "streams": [{ + "uid": "alsa-loop", + "dev": "/dev/snd/by-path/platform-snd_aloop.0", + "subdev": 0, + "count": 8 + }], + + "controls": [ + { + "uid": "stream", + "function": "plugin://alsa-router/stream_ctl" + }, + { + "uid": "zone", + "function": "plugin://alsa-router/zone_ctl" + } + ] +} diff --git a/conf.d/project/etc/fiberdyme_hal_sample.json b/conf.d/project/etc/fiberdyme_hal_sample.json new file mode 100644 index 0000000..2614163 --- /dev/null +++ b/conf.d/project/etc/fiberdyme_hal_sample.json @@ -0,0 +1,287 @@ +{ + "$schema": "ToBeDone", + "metadata": { + "api": "fd-dsp", + "uid": "fiberdyne_dsp", + "info": "Fiberdyne DSP HAL for Xtensa HiFi2", + "version": "1.0", + "require": "alsacore" + }, + "plugins": [ + { + "uid": "fd-dsp-hifi2", + "info": "Fiberdyne DSP client library for HiFi2", + "basename": "fd-dsp-hifi2", + "ldpath": "./fd-dsp-hifi2" + } + ], + "comment": "These are per-stream, could look at alsa byte stream?", + "control": [ + { + "uid": "Volume", + "alsa": { + "name": "PCM Playback Volume", + "value": 50 + } + }, + { + "uid": "Mute", + "alsa": { + "name": "PCM Playback Switch", + "value": false + } + }, + { + "uid": "Bass", + "alsa": { + "name": "PCM Playback Bass", + "value": 50 + } + }, + { + "uid": "Mid", + "alsa": { + "name": "PCM Playback Mid", + "value": 50 + } + }, + { + "uid": "Treble", + "alsa": { + "name": "PCM Playback Treble", + "value": 50 + } + }, + { + "uid": "Balance", + "alsa": { + "name": "PCM Playback Balance", + "value": 50 + } + }, + { + "uid": "Fade", + "alsa": { + "name": "PCM Playback Fade", + "value": 50 + } + } + ], + "eqpoint": { + "action": [ + { + "uid": "eq-add-point", + "function": "plugin://fd-dsp-hifi2/eq_add_point" + }, + { + "uid": "eq-remove-point", + "function": "plugin://fd-dsp-hifi2/eq_remove_point" + } + ] + }, + "filter": { + "plugin": "fd-dsp-hifi2", + "action": [ + { + "uid": "filter-hip", + "function": "plugin://fd-dsp-hifi2/filter_hip" + } + ] + }, + "cards": { + "uid": "A", + "alsa": "xf-dsp-alsa:0,1", + "desc": "Xtensa R-Car HiFi2 DSP", + "action": { + "uid": "init-snd-card", + "function": "plugin://fd-dsp-hifi2/init-stereo" + }, + "channels": { + "sink": [ + { + "type": "FrontLeftFullRange", + "port": 0 + }, + { + "type": "FrontRightFullRange", + "port": 1 + }, + { + "type": "RearLeftFullRange", + "port": 2 + }, + { + "type": "FrontRightFullRange", + "port": 3 + }, + { + "type": "Center", + "port": 4 + }, + { + "type": "LFE", + "port": 5 + } + ], + "source": [ + { + "uid": "FrontRightMic", + "type": "Directional", + "port": 0 + } + ] + } + }, + "info": "This is totally an abstraction", + "zone": [ + { + "uid": "FrontSeat", + "type": "sink", + "mapping": [ + [ + "FrontRightMain", + "FrontRightHigh" + ], + [ + "FrontLeftMain", + "FrontLeftHigh" + ] + ] + }, + { + "uid": "RearSeat", + "type": "sink", + "mapping": [ + [ + "RearRightMain", + "RearRightHigh" + ], + [ + "RearLeftMain", + "RearLeftHigh" + ] + ] + }, + { + "uid": "DriverMic", + "type": "source", + "mapping": [ + [ + "FrontRightMic" + ] + ] + }, + { + "uid": "FullMicSetup", + "type":"source", + "mapping": + [ + [ "FrontLeftMic"], + [ "FrontRightMic"], + [ "RearLeftMic"], + [ "RearLeftMic"] + ] + } + { + "uid": "FiveOne", + "type": "sink", + "mapping": [ + [ + "FrontRightMain", + "FrontRightHigh" + ], + [ + "FrontLeftMain", + "FrontLeftHigh" + ], + [ + "RearRightMain", + "RearRightHigh" + ], + [ + "RearLeftMain", + "RearLeftHigh" + ], + [ + "Center" + ], + [ + "LFE" + ] + ] + }, + { + "uid": "StereoFour", + "type": "sink", + "mapping": [ + [ + "FrontRightMain", + "FrontRightHigh", + "RearRightMain", + "RearRightHigh" + ], + [ + "FrontLeftMain", + "FrontLeftHigh", + "RearLeftMain", + "RearLeftHigh" + ] + ] + } + ], + "streams": [ + { + "name": "speech-engine", + "profile": "profile-speech", + "source": { + "zone":"DriverMic", + "defaultconfig":{ + "mute": true + } + }, + "sink": { + "zone": "FrontSeat", + "defaultconfig": { + "volume": 50, + "mute": false, + "bass": 50, + "mid": 50, + "treble": 50, + "balance": 50, + "fade": 50 + } + } + }, + { + "name": "phone", + "profile": "test", + "source": { + "channels": 1, + "zone": "DriverMic", + "defaultconfig":{ + "volume":"25" + } + }, + "sink": { + "channels": 2, + "zone": "FrontSeat" + } + }, + { + "name": "stereo", + "profile": "profile-dynamic", + "sink": { + "channels": 2, + "zone": "StereoFour" + } + }, + { + "name": "5_1", + "profile": "profile-dynamic", + "sink": { + "channels": 6, + "zone": "FiveOne" + } + } + ] +}
\ No newline at end of file diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in new file mode 100644 index 0000000..197dedc --- /dev/null +++ b/conf.d/wgt/config.xml.in @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@"> + <name>@PROJECT_NAME@</name> + <icon src="@PROJECT_ICON@"/> + <content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/> + <description>@PROJECT_DESCRIPTION@</description> + <author>@PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@></author> + <license>@PROJECT_LICENSE@</license> + + <feature name="urn:AGL:widget:required-permission"> + <param name="urn:AGL:permission::public:hidden" value="required" /> + <param name="urn:AGL:permission::public:no-htdocs" value="required" /> + </feature> + + <feature name="urn:AGL:widget:provided-api"> + <param name="control" value="ws" /> + </feature> + + <feature name="urn:AGL:widget:required-api"> + <param name="lib/afb-control-afb.so" value="local" /> + </feature> +</widget> + diff --git a/conf.d/wgt/icon.png b/conf.d/wgt/icon.png Binary files differnew file mode 100644 index 0000000..d127aaa --- /dev/null +++ b/conf.d/wgt/icon.png diff --git a/mixer-binding/CMakeLists.txt b/mixer-binding/CMakeLists.txt new file mode 100644 index 0000000..bc4ebe6 --- /dev/null +++ b/mixer-binding/CMakeLists.txt @@ -0,0 +1,50 @@ +########################################################################### +# Copyright 2015, 2016, 2017, 2018 IoT.bzh +# +# author: Fulup Ar Foll <fulup@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(mixer-binding) + + # Define project Targets + ADD_LIBRARY(${TARGET_NAME} MODULE mixer-binding.c) + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + PREFIX "" + LABELS "BINDING" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${TARGET_NAME} + ) + + 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} + ) + + # Define target includes for this target client + TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ) + + # make sure config is copied before starting + add_dependencies(${TARGET_NAME} soft-mixer-config)
\ No newline at end of file diff --git a/mixer-binding/mixer-binding.c b/mixer-binding/mixer-binding.c new file mode 100644 index 0000000..ae83932 --- /dev/null +++ b/mixer-binding/mixer-binding.c @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2016 "IoT.bzh" + * Author Fulup Ar Foll <fulup@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 <string.h> +#include <time.h> + +#include "mixer-binding.h" + + +// default api to print log when apihandle not avaliable +PUBLIC afb_dynapi *AFB_default; + +// Config Section definition (note: controls section index should match handle retrieval in HalConfigExec) +static CtlSectionT ctrlSections[]= { + {.key="plugins" , .loadCB= PluginConfig}, + {.key="controls", .loadCB= ControlConfig}, + + {.key=NULL} +}; + +STATIC void ctrlapi_ping (AFB_ReqT request) { + static int count=0; + + count++; + AFB_ReqNotice (request, "Controller:ping count=%d", count); + AFB_ReqSucess(request,json_object_new_int(count), NULL); + + return; +} + +// Every HAL export the same API & Interface Mapping from SndCard to AudioLogic is done through alsaHalSndCardT +STATIC AFB_ApiVerbs CtrlApiVerbs[] = { + /* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */ + { .verb = "ping", .callback = ctrlapi_ping , .info = "ping test for API"}, + { .verb = NULL} /* marker for end of the array */ +}; + +STATIC int CtrlLoadStaticVerbs (afb_dynapi *apiHandle, AFB_ApiVerbs *verbs) { + int errcount=0; + + for (int idx=0; verbs[idx].verb; idx++) { + errcount+= afb_dynapi_add_verb(apiHandle, CtrlApiVerbs[idx].verb, NULL, CtrlApiVerbs[idx].callback, (void*)&CtrlApiVerbs[idx], CtrlApiVerbs[idx].auth, 0); + } + + return errcount; +}; + + +STATIC int CtrlInitOneApi (AFB_ApiT apiHandle) { + + AFB_default = apiHandle; // hugely hack to make all V2 AFB_DEBUG to work in fileutils + + // retrieve section config from api handle + CtlConfigT *ctrlConfig = (CtlConfigT*) afb_dynapi_get_userdata(apiHandle); + int err = CtlConfigExec (apiHandle, ctrlConfig); + + return err; +} + +// next generation dynamic API-V3 mode + +STATIC int CtrlLoadOneApi (void *cbdata, AFB_ApiT apiHandle) { + CtlConfigT *ctrlConfig = (CtlConfigT*) cbdata; + + // save closure as api's data context + afb_dynapi_set_userdata(apiHandle, ctrlConfig); + + AFB_ApiNotice (apiHandle, "debug1"); + + // add static controls verbs + int err = CtrlLoadStaticVerbs (apiHandle, CtrlApiVerbs); + if (err) { + AFB_ApiError(apiHandle, "CtrlLoadSection fail to register static V2 verbs"); + goto OnErrorExit; + } + + AFB_ApiNotice (apiHandle, "debug2"); + + // load section for corresponding API + err= CtlLoadSections(apiHandle, ctrlConfig, ctrlSections); + + AFB_ApiNotice (apiHandle, "debug3"); + + // declare an event event manager for this API; + afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent); + + // init API function (does not receive user closure ??? + afb_dynapi_on_init(apiHandle, CtrlInitOneApi); + + afb_dynapi_seal(apiHandle); + return err; + +OnErrorExit: + return 1; +} + + +PUBLIC int afbBindingVdyn(afb_dynapi *apiHandle) { + + AFB_default = apiHandle; + AFB_ApiNotice (apiHandle, "Controller in afbBindingVdyn"); + + const char *dirList= getenv("CONTROL_CONFIG_PATH"); + if (!dirList) dirList=CONTROL_CONFIG_PATH; + + const char *configPath = CtlConfigSearch(apiHandle, dirList, "config-"); + if (!configPath) { + AFB_ApiError(apiHandle, "CtlPreInit: No config-%s-* config found in %s ", GetBinderName(), dirList); + goto OnErrorExit; + } + + // load config file and create API + CtlConfigT *ctrlConfig = CtlLoadMetaData (apiHandle, configPath); + if (!ctrlConfig) { + AFB_ApiError(apiHandle, "CtrlBindingDyn No valid control config file in:\n-- %s", configPath); + goto OnErrorExit; + } + + + if (!ctrlConfig->api) { + AFB_ApiError(apiHandle, "CtrlBindingDyn API Missing from metadata in:\n-- %s", configPath); + goto OnErrorExit; + } + + AFB_ApiNotice (apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, ctrlConfig->info); + // create one API per config file (Pre-V3 return code ToBeChanged) + int status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig); + + return status; + +OnErrorExit: + return -1; +} + diff --git a/mixer-binding/mixer-binding.h b/mixer-binding/mixer-binding.h new file mode 100644 index 0000000..57d4ce9 --- /dev/null +++ b/mixer-binding/mixer-binding.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 "IoT.bzh" + * Author Fulup Ar Foll <fulup@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 _CTL_BINDING_INCLUDE_ +#define _CTL_BINDING_INCLUDE_ + +#include <stdio.h> +#include <alsa/asoundlib.h> + +#include <filescan-utils.h> +#include <wrap-json.h> + +#include <ctl-config.h> + +#endif /* _CTL_BINDING_INCLUDE_ */ diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml new file mode 100644 index 0000000..8e36718 --- /dev/null +++ b/nbproject/configurations.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configurationDescriptor version="100"> + <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT"> + <df root="." name="0"> + <df name="app-afb-helpers-submodule"> + <in>filescan-utils.c</in> + <in>wrap-json.c</in> + </df> + <df name="app-controller-submodule"> + <df name="ctl-lib"> + <in>ctl-action.c</in> + <in>ctl-config.c</in> + <in>ctl-control.c</in> + <in>ctl-event.c</in> + <in>ctl-lua.c</in> + <in>ctl-plugin.c</in> + <in>ctl-timer.c</in> + </df> + </df> + <df name="mixer-binding"> + <in>mixer-binding.c</in> + </df> + </df> + <logicalFolder name="ExternalFiles" + displayName="Important Files" + projectFiles="false" + kind="IMPORTANT_FILES_FOLDER"> + <itemPath>build/Makefile</itemPath> + <itemPath>nbproject/private/launcher.properties</itemPath> + </logicalFolder> + </logicalFolder> + <sourceFolderFilter>^(nbproject)$</sourceFolderFilter> + <sourceRootList> + <Elem>.</Elem> + </sourceRootList> + <projectmakefile>build/Makefile</projectmakefile> + <confs> + <conf name="Default" type="0"> + <toolsSet> + <compilerSet>GNU|GNU</compilerSet> + <dependencyChecking>false</dependencyChecking> + <rebuildPropChanged>false</rebuildPropChanged> + </toolsSet> + <flagsDictionary> + <element flagsID="0" commonFlags="-mtune=generic -march=x86-64 -g -fPIC"/> + </flagsDictionary> + <codeAssistance> + </codeAssistance> + <makefileType> + <makeTool> + <buildCommandWorkingDir>build</buildCommandWorkingDir> + <buildCommand>${MAKE} -f Makefile</buildCommand> + <cleanCommand>${MAKE} -f Makefile clean</cleanCommand> + <executablePath></executablePath> + </makeTool> + <preBuild> + <preBuildCommandWorkingDir>build</preBuildCommandWorkingDir> + <preBuildCommand>cmake ..</preBuildCommand> + <preBuildFirst>true</preBuildFirst> + </preBuild> + </makefileType> + <item path="app-afb-helpers-submodule/filescan-utils.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-afb-helpers-submodule</pElem> + <pElem>../../../opt/include</pElem> + <pElem>build/app-afb-helpers-submodule</pElem> + </incDir> + </cTool> + </item> + <item path="app-afb-helpers-submodule/wrap-json.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + <incDir> + <pElem>app-afb-helpers-submodule</pElem> + <pElem>build/app-afb-helpers-submodule</pElem> + </incDir> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-action.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-config.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-control.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-event.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-lua.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-plugin.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <item path="app-controller-submodule/ctl-lib/ctl-timer.c" + ex="false" + tool="0" + flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + <folder path="0/app-controller-submodule"> + <cTool> + <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> + <pElem>app-afb-helpers-submodule</pElem> + <pElem>../../../opt/include</pElem> + <pElem>build/app-controller-submodule/ctl-lib</pElem> + </incDir> + </cTool> + </folder> + <folder path="0/mixer-binding"> + <cTool> + <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>mixer-binding</pElem> + <pElem>app-afb-helpers-submodule</pElem> + <pElem>app-controller-submodule/ctl-lib</pElem> + <pElem>../../../opt/include</pElem> + <pElem>build/mixer-binding</pElem> + </incDir> + </cTool> + </folder> + <item path="mixer-binding/mixer-binding.c" ex="false" tool="0" flavor2="3"> + <cTool flags="0"> + </cTool> + </item> + </conf> + </confs> +</configurationDescriptor> diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..369d0f7 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.cnd.makeproject</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/make-project/1"> + <name>4a-softmixer</name> + <c-extensions>c</c-extensions> + <cpp-extensions>cpp,cxx</cpp-extensions> + <header-extensions>h,hpp</header-extensions> + <sourceEncoding>UTF-8</sourceEncoding> + <make-dep-projects/> + <sourceRootList> + <sourceRootElem>.</sourceRootElem> + </sourceRootList> + <confList> + <confElem> + <name>Default</name> + <type>0</type> + </confElem> + </confList> + <formatting> + <project-formatting-style>false</project-formatting-style> + </formatting> + </data> + </configuration> +</project> diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 0000000..644e359 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,40 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Romain Forlot <romain.forlot@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. +########################################################################### + + +PROJECT_TARGET_ADD(alsa-router) + + # Define targets + ADD_LIBRARY(${TARGET_NAME} MODULE ${TARGET_NAME}.c) + + # Alsa Plugin properties + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "PLUGIN" + PREFIX "" + SUFFIX ".ctlso" + OUTPUT_NAME ${TARGET_NAME} + ) + + # Library dependencies (include updates automatically) + TARGET_LINK_LIBRARIES(${TARGET_NAME} + ${link_libraries} + ) + + target_include_directories(${TARGET_NAME} + PRIVATE "../app-controller-submodule/ctl-lib" + PRIVATE "../mixer-binding") diff --git a/plugins/alsa-router.c b/plugins/alsa-router.c new file mode 100644 index 0000000..e0e7eb2 --- /dev/null +++ b/plugins/alsa-router.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 "IoT.bzh" + * Author Romain Forlot <romain.forlot@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 // needed for vasprintf + +#include <afb/afb-binding.h> +#include <systemd/sd-event.h> +#include <json-c/json_object.h> +#include <stdbool.h> +#include <string.h> + +#include "ctl-plugin.h" +#include "wrap-json.h" + +CTLP_CAPI_REGISTER("alsa-mixer"); + +// Call at initialisation time +/*CTLP_ONLOAD(plugin, callbacks) { + AFB_NOTICE ("GPS plugin: uid='%s' 'info='%s'", plugin->uid, plugin->info); + return api; +}*/ + +CTLP_CAPI (zone_action, source, argsJ, eventJ) { + json_object* subscribeArgsJ = NULL, *responseJ = NULL; + + int err = 0; + wrap_json_pack(&subscribeArgsJ, "{ss}", "value", "location"); + AFB_ApiDebug(source->api, "Calling zone_action with %s", json_object_to_json_string_ext(subscribeArgsJ, JSON_C_TO_STRING_PRETTY)); + + return err; +} |