diff options
Diffstat (limited to 'conf.d')
-rw-r--r-- | conf.d/cmake/config.cmake | 4 | ||||
-rw-r--r-- | conf.d/project/etc/4a-softmixer-config.json | 42 | ||||
-rw-r--r-- | conf.d/project/etc/4a-softmixer-test.json | 75 | ||||
-rw-r--r-- | conf.d/project/lua.d/softmixer-simple-test.lua (renamed from conf.d/project/lua.d/softmixer-simple.lua) | 97 |
4 files changed, 106 insertions, 112 deletions
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index afba6b7..5f5bc23 100644 --- a/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -131,8 +131,8 @@ list(APPEND link_libraries afb-helpers) set(CONTROL_SUPPORT_LUA 1) add_definitions(-DCONTROL_PLUGIN_PATH="${CMAKE_BINARY_DIR}/package/lib/plugins:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib/plugins") -add_definitions(-DCONTROL_CONFIG_PATH="${CMAKE_BINARY_DIR}/package/etc:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc") -add_definitions(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/lua.d:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/data") +add_definitions(-DCONTROL_CONFIG_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/etc:${CMAKE_BINARY_DIR}/package/etc:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc") +add_definitions(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/lua.d:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/var") add_definitions(-DCTL_PLUGIN_MAGIC=987456123) add_definitions(-DUSE_API_DYN=1 -DAFB_BINDING_VERSION=dyn) diff --git a/conf.d/project/etc/4a-softmixer-config.json b/conf.d/project/etc/4a-softmixer-config.json deleted file mode 100644 index e67709f..0000000 --- a/conf.d/project/etc/4a-softmixer-config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json", - "metadata": { - "uid": "Soft Mixer", - "version": "1.0", - "api": "softmixer", - "info": "Soft Mixer emulating hardware mixer" - }, - "resources": [ - { - "uid": "alsa-softmixer", - "info": "Map alsa-loop subdevices to 4A HAL streams", - "spath":"./plugins/alsa:../conf.d/project/lua.d", - "libs": ["alsa-router.ctlso", "softmixer-simple.lua"], - "lua": {"prefix":"smix","functions": ["snd_cards", "snd_zones", "snd_loops", "snd_streams"]} - } - ], - - "onload": [ - { - "uid": "init-soft-mixer", - "info": "Initialise Audio Router", - "action": "lua://alsa-softmixer#_init_softmixer_" - } - ], - - "controls": [ - { - "uid": "mixer-config", - "action": "lua://alsa-softmixer#_mixer_config_" - }, - { - "uid": "snd-cards", - "action": "plugin://alsa-softmixer#snd_cards" - }, - { - "uid": "snd-zone", - "action": "plugin://alsa-softmixer#snd_zones" - } - ] - -} diff --git a/conf.d/project/etc/4a-softmixer-test.json b/conf.d/project/etc/4a-softmixer-test.json new file mode 100644 index 0000000..f363a55 --- /dev/null +++ b/conf.d/project/etc/4a-softmixer-test.json @@ -0,0 +1,75 @@ +{ + "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json", + "metadata": { + "uid": "Soft Mixer", + "version": "1.0", + "api": "softmixer", + "info": "Soft Mixer emulating hardware mixer" + }, + "resources": [ + { + "uid": "softmixer", + "info": "Map alsa-loop subdevices to 4A HAL streams", + "spath": "./plugins/alsa:../conf.d/project/lua.d", + "libs": ["alsa-softmixer.ctlso", "softmixer-simple-test.lua"], + "lua": { + "prefix": "smix", + "functions": ["_mixer_new_"] + } + } + ], + + "onload": [ + { + "uid": "init-soft-mixer", + "info": "Initialise Audio Router", + "action": "lua://softmixer#_mixer_simple_test_" + } + ], + "controls": [ + { + "uid": "new", + "action": "plugin://softmixer#_mixer_new_", + "args": { + "devices": { + "playback": 0, + "capture": 1 + }, + "subdevs": [ + { + "subdev": 0, + "numid": 51 + }, + { + "subdev": 1, + "numid": 57 + }, + { + "subdev": 2, + "numid": 63 + }, + { + "subdev": 3, + "numid": 69 + }, + { + "subdev": 4, + "numid": 75 + }, + { + "subdev": 5, + "numid": 81 + }, + { + "subdev": 6, + "numid": 87 + }, + { + "subdev": 7, + "numid": 93 + } + ] + } + } + ] +} diff --git a/conf.d/project/lua.d/softmixer-simple.lua b/conf.d/project/lua.d/softmixer-simple-test.lua index e78eacd..6d6dffc 100644 --- a/conf.d/project/lua.d/softmixer-simple.lua +++ b/conf.d/project/lua.d/softmixer-simple-test.lua @@ -30,24 +30,14 @@ end -- Display receive arguments and echo them to caller -function _mixer_config_ (source, args) +function _mixer_simple_test_ (source, args) do local error local response - -- ==================== Default rate =========================== - - local audio_defaults = { - ["rate"] = 48000, - } - - -- ======================= Loop PCM =========================== - - local snd_aloop = { - ["uid"] = "Alsa-Loop", - ["devpath"] = "/dev/snd/by-path/platform-snd_aloop.0", + -- ================== Default Alsa snd-aloop numid and subdev config + local aloop = { ["devices"] = {["playback"]=0,["capture"]=1}, - ["params"] = audio_defaults, ["subdevs"] = { {["subdev"]= 0, ["numid"]= 51}, {["subdev"]= 1, ["numid"]= 57}, @@ -60,17 +50,23 @@ function _mixer_config_ (source, args) } } - error,response= smix:snd_loops (source, snd_aloop) - if (error ~= 0) then - AFB:error (source, "--InLua-- smix:snd_loops fail to attach sndcards=%s", Dump_Table(aloop)) - goto OnErrorExit - else - AFB:notice (source, "--InLua-- smix:snd_loops done response=%s\n", Dump_Table(response)) - end - + -- ==================== Default rate =========================== + + local audio_defaults = { + ["rate"] = 48000, + } + + -- ======================= Loop PCM =========================== + local snd_aloop = { + ["uid"] = "Alsa-Loop", + ["devpath"] = "/dev/snd/by-path/platform-snd_aloop.0", + ["params"] = audio_defaults, + ["devices"] = aloop.devices, + ["subdevs"] = aloop.subdevs, + } - -- ============================= Sound Cards =================== + -- ============================= Sound Cards =================== local snd_yamaha = { ["uid"]= "YAMAHA-APU70", ["devpath"]= "/dev/snd/by-id/usb-YAMAHA_Corporation_YAMAHA_AP-U70_USB_Audio_00-00", @@ -91,21 +87,8 @@ function _mixer_config_ (source, args) } } - -- group sound card as one multi channels card - local sndcards= { - snd_yamaha, - } - - error,response= smix:snd_cards (source, sndcards) - if (error ~= 0) then - AFB:error (source, "--InLua-- smix:snd_cards fail to attach sndcards=%s", Dump_Table(sndcards)) - goto OnErrorExit - else - AFB:notice (source, "--InLua-- smix:snd_cards done response=%s\n", Dump_Table(response)) - end -- ============================= Zones =================== - local zone_front= { ["uid"] = "front-seats", ["type"] = "playback", @@ -115,20 +98,7 @@ function _mixer_config_ (source, args) } } - local multi_zones = { - zone_front, - } - - error,response= smix:snd_zones (source, multi_zones) - if (error ~= 0) then - AFB:error (source, "--InLua-- smix:snd_zones fail to attach sndcards=%s", Dump_Table(multi_zones)) - goto OnErrorExit - else - AFB:notice (source, "--InLua-- smix:snd_zones done response=%s\n", Dump_Table(response)) - end - -- =================== Audio Stream ============================ - local stream_music= { ["uid"] = "multimedia", ["zone"] = "front-seats", @@ -143,20 +113,24 @@ function _mixer_config_ (source, args) ["mute"] = false, } - local snd_streams = { - stream_music, - stream_navigation, + --- ================ Create Mixer ========================= + local MyMixer= { + ["uid"]="Simple_Mixer", + ["backend"] = {snd_yamaha}, + ["frontend"]= {snd_aloop}, + ["zones"] = {zone_front}, + ["streams"] = {stream_music,stream_navigation}, } - error,response= smix:snd_streams (source, snd_streams) + local error,response= smix:_mixer_new_ (source, MyMixer) if (error ~= 0) then - AFB:error (source, "--InLua-- smix:snd_streams fail to attach sndcards=%s", Dump_Table(aloop)) + AFB:error (source, "--InLua-- smix:_mixer_new_ fail config=%s", Dump_Table(aloop)) goto OnErrorExit else - AFB:notice (source, "--InLua-- smix:streams_loops done response=%s\n", Dump_Table(response)) + AFB:notice (source, "--InLua-- smix:_mixer_new_ done response=%s\n", Dump_Table(response)) end - + -- ================== Happy End ============================= AFB:notice (source, "--InLua-- _mixer_config_ done") return 0 end @@ -166,16 +140,3 @@ function _mixer_config_ (source, args) AFB:error (source, "--InLua-- snd_attach fail") return 1 -- unhappy end -- end - --- Display receive arguments and echo them to caller -function _init_softmixer_ (source, args) - - printf ("*********** in print ") - -- create event to push change audio roles to potential listeners - _EventHandle=AFB:evtmake(source, "control") - - _mixer_config_ (source, args) - -end - -printf ("*********** load done ") |