aboutsummaryrefslogtreecommitdiffstats
path: root/mixer-binding
diff options
context:
space:
mode:
authorPierre MARZIN <pierre.marzin@iot.bzh>2019-04-01 10:35:57 +0200
committerPierre Marzin <pierre.marzin@iot.bzh>2019-04-02 08:16:29 +0000
commit36721c55b616bdce8b8f79ff3c7042ef54d18478 (patch)
tree652c6cd69ef9ce9727965d752c4d0c741d264afc /mixer-binding
parent074e6871959279c4aed3e162f21f677e08338b3a (diff)
pre-init: Add a config detection
Scan the loaded modules during pre-init to know which config file to load. If Avirt core module is loaded then load the avirt config file. Otherwise, load the default config file. Change the config file name in order to use the prefix to select them. Change-Id: I8f9d5ed568fa20b06ac3bef443a2392de26c8235 Signed-off-by: Pierre MARZIN <pierre.marzin@iot.bzh>
Diffstat (limited to 'mixer-binding')
-rw-r--r--mixer-binding/mixer-binding.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/mixer-binding/mixer-binding.c b/mixer-binding/mixer-binding.c
index 64a7f05..f2b6b05 100644
--- a/mixer-binding/mixer-binding.c
+++ b/mixer-binding/mixer-binding.c
@@ -22,6 +22,9 @@
#include "mixer-binding.h"
+#define size_temp 512
+
+enum smixer_audio_mode_t { DEFAULT, AVIRT };
// default api to print log when apihandle not avalaible
PUBLIC afb_api_t AFB_default;
@@ -102,12 +105,44 @@ PUBLIC int afbBindingEntry(afb_api_t apiHandle) {
AFB_default = apiHandle;
+ FILE *fp;
+ char temp[size_temp];
+ char *prefix;
+ enum smixer_audio_mode_t smixer_audio_mode = DEFAULT;
+
AFB_API_NOTICE (apiHandle, "Controller in afbBindingEntry");
- const char *dirList= getenv("CONTROL_CONFIG_PATH");
+ const char *dirList = getenv("CONTROL_CONFIG_PATH");
if (!dirList) dirList=CONTROL_CONFIG_PATH;
- const char *configPath = CtlConfigSearch(apiHandle, dirList, "smixer");
+ // Select correct config file
+ char *configPath = getenv("SMIXER_CONFIG_FILE_PATH");
+ if (!configPath) {
+ // Do a module detection to know which audio config we need (avirt or aloop=default)
+ if((fp = fopen("/proc/modules", "r")) == NULL) {
+ goto OnErrorExit;
+ }
+
+ while(fgets(temp, size_temp, fp) != NULL) {
+ if((strstr(temp, "snd_avirt_core")) != NULL) {
+ AFB_API_NOTICE (apiHandle, "CTL-INIT: AVIRT module is loaded, assume that mixer needs avirt config.");
+ smixer_audio_mode = AVIRT;
+ break;
+ }
+ }
+
+ if(fp) fclose(fp);
+
+ if(smixer_audio_mode == AVIRT) {
+ prefix = "smixer-avirt";
+ } else {
+ prefix = "smixer-default";
+ }
+
+ configPath = CtlConfigSearch(apiHandle, dirList, prefix);
+ AFB_API_NOTICE (apiHandle, "CTL-INIT: configPath=%s", configPath);
+ }
+
if (!configPath) {
AFB_API_ERROR(apiHandle, "CtlPreInit: No smixer-%s-* config found in %s ", GetBinderName(), dirList);
goto OnErrorExit;