From ab6e470190f2cc410b1f6fa8f146317a3c3b08b5 Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Wed, 1 Nov 2017 22:18:54 +0100 Subject: Integration with AlsaHookPlugin (work in progress) --- conf.d/cmake/config.cmake | 4 +- conf.d/project/.asoundrc | 164 -------------------------- conf.d/project/.asoundrc-audiok | 164 ++++++++++++++++++++++++++ conf.d/project/.asounrc-fulup | 198 ++++++++++++++++++++++++++++++++ conf.d/project/README.md | 15 +++ conf.d/project/agl-ahl-config.json | 128 --------------------- conf.d/project/ahl-audiok4a-config.json | 128 +++++++++++++++++++++ conf.d/project/ahl-fulup4a-config.json | 39 +++++++ 8 files changed, 547 insertions(+), 293 deletions(-) delete mode 100644 conf.d/project/.asoundrc create mode 100644 conf.d/project/.asoundrc-audiok create mode 100644 conf.d/project/.asounrc-fulup create mode 100644 conf.d/project/README.md delete mode 100644 conf.d/project/agl-ahl-config.json create mode 100644 conf.d/project/ahl-audiok4a-config.json create mode 100644 conf.d/project/ahl-fulup4a-config.json (limited to 'conf.d') diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index ba56110..ff824cf 100644 --- a/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -54,6 +54,7 @@ set(CONTROL_SUPPORT_LUA 1 CACHE BOOL "Active or not LUA Support") # PKG_CONFIG required packages # ----------------------------- set (PKG_REQUIRED_LIST + glib-2.0 alsa>=1.1.2 libsystemd>=222 libmicrohttpd>=0.9.55 @@ -86,6 +87,7 @@ set(COMPILE_OPTIONS -DMAX_LINEAR_DB_SCALE=24 # until 24db volume normalisation use a simple linear scale -DTLV_BYTE_SIZE=256 # Alsa use 4096 as default but 256 should fit most sndcards -DCONTROL_MAXPATH_LEN=255 +-DCONTROL_CONFIG_PATH="${CMAKE_SOURCE_DIR}/conf.d/project:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}" 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.") @@ -100,7 +102,7 @@ if(IS_DIRECTORY $ENV{HOME}/opt/afb-monitoring) set(MONITORING_ALIAS "--alias=/monitoring:$ENV{HOME}/opt/afb-monitoring") endif() -set(CLOSING_MESSAGE "Debug: afb-daemon --name=afb-aaaa --port=1234 --ws-server=unix:/var/tmp/ahl-4a --cntxtimeout=1 ${MONITORING_ALIAS} --ldpaths=package/lib:../../alsa-4a/build/package/lib:../../hal-sample-4a/build/package/lib --workdir=. --roothttp=../htdocs --token= --verbose ") +set(CLOSING_MESSAGE "Debug: afb-daemon --name=afb-audiok4a --port=1234 --ws-server=unix:/var/tmp/ahl-4a --cntxtimeout=1 ${MONITORING_ALIAS} --binding=package/lib/afb-audiohighlevel.so --ldpaths=../../alsa-4a/build/package/lib:../../hal-sample-4a/build/package/lib --workdir=. --roothttp=../htdocs --token= --verbose ") # Optional location for config.xml.in diff --git a/conf.d/project/.asoundrc b/conf.d/project/.asoundrc deleted file mode 100644 index cba88e5..0000000 --- a/conf.d/project/.asoundrc +++ /dev/null @@ -1,164 +0,0 @@ - - -##### AGL Conf ##### -pcm.SoftMixer { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { - pcm "hw:0" # Main sound card - # periods 8 - period_size 1024 - buffer_size 4096 - } - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} - -pcm.SoftMixer_DriverHR { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { - pcm "hw:1" # Alternate sound card / dummy - # periods 8 - period_size 1024 - buffer_size 4096 - } - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} - -pcm.SoftMixer_RSE { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { - pcm "hw:2" # Alternate sound card / dummy - # periods 8 - period_size 1024 - buffer_size 4096 - } - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} - -pcm.Entertainment_Main { - type softvol - slave.pcm "SoftMixer" - control{ - name "Entertainment_Vol" - card 0 - } -} - -pcm.Guidance_Main { - type softvol - slave.pcm "SoftMixer" - control{ - name "Guidance_Vol" - card 0 - } -} - -pcm.Communications_Main { - type softvol - slave.pcm "SoftMixer" - control{ - name "Communications_Vol" - card 0 - } -} - -pcm.Notification_Main { - type softvol - slave.pcm "SoftMixer" - control{ - name "Notification_Vol" - card 0 - } -} - -pcm.Warning_Main { - type softvol - slave.pcm "SoftMixer" - control{ - name "Warning_Vol" - card 0 - } -} - -pcm.Entertainment_DriverHR { - type softvol - slave.pcm "SoftMixer_DriverHR" - control{ - name "Entertainment_Vol" - card 1 - } -} - -pcm.Guidance_DriverHR { - type softvol - slave.pcm "SoftMixer_DriverHR" - control{ - name "Guidance_Vol" - card 1 - } -} - -pcm.Communications_DriverHR { - type softvol - slave.pcm "SoftMixer_DriverHR" - control{ - name "Communications_Vol" - card 1 - } -} - -pcm.Notification_DriverHR { - type softvol - slave.pcm "SoftMixer_DriverHR" - control{ - name "Notification_Vol" - card 1 - } -} - -pcm.Warning_DriverHR { - type softvol - slave.pcm "SoftMixer_DriverHR" - control{ - name "Warning_Vol" - card 1 - } -} - -pcm.Entertainment_RSE { - type softvol - slave.pcm "SoftMixer_RSE" - control{ - name "Entertainment_Vol" - card 2 - } -} diff --git a/conf.d/project/.asoundrc-audiok b/conf.d/project/.asoundrc-audiok new file mode 100644 index 0000000..cba88e5 --- /dev/null +++ b/conf.d/project/.asoundrc-audiok @@ -0,0 +1,164 @@ + + +##### AGL Conf ##### +pcm.SoftMixer { + type dmix + ipc_key 1024 + ipc_key_add_uid false + ipc_perm 0666 # mixing for all users + + # Define target effective sound card (cannot be a plugin) + slave { + pcm "hw:0" # Main sound card + # periods 8 + period_size 1024 + buffer_size 4096 + } + + # DMIX can only map two channels + bindings { + 0 0 + 1 1 + } +} + +pcm.SoftMixer_DriverHR { + type dmix + ipc_key 1024 + ipc_key_add_uid false + ipc_perm 0666 # mixing for all users + + # Define target effective sound card (cannot be a plugin) + slave { + pcm "hw:1" # Alternate sound card / dummy + # periods 8 + period_size 1024 + buffer_size 4096 + } + + # DMIX can only map two channels + bindings { + 0 0 + 1 1 + } +} + +pcm.SoftMixer_RSE { + type dmix + ipc_key 1024 + ipc_key_add_uid false + ipc_perm 0666 # mixing for all users + + # Define target effective sound card (cannot be a plugin) + slave { + pcm "hw:2" # Alternate sound card / dummy + # periods 8 + period_size 1024 + buffer_size 4096 + } + + # DMIX can only map two channels + bindings { + 0 0 + 1 1 + } +} + +pcm.Entertainment_Main { + type softvol + slave.pcm "SoftMixer" + control{ + name "Entertainment_Vol" + card 0 + } +} + +pcm.Guidance_Main { + type softvol + slave.pcm "SoftMixer" + control{ + name "Guidance_Vol" + card 0 + } +} + +pcm.Communications_Main { + type softvol + slave.pcm "SoftMixer" + control{ + name "Communications_Vol" + card 0 + } +} + +pcm.Notification_Main { + type softvol + slave.pcm "SoftMixer" + control{ + name "Notification_Vol" + card 0 + } +} + +pcm.Warning_Main { + type softvol + slave.pcm "SoftMixer" + control{ + name "Warning_Vol" + card 0 + } +} + +pcm.Entertainment_DriverHR { + type softvol + slave.pcm "SoftMixer_DriverHR" + control{ + name "Entertainment_Vol" + card 1 + } +} + +pcm.Guidance_DriverHR { + type softvol + slave.pcm "SoftMixer_DriverHR" + control{ + name "Guidance_Vol" + card 1 + } +} + +pcm.Communications_DriverHR { + type softvol + slave.pcm "SoftMixer_DriverHR" + control{ + name "Communications_Vol" + card 1 + } +} + +pcm.Notification_DriverHR { + type softvol + slave.pcm "SoftMixer_DriverHR" + control{ + name "Notification_Vol" + card 1 + } +} + +pcm.Warning_DriverHR { + type softvol + slave.pcm "SoftMixer_DriverHR" + control{ + name "Warning_Vol" + card 1 + } +} + +pcm.Entertainment_RSE { + type softvol + slave.pcm "SoftMixer_RSE" + control{ + name "Entertainment_Vol" + card 2 + } +} diff --git a/conf.d/project/.asounrc-fulup b/conf.d/project/.asounrc-fulup new file mode 100644 index 0000000..c98d5a8 --- /dev/null +++ b/conf.d/project/.asounrc-fulup @@ -0,0 +1,198 @@ +# +# Author: Fulup Ar Foll +# Object: PCM hook type +# +# Test : Note: Jabra_USB=hw:v1340 +# Check SoundCard ==> speaker-test -Dhw:v1340 -c2 -twav +# Check MixerPCM ==> speaker-test -DSpeakers -c2 -twav +# Check SoftVol ==> speaker-test -DMusicPCM -c2 -twav +# Check Plugin ==> speaker-test -DMultimedia -c2 -twav +# Check Plugin ==> speaker-test -DNavigation -c2 -twav +# +# MultiMedia aplay -DDMyNavPCM /usr/share/sounds/alsa/test.wav +# +# Bug/Feature: when softvol control is initialised from plugin and not +# from AGL binding. At 1st run ctl has invalid TLV and cannot be +# use. Bypass Solution: +# * start audio-binder before playing sound (binding create control before softvol plugin) +# * run a dummy aplay -DMyNavPCM "" to get a clean control +# +# References: https://www.spinics.net/lists/alsa-devel/msg54235.html +# -------------------------------------------------------------------- + +# ------------------------------------------------------ +# Mixer PCM allow to play multiple stream simultaneously +# ------------------------------------------------------ +pcm.Speakers { + type dmix + slave {pcm "hw:v1340"} #Jabra Solmate 1 + ipc_key 1001 # ipc_key should be unique to each dmix +} + +# ----------------------------------------------------- +# Register ControllerHookPlugin (ToiBeFix fullpath) +# ----------------------------------------------------- +pcm_hook_type.CtlHookPlugin { + install "AlsaInstallHook" + lib "/home/fulup/Workspace/Audio-4a/alsa-4a/build/alsa-hook/policy_alsa_hook.so" +} + + +# ------------------------------------------------------- +# Define one Audio Virtual Channel per Audio Roles +# ------------------------------------------------------- +pcm.MusicPCM { + type softvol + + # Point Slave on HOOK for policies control + slave.pcm "Speakers" + + # name should match with HAL definition + control.name "Playback Multimedia" +} + +pcm.NaviPCM { + type softvol + + # Point Slave on HOOK for policies control + slave.pcm "Speakers" + + # name should match with HAL definition + control.name "Playback Navigation" +} + +pcm.UrgentPCM { + type softvol + + # Point Slave on HOOK for policies control + slave.pcm "Speakers" + + # name should match with HAL definition + control.name "Playback Emergency" +} + +# ---------------------------------------------------- +# Define one hooked PCM channel per Audio Roles +# ---------------------------------------------------- +pcm.Multimedia { + type hooks + slave {pcm "MusicPCM"} + hooks.0 { + comment "Defined used hook sharelib and provide arguments/config to install func" + type "CtlHookPlugin" + hook_args { + + # print few log messages (default false) + verbose true + + # uri to audio-4a policy engine + uri="unix:/var/tmp/ahl-4a" + + # timeout in ms (default 500) + timeout 5000 + + # force API synchronous mode + synchronous true + + # api subcall to request a role + request { + stream_open "{'audio_role':'Entertainment', 'endpoint_type': 'sink'}" + set_stream_state "{'state': 'running'}" + } + + # api subcall to request a role + release { + stream_close "{}" + } + + # map AGL event on Unix signal. Search in event for json key=value + events { + sig-02 {search music, value quit} + sig-31 {search event, value start} + sig-32 {search event, value start} + } + } + } +} + +pcm.Navigation { + type hooks + slave {pcm "NaviPCM"} + hooks.0 { + comment "Defined used hook sharelib and provide arguments/config to install func" + type "CtlHookPlugin" + hook_args { + + # print few log messages (default false) + verbose true + + # uri to audio-4a policy engine + uri="unix:/var/tmp/ahl-4a" + + # timeout in ms (default 500) + timeout 5000 + + # force API synchronous mode + synchronous true + + # api subcall to request a role + request { + stream_open "{'audio_role':'Guidance', 'endpoint_type': 'sink'}" + set_stream_state "{'state': 'running'}" + } + + # api subcall to request a role + release { + release-role "{'uid':'alsa-hook-client'}" + } + + # map AGL event on Unix signal. Search in event for json key=value + events { + sig-02 {search navi, value quit} + sig-31 {search event, value start} + sig-32 {search event, value start} + } + } + } +} + +pcm.Emergency { + type hooks + slave {pcm "UrgentPCM"} + hooks.0 { + comment "Defined used hook sharelib and provide arguments/config to install func" + type "CtlHookPlugin" + hook_args { + + # print few log messages (default false) + verbose true + + # uri to audio-4a policy engine + uri="unix:/var/tmp/ahl-4a" + + # timeout in ms (default 500) + timeout 5000 + + # force API synchronous mode + synchronous true + + # api subcall to request a role + request { + stream_open "{'audio_role':'Emergency', 'endpoint_type': 'sink'}" + set_stream_state "{'state': 'running'}" + } + + # api subcall to request a role + release { + release-role "{'uid':'alsa-hook-client'}" + } + + # map AGL event on Unix signal. Search in event for json key=value + events { + sig-02 {search navi, value quit} + sig-31 {search event, value start} + sig-32 {search event, value start} + } + } + } +} diff --git a/conf.d/project/README.md b/conf.d/project/README.md new file mode 100644 index 0000000..00e3c2f --- /dev/null +++ b/conf.d/project/README.md @@ -0,0 +1,15 @@ + +1) $HOME/.asoundrc or /etc/asound.conf should match you hardware audio configuration. +2) ahl-xxxxxx-config.json should match your .asoundrc config + +Note: config file is search within with following rules: + - default search path is $PROJECT_ROOT/conf.d/project:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME} + - if environment variable "AAAA_CONFIG_PATH" is defined that it is used as search path + - config file should match "ahl-BINDERNAME-config.json" where BINDERNAME is provided through "--name=BINDERNAME" in afb-daemon commande line. + +Note: you may debug Audio-4A from your development tree with: + + afb-daemon --name=afb-audio4a --port=1234 --ws-server=unix:/var/tmp/ahl-4a --cntxtimeout=1 \ + --alias=/monitoring:/home/fulup/opt/afb-monitoring --binding=package/lib/afb-audiohighlevel.so \ + --ldpaths=../../alsa-4a/build/package/lib:../../hal-sample-4a/build/package/lib --workdir=. \ + --roothttp=../htdocs --token= --verbose --verbose \ No newline at end of file diff --git a/conf.d/project/agl-ahl-config.json b/conf.d/project/agl-ahl-config.json deleted file mode 100644 index f49c0be..0000000 --- a/conf.d/project/agl-ahl-config.json +++ /dev/null @@ -1,128 +0,0 @@ -{ - "version": "0.2.0", - "policy_module": "AudioPolicy_v1", - "description": "High-level binding configuration file", - "note": "Devices and routings are always listed in order of priority (for device selection rules)", - "hal_list": ["ensoniq","usbaudio"], - "audio_roles": [ - { - "name": "Warning", - "id": 0, - "description": "Safety-relevant or critical alerts/alarms", - "priority": 100, - "output": [ - "alsa.plug:Warning_Main", - "alsa.plug:Warning_DriverHR" - ], - "actions": [ - "emergency_brake", - "collision_warning", - "blind_spot_warning" - ], - "interupt_behavior": "pause" - }, - { - "name": "Guidance", - "id": 1, - "description": "Important user information where user action is expected (e.g. navigation instruction)", - "priority": 25, - "output": [ - "alsa.plug:Guidance_Main", - "alsa.plug:Guidance_DriverHR" - ], - "actions": [ - "lane_guidance_left", - "lane_guidance_right", - "destination_reached" - ], - "interupt_behavior": "continue" - }, - { - "name": "Notification", - "id": 2, - "description": "HMI or else notifications (e.g. touchscreen events, speech recognition on/off,...)", - "priority": 0, - "output": [ - "alsa.plug:Notification_Main", - "alsa.plug:Notification_DriverHR" - ], - "actions": [ - "home", - "context_switch", - "accept", - "cancel", - "selection_change" - ], - "interupt_behavior": "cancel" - }, - { - "name": "Communication", - "id": 3, - "description": "Voice communications (e.g. handsfree, speech recognition)", - "priority": 50, - "output": [ - "alsa.plug:Communications_Main", - "alsa.plug:Communications_DriverHR", - ], - "input": [ - "alsa.hw:0", - ], - "actions": [ - "bt_device_connected", - "bt_device_disconnected", - "sms_received" - ], - "interupt_behavior": "continue" - }, - { - "name": "Entertainment", - "id": 4, - "description": "Multimedia content (e.g. tuner, media player, etc.)", - "priority": 0, - "output": [ - "alsa.plug:Entertainment_Main", - "alsa.plug:Entertainment_DriverHR", - ], - "interupt_behavior": "pause" - }, - { - "name": "System", - "id": 5, - "description": "System level content or development", - "priority": 100, - "output": [ - "alsa.hw:0" - ], - "input": [ - "alsa.hw:0" - ], - "interupt_behavior": "continue" - }, - { - "name": "Startup", - "id": 6, - "description": "Early (startup) sound", - "priority": 100, - "output": [ - "alsa.hw:0" - ], - "actions": [ - "welcome_sound" - ], - "interupt_behavior": "pause" - }, - { - "name": "Shutdown", - "id": 7, - "description": "Late (shutdown) sound", - "priority": 100, - "output": [ - "alsa.hw:0" - ], - "actions": [ - "goodbye_sound" - ], - "interupt_behavior": "cancel" - } - ] -} diff --git a/conf.d/project/ahl-audiok4a-config.json b/conf.d/project/ahl-audiok4a-config.json new file mode 100644 index 0000000..f49c0be --- /dev/null +++ b/conf.d/project/ahl-audiok4a-config.json @@ -0,0 +1,128 @@ +{ + "version": "0.2.0", + "policy_module": "AudioPolicy_v1", + "description": "High-level binding configuration file", + "note": "Devices and routings are always listed in order of priority (for device selection rules)", + "hal_list": ["ensoniq","usbaudio"], + "audio_roles": [ + { + "name": "Warning", + "id": 0, + "description": "Safety-relevant or critical alerts/alarms", + "priority": 100, + "output": [ + "alsa.plug:Warning_Main", + "alsa.plug:Warning_DriverHR" + ], + "actions": [ + "emergency_brake", + "collision_warning", + "blind_spot_warning" + ], + "interupt_behavior": "pause" + }, + { + "name": "Guidance", + "id": 1, + "description": "Important user information where user action is expected (e.g. navigation instruction)", + "priority": 25, + "output": [ + "alsa.plug:Guidance_Main", + "alsa.plug:Guidance_DriverHR" + ], + "actions": [ + "lane_guidance_left", + "lane_guidance_right", + "destination_reached" + ], + "interupt_behavior": "continue" + }, + { + "name": "Notification", + "id": 2, + "description": "HMI or else notifications (e.g. touchscreen events, speech recognition on/off,...)", + "priority": 0, + "output": [ + "alsa.plug:Notification_Main", + "alsa.plug:Notification_DriverHR" + ], + "actions": [ + "home", + "context_switch", + "accept", + "cancel", + "selection_change" + ], + "interupt_behavior": "cancel" + }, + { + "name": "Communication", + "id": 3, + "description": "Voice communications (e.g. handsfree, speech recognition)", + "priority": 50, + "output": [ + "alsa.plug:Communications_Main", + "alsa.plug:Communications_DriverHR", + ], + "input": [ + "alsa.hw:0", + ], + "actions": [ + "bt_device_connected", + "bt_device_disconnected", + "sms_received" + ], + "interupt_behavior": "continue" + }, + { + "name": "Entertainment", + "id": 4, + "description": "Multimedia content (e.g. tuner, media player, etc.)", + "priority": 0, + "output": [ + "alsa.plug:Entertainment_Main", + "alsa.plug:Entertainment_DriverHR", + ], + "interupt_behavior": "pause" + }, + { + "name": "System", + "id": 5, + "description": "System level content or development", + "priority": 100, + "output": [ + "alsa.hw:0" + ], + "input": [ + "alsa.hw:0" + ], + "interupt_behavior": "continue" + }, + { + "name": "Startup", + "id": 6, + "description": "Early (startup) sound", + "priority": 100, + "output": [ + "alsa.hw:0" + ], + "actions": [ + "welcome_sound" + ], + "interupt_behavior": "pause" + }, + { + "name": "Shutdown", + "id": 7, + "description": "Late (shutdown) sound", + "priority": 100, + "output": [ + "alsa.hw:0" + ], + "actions": [ + "goodbye_sound" + ], + "interupt_behavior": "cancel" + } + ] +} diff --git a/conf.d/project/ahl-fulup4a-config.json b/conf.d/project/ahl-fulup4a-config.json new file mode 100644 index 0000000..1a851a5 --- /dev/null +++ b/conf.d/project/ahl-fulup4a-config.json @@ -0,0 +1,39 @@ +{ + "version": "0.2.0", + "policy_module": "AudioPolicy_v1", + "description": "High-level binding configuration file", + "note": "Devices and routings are always listed in order of priority (for device selection rules)", + "hal_list": ["jabra-usb"], + "audio_roles": [ + { + "name": "Guidance", + "id": 1, + "description": "Important user information where user action is expected (e.g. navigation instruction)", + "priority": 25, + "output": [ + "alsa.plug:NaviPCM" + ], + "interupt_behavior": "continue" + }, + { + "name": "Emergency", + "id": 2, + "description": "HMI or else notifications (e.g. touchscreen events, speech recognition on/off,...)", + "priority": 100, + "output": [ + "alsa.plug:UrgentPCM" + ], + "interupt_behavior": "pause" + }, + { + "name": "Entertainment", + "id": 3, + "description": "Multimedia content (e.g. tuner, media player, etc.)", + "priority": 0, + "output": [ + "alsa.plug:MusicPCM" + ], + "interupt_behavior": "pause" + } + ] +} -- cgit 1.2.3-korg