aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AlsaSound/CoreBinding/AlsaUseCase.c127
-rw-r--r--Common/AudioCommonLib.c7
-rw-r--r--Common/AudioCommonLib.h2
-rw-r--r--README.md19
4 files changed, 77 insertions, 78 deletions
diff --git a/AlsaSound/CoreBinding/AlsaUseCase.c b/AlsaSound/CoreBinding/AlsaUseCase.c
index ccea4fa..8e23e3c 100644
--- a/AlsaSound/CoreBinding/AlsaUseCase.c
+++ b/AlsaSound/CoreBinding/AlsaUseCase.c
@@ -233,68 +233,6 @@ STATIC json_object *ucmGetValue (ucmHandleT *ucmHandle, const char *verb, const
return (NULL);
}
-PUBLIC void alsaUseCaseSet(struct afb_req request) {
- int err, ucmIdx;
- queryValuesT queryValues;
- json_object *jResponse = json_object_new_object();
-
- err = alsaCheckQuery (request, &queryValues);
- if (err) goto OnErrorExit;
-
- ucmIdx = alsaUseCaseOpen (request, &queryValues, TRUE);
- if (ucmIdx < 0) goto OnErrorExit;
-
- snd_use_case_mgr_t *ucmMgr= ucmHandles[ucmIdx].ucm;
- const char *cardName= ucmHandles[ucmIdx].cardName;
-
- const char *verb = afb_req_value(request, "verb");
- const char *mod = afb_req_value(request, "mod");
- const char *dev = afb_req_value(request, "dev");
- // Known identifiers: _verb - set current verb = value _enadev - enable given device = value _disdev - disable given device = value _swdev/{old_device} - new_device = value
-
- if (verb) {
- err = snd_use_case_set (ucmMgr, "_verb", verb);
- if (err) {
- afb_req_fail_f (request, "ucmset-verb", "SndCard devid=[%s] name=[%s] Invalid UCM verb=[%s] err=%s", queryValues.devid, cardName, verb, snd_strerror(err));
- goto OnErrorExit;
- }
- }
-
- if (dev) {
- err = snd_use_case_set (ucmMgr, "_enadev", dev);
- if (err) {
- afb_req_fail_f (request, "ucmset-dev", "SndCard devid=[%s] name=[%s] Invalid UCMverb=[%s] dev=%s err=%s", queryValues.devid, cardName, verb, dev, snd_strerror(err));
- goto OnErrorExit;
- }
- }
-
- if (mod) {
- err = snd_use_case_set (ucmMgr, "_enamod", mod);
- if (err) {
- afb_req_fail_f (request, "ucmset-mod", "SndCard devid=[%s] name=[%s] Invalid UCM verb=[%s] mod=[%s] err=%s", queryValues.devid, cardName, verb, mod, snd_strerror(err));
- goto OnErrorExit;
- }
- }
-
- if (queryValues.quiet <= 3) {
- json_object *jValue;
-
- jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, dev, "OutputDspName");
- if (jValue) json_object_object_add (jResponse, "OutputDspName", jValue);
-
- jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, dev, "PlaybackPCM");
- if (jValue) json_object_object_add (jResponse, "PlaybackPCM", jValue);
-
- jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, mod, "CapturePCM");
- if (jValue) json_object_object_add (jResponse, "CapturePCM", jValue);
- }
- afb_req_success (request, jResponse, NULL);
-
- OnErrorExit:
- return;
-}
-
-
PUBLIC void alsaUseCaseGet (struct afb_req request) {
int err, ucmIdx, labelCount;
queryValuesT queryValues;
@@ -379,6 +317,71 @@ PUBLIC void alsaUseCaseGet (struct afb_req request) {
return;
}
+PUBLIC void alsaUseCaseSet(struct afb_req request) {
+ int err, ucmIdx;
+ queryValuesT queryValues;
+ json_object *jResponse = json_object_new_object();
+
+ err = alsaCheckQuery (request, &queryValues);
+ if (err) goto OnErrorExit;
+
+ ucmIdx = alsaUseCaseOpen (request, &queryValues, TRUE);
+ if (ucmIdx < 0) goto OnErrorExit;
+
+ snd_use_case_mgr_t *ucmMgr= ucmHandles[ucmIdx].ucm;
+ const char *cardName= ucmHandles[ucmIdx].cardName;
+
+ const char *verb = afb_req_value(request, "verb");
+ const char *mod = afb_req_value(request, "mod");
+ const char *dev = afb_req_value(request, "dev");
+ // Known identifiers: _verb - set current verb = value _enadev - enable given device = value _disdev - disable given device = value _swdev/{old_device} - new_device = value
+
+ if (verb) {
+ err = snd_use_case_set (ucmMgr, "_verb", verb);
+ if (err) {
+ afb_req_fail_f (request, "ucmset-verb", "SndCard devid=[%s] name=[%s] Invalid UCM verb=[%s] err=%s", queryValues.devid, cardName, verb, snd_strerror(err));
+ goto OnErrorExit;
+ }
+ }
+
+ if (dev) {
+ err = snd_use_case_set (ucmMgr, "_enadev", dev);
+ if (err) {
+ afb_req_fail_f (request, "ucmset-dev", "SndCard devid=[%s] name=[%s] Invalid UCMverb=[%s] dev=%s err=%s", queryValues.devid, cardName, verb, dev, snd_strerror(err));
+ goto OnErrorExit;
+ }
+ }
+
+ if (mod) {
+ err = snd_use_case_set (ucmMgr, "_enamod", mod);
+ if (err) {
+ afb_req_fail_f (request, "ucmset-mod", "SndCard devid=[%s] name=[%s] Invalid UCM verb=[%s] mod=[%s] err=%s", queryValues.devid, cardName, verb, mod, snd_strerror(err));
+ goto OnErrorExit;
+ }
+ }
+
+ // label are requested transfert request to get
+ if (afb_req_value(request, "values")) return alsaUseCaseGet(request);
+
+ if (queryValues.quiet <= 3) {
+ json_object *jValue;
+
+ jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, dev, "OutputDspName");
+ if (jValue) json_object_object_add (jResponse, "OutputDspName", jValue);
+
+ jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, dev, "PlaybackPCM");
+ if (jValue) json_object_object_add (jResponse, "PlaybackPCM", jValue);
+
+ jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, mod, "CapturePCM");
+ if (jValue) json_object_object_add (jResponse, "CapturePCM", jValue);
+ }
+ afb_req_success (request, jResponse, NULL);
+
+ OnErrorExit:
+ return;
+}
+
+
PUBLIC void alsaUseCaseReset (struct afb_req request) {
int err, ucmIdx;
diff --git a/Common/AudioCommonLib.c b/Common/AudioCommonLib.c
index 0517e8e..0055896 100644
--- a/Common/AudioCommonLib.c
+++ b/Common/AudioCommonLib.c
@@ -53,15 +53,16 @@ OnErrorExit:
return (-1);
}
+
// This function should be part of Generic AGL Framework
-PUBLIC json_object* afb_service_call_sync(struct afb_service srvitf, struct afb_req request, char* api, char* verb, struct json_object* queryurl, void *handle) {
+PUBLIC json_object* afb_service_call_sync(struct afb_service srvitf, struct afb_req request, char* api, char* verb, struct json_object* queryurl) {
json_object* response = NULL;
int status = 0;
sem_t semid;
// Nested procedure are allow in GNU and allow us to keep caller stack valid
- void callback(void *handle, int iserror, struct json_object * result) {
+ void callback(void *handle, int iserror, struct json_object *result) {
// Process Basic Error
if (!cbCheckResponse(request, iserror, result)) {
@@ -88,7 +89,7 @@ OnExitCB:
}
// Call service and wait for call back to finish before moving any further
- afb_service_call(srvitf, "alsacore", "getctl", queryurl, callback, handle);
+ afb_service_call(srvitf, api, verb, queryurl, callback, NULL);
sem_wait(&semid);
OnExit:
diff --git a/Common/AudioCommonLib.h b/Common/AudioCommonLib.h
index ebee389..ffefbfc 100644
--- a/Common/AudioCommonLib.h
+++ b/Common/AudioCommonLib.h
@@ -61,7 +61,7 @@ typedef enum {
} halCtlsEnumT;
PUBLIC int cbCheckResponse(struct afb_req request, int iserror, struct json_object *result) ;
-PUBLIC json_object* afb_service_call_sync(struct afb_service srvitf, struct afb_req request, char* api, char* verb, struct json_object* queryurl, void *handle);
+PUBLIC json_object* afb_service_call_sync(struct afb_service srvitf, struct afb_req request, char* api, char* verb, struct json_object* queryurl);
PUBLIC void pingtest(struct afb_req request);
#endif /* AUDIOCOMMON_H */
diff --git a/README.md b/README.md
index 44b8ec2..fb98fc8 100644
--- a/README.md
+++ b/README.md
@@ -30,11 +30,13 @@ AFB_daemon dependency on Standard Linux Distributions
```
# Might want to add following variables into ~/.bashrc
# export CC=gcc-5; export CXX=g++-5 # if using gcc5
- echo "export DEST=$HOME/opt" >>~/.bashrc
- echo "export LD_LIBRARY_PATH=$DEST/lib64" >>~/.bashrc
- echo "export LIBRARY_PATH=$DEST/lib64" >>~/.bashrc
- echo "export PKG_CONFIG_PATH=$DEST/lib64/pkgconfig" >>~/.bashrc
- echo "export PATH=$DEST/bin:$PATH" >>~/.bashrc
+
+ echo 'export LIBPOSTFIX=64'>>~/.bashrc
+ echo 'export DEST=$HOME/opt' >>~/.bashrc
+ echo 'export LD_LIBRARY_PATH=$DEST/lib${LIBPOSTFIX}' >>~/.bashrc
+ echo 'export LIBRARY_PATH=$DEST/lib${LIBPOSTFIX}' >>~/.bashrc
+ echo 'export PKG_CONFIG_PATH=$DEST/lib${LIBPOSTFIX}/pkgconfig' >>~/.bashrc
+ echo 'export PATH=$DEST/bin:$PATH' >>~/.bashrc
source ~/.bashrc
# install AGL pached version of LibMicroHttpd
@@ -55,13 +57,6 @@ AFB_daemon dependency on Standard Linux Distributions
make install
```
-Other Audio Binding Dependencies
-----------------------------------
- afb-daemon
- alsa-devel
-
- Edit CMakeList.txt to tune options
-
```
# Compile binding