summaryrefslogtreecommitdiffstats
path: root/mixer-binding/mixer-binding.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixer-binding/mixer-binding.c')
-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;