summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.hpp
blob: 8ffdd76715da1495483c15e26a0dd0f19fd7fa19 (plain)
1
2
3
4
5
6
7
#pragma once

#include <afb/afb-binding>

void onEvent(const char *event, struct json_object *object);
int loadConf();
int execConf();
ht .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#AGL Audio High Level ALSA configuration
#This define 2 sounds card with 8 audio roles each
#The alsa soft volume control name must match with the HAL Control Name

pcm.SoftMixer { 
    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"
}

pcm.Entertainment_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Entertainment_Volume"
 }
}

pcm.Guidance_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Guidance_Volume"
 }
}

pcm.Communications_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Communications_Volume"
 }
}

pcm.Notification_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Notification_Volume"
 }
}

pcm.Warning_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Warning_Volume"
 }
}

pcm.System_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "System_Volume"
 }
}

pcm.Startup_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Startup_Volume"
 }
}

pcm.Shutdown_Main {
 type softvol
 slave.pcm "SoftMixer"
 control{
   name "Shutdown_Volume"
 }
}

# ----------------------------------------------------
# Define one hooked PCM channel per Audio Roles
# ----------------------------------------------------
pcm.Multimedia {
    type hooks
    slave {pcm "Entertainment_Main"}
    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 {
		set_stream_state "{'state':'idle'}"
                stream_close "{}"
            } 
   
            # map AGL event on Unix signal. Search in event for json key=value
            events {   
                sig-02 {search state_event, value 1}
                sig-31 {search state_event, value 2}
                sig-32 {search state_event, value 3}
            }
        }
    }
}

# ----------------------------------------------------
# Define one hooked PCM channel per Audio Roles
# ----------------------------------------------------
pcm.Navigation {
    type hooks
    slave {pcm "Guidance_Main"}
    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 {
                set_stream_state "{'state':'idle'}"
                stream_close "{}"
            } 
   
            # map AGL event on Unix signal. Search in event for json key=value
            events {   
                sig-02 {search state_event, value 1}
                sig-31 {search state_event, value 2}
                sig-32 {search state_event, value 3}
            }
        }
    }
}