summaryrefslogtreecommitdiffstats
path: root/ALSA-afb/Alsa-Ucm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ALSA-afb/Alsa-Ucm.c')
-rw-r--r--ALSA-afb/Alsa-Ucm.c456
1 files changed, 227 insertions, 229 deletions
diff --git a/ALSA-afb/Alsa-Ucm.c b/ALSA-afb/Alsa-Ucm.c
index ee2b36d..016fe10 100644
--- a/ALSA-afb/Alsa-Ucm.c
+++ b/ALSA-afb/Alsa-Ucm.c
@@ -32,7 +32,7 @@
- alsaucm -c 'HDA Intel PCH' set _verb HiFi set _enadev Headphone set _enamod RecordMedia
- alsaucm -c 'HDA Intel PCH' set _verb HiFi get OutputDspName//
-*/
+ */
#define _GNU_SOURCE // needed for vasprintf
#include <alsa/asoundlib.h>
@@ -42,75 +42,75 @@
#include "Alsa-ApiHat.h"
typedef struct {
- snd_use_case_mgr_t *ucm;
- int cardId;
- char *cardName;
-} ucmHandleT;
+ snd_use_case_mgr_t *ucm;
+ int cardId;
+ char *cardName;
+} ucmHandleT;
static ucmHandleT ucmHandles[MAX_SND_CARD];
// Cache opened UCM handles
-STATIC int alsaUseCaseOpen (struct afb_req request, queryValuesT *queryValues, int allowNewMgr) {
- snd_ctl_t *ctlDev;
+
+STATIC int alsaUseCaseOpen(struct afb_req request, queryValuesT *queryValues, int allowNewMgr) {
+ snd_ctl_t *ctlDev;
snd_ctl_card_info_t *cardinfo;
snd_use_case_mgr_t *ucmHandle;
const char *cardName;
- int cardId, idx, idxFree=-1, err;
-
+ int cardId, idx, idxFree = -1, err;
+
// open control interface for devid
err = snd_ctl_open(&ctlDev, queryValues->devid, SND_CTL_READONLY);
if (err < 0) {
- ctlDev=NULL;
- afb_req_fail_f (request, "devid-unknown", "SndCard devid=[%s] Not Found err=%d", queryValues->devid, err);
+ ctlDev = NULL;
+ afb_req_fail_f(request, "devid-unknown", "SndCard devid=[%s] Not Found err=%d", queryValues->devid, err);
goto OnErrorExit;
}
-
- snd_ctl_card_info_alloca(&cardinfo);
- if ((err = snd_ctl_card_info(ctlDev, cardinfo)) < 0) {
- afb_req_fail_f (request, "devid-invalid", "SndCard devid=[%s] Not Found err=%s", queryValues->devid, snd_strerror(err));
+
+ snd_ctl_card_info_alloca(&cardinfo);
+ if ((err = snd_ctl_card_info(ctlDev, cardinfo)) < 0) {
+ afb_req_fail_f(request, "devid-invalid", "SndCard devid=[%s] Not Found err=%s", queryValues->devid, snd_strerror(err));
goto OnErrorExit;
}
-
+
// search for an existing subscription and mark 1st free slot
- cardId = snd_ctl_card_info_get_card(cardinfo);
- for (idx= 0; idx < MAX_SND_CARD; idx ++) {
- if (ucmHandles[idx].ucm != NULL) {
- if (ucmHandles[idx].cardId == cardId) goto OnSuccessExit;
- } else if (idxFree == -1) idxFree= idx;
+ cardId = snd_ctl_card_info_get_card(cardinfo);
+ for (idx = 0; idx < MAX_SND_CARD; idx++) {
+ if (ucmHandles[idx].ucm != NULL) {
+ if (ucmHandles[idx].cardId == cardId) goto OnSuccessExit;
+ } else if (idxFree == -1) idxFree = idx;
};
-
+
if (!allowNewMgr) {
- afb_req_fail_f (request, "ucm-nomgr", "SndCard devid=[%s] no exiting UCM manager session", queryValues->devid);
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucm-nomgr", "SndCard devid=[%s] no exiting UCM manager session", queryValues->devid);
+ goto OnErrorExit;
}
if (idxFree < 0 && idx == MAX_SND_CARD) {
- afb_req_fail_f (request, "ucm-toomany", "SndCard devid=[%s] too many open UCM Max=%d", queryValues->devid, MAX_SND_CARD);
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucm-toomany", "SndCard devid=[%s] too many open UCM Max=%d", queryValues->devid, MAX_SND_CARD);
+ goto OnErrorExit;
}
-
+
idx = idxFree;
- cardName = snd_ctl_card_info_get_name(cardinfo);
+ cardName = snd_ctl_card_info_get_name(cardinfo);
err = snd_use_case_mgr_open(&ucmHandle, cardName);
if (err) {
- afb_req_fail_f (request, "ucm-open", "SndCard devid=[%s] name=[%s] No UCM Profile err=%s", queryValues->devid, cardName, snd_strerror(err));
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucm-open", "SndCard devid=[%s] name=[%s] No UCM Profile err=%s", queryValues->devid, cardName, snd_strerror(err));
+ goto OnErrorExit;
}
ucmHandles[idx].ucm = ucmHandle;
- ucmHandles[idx].cardId = cardId;
- ucmHandles[idx].cardName = strdup(cardName);
+ ucmHandles[idx].cardId = cardId;
+ ucmHandles[idx].cardName = strdup(cardName);
- OnSuccessExit:
- if (ctlDev) snd_ctl_close(ctlDev);
+OnSuccessExit:
+ if (ctlDev) snd_ctl_close(ctlDev);
return idx;
-
- OnErrorExit:
- if (ctlDev) snd_ctl_close(ctlDev);
+
+OnErrorExit:
+ if (ctlDev) snd_ctl_close(ctlDev);
return -1;
}
-
-PUBLIC void alsaUseCaseQuery(struct afb_req request) {
+PUBLIC void alsaUseCaseQuery(struct afb_req request) {
int verbCount, ucmIdx;
const char **verbList;
snd_use_case_mgr_t *ucmHandle;
@@ -118,318 +118,316 @@ PUBLIC void alsaUseCaseQuery(struct afb_req request) {
json_object *ucmJs;
const char *cardName;
- json_object *queryJ = alsaCheckQuery (request, &queryValues);
+ json_object *queryJ = alsaCheckQuery(request, &queryValues);
if (!queryJ) goto OnErrorExit;
-
- ucmIdx = alsaUseCaseOpen (request, &queryValues, TRUE);
+
+ ucmIdx = alsaUseCaseOpen(request, &queryValues, TRUE);
if (ucmIdx < 0) goto OnErrorExit;
ucmHandle = ucmHandles [ucmIdx].ucm;
- cardName = ucmHandles [ucmIdx].cardName;
-
- verbCount = snd_use_case_get_list (ucmHandle, "_verbs", &verbList);
+ cardName = ucmHandles [ucmIdx].cardName;
+
+ verbCount = snd_use_case_get_list(ucmHandle, "_verbs", &verbList);
if (verbCount < 0) {
- afb_req_fail_f (request, "ucm-list", "SndCard devid=[%s] name=[%s] No UCM Verbs", queryValues.devid, cardName);
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucm-list", "SndCard devid=[%s] name=[%s] No UCM Verbs", queryValues.devid, cardName);
+ goto OnErrorExit;
}
-
+
ucmJs = json_object_new_array();
- for (int idx=0; idx < verbCount; idx +=2) {
+ for (int idx = 0; idx < verbCount; idx += 2) {
int devCount, modCount, tqCount;
const char **devList, **modList, **tqList;
json_object *ucmJ = json_object_new_object();
char identifier[32];
-
- json_object_object_add (ucmJ, "verb", json_object_new_string(verbList[idx]));
- if (verbList[idx+1]) json_object_object_add (ucmJ, "info", json_object_new_string(verbList[idx+1]));
-
- AFB_DEBUG ("Verb[%d] Action=%s Info=%s", idx, verbList[idx], verbList[idx+1]);
-
- snprintf (identifier, sizeof(identifier), "_devices/%s", verbList[idx]);
- devCount = snd_use_case_get_list (ucmHandle, identifier, &devList);
+
+ json_object_object_add(ucmJ, "verb", json_object_new_string(verbList[idx]));
+ if (verbList[idx + 1]) json_object_object_add(ucmJ, "info", json_object_new_string(verbList[idx + 1]));
+
+ AFB_DEBUG("Verb[%d] Action=%s Info=%s", idx, verbList[idx], verbList[idx + 1]);
+
+ snprintf(identifier, sizeof (identifier), "_devices/%s", verbList[idx]);
+ devCount = snd_use_case_get_list(ucmHandle, identifier, &devList);
if (devCount > 0) {
json_object *devsJ = json_object_new_array();
-
- for (int jdx=0; jdx < devCount; jdx+=2) {
+
+ for (int jdx = 0; jdx < devCount; jdx += 2) {
json_object *devJ = json_object_new_object();
- AFB_DEBUG ("device[%d] Action=%s Info=%s", jdx, devList[jdx], devList[jdx+1]);
- json_object_object_add (devJ, "dev", json_object_new_string(devList[jdx]));
- if (devList[jdx+1]) json_object_object_add (devJ, "info", json_object_new_string(devList[jdx+1]));
- json_object_array_add (devsJ, devJ);
+ AFB_DEBUG("device[%d] Action=%s Info=%s", jdx, devList[jdx], devList[jdx + 1]);
+ json_object_object_add(devJ, "dev", json_object_new_string(devList[jdx]));
+ if (devList[jdx + 1]) json_object_object_add(devJ, "info", json_object_new_string(devList[jdx + 1]));
+ json_object_array_add(devsJ, devJ);
}
- json_object_object_add(ucmJ,"devices", devsJ);
+ json_object_object_add(ucmJ, "devices", devsJ);
snd_use_case_free_list(devList, devCount);
}
-
- snprintf (identifier, sizeof(identifier), "_modifiers/%s", verbList[idx]);
- modCount = snd_use_case_get_list (ucmHandle, identifier, &modList);
+
+ snprintf(identifier, sizeof (identifier), "_modifiers/%s", verbList[idx]);
+ modCount = snd_use_case_get_list(ucmHandle, identifier, &modList);
if (modCount > 0) {
json_object *modsJ = json_object_new_array();
-
- for (int jdx=0; jdx < modCount; jdx+=2) {
+
+ for (int jdx = 0; jdx < modCount; jdx += 2) {
json_object *modJ = json_object_new_object();
- AFB_DEBUG ("modifier[%d] Action=%s Info=%s", jdx, modList[jdx], modList[jdx+1]);
- json_object_object_add (modJ, "mod", json_object_new_string(modList[jdx]));
- if (modList[jdx+1]) json_object_object_add (modJ, "info", json_object_new_string(modList[jdx+1]));
- json_object_array_add (modsJ, modJ);
+ AFB_DEBUG("modifier[%d] Action=%s Info=%s", jdx, modList[jdx], modList[jdx + 1]);
+ json_object_object_add(modJ, "mod", json_object_new_string(modList[jdx]));
+ if (modList[jdx + 1]) json_object_object_add(modJ, "info", json_object_new_string(modList[jdx + 1]));
+ json_object_array_add(modsJ, modJ);
}
- json_object_object_add(ucmJ,"modifiers", modsJ);
+ json_object_object_add(ucmJ, "modifiers", modsJ);
snd_use_case_free_list(modList, modCount);
}
- snprintf (identifier, sizeof(identifier), "TQ/%s", verbList[idx]);
- tqCount = snd_use_case_get_list (ucmHandle, identifier, &tqList);
+ snprintf(identifier, sizeof (identifier), "TQ/%s", verbList[idx]);
+ tqCount = snd_use_case_get_list(ucmHandle, identifier, &tqList);
if (tqCount > 0) {
json_object *tqsJ = json_object_new_array();
-
- for (int jdx=0; jdx < tqCount; jdx+=2) {
+
+ for (int jdx = 0; jdx < tqCount; jdx += 2) {
json_object *tqJ = json_object_new_object();
- AFB_DEBUG ("toneqa[%d] Action=%s Info=%s", jdx, tqList[jdx], tqList[jdx+1]);
- json_object_object_add (tqJ, "tq", json_object_new_string(tqList[jdx]));
- if (tqList[jdx+1]) json_object_object_add (tqJ, "info", json_object_new_string(tqList[jdx+1]));
- json_object_array_add (tqsJ, tqJ);
+ AFB_DEBUG("toneqa[%d] Action=%s Info=%s", jdx, tqList[jdx], tqList[jdx + 1]);
+ json_object_object_add(tqJ, "tq", json_object_new_string(tqList[jdx]));
+ if (tqList[jdx + 1]) json_object_object_add(tqJ, "info", json_object_new_string(tqList[jdx + 1]));
+ json_object_array_add(tqsJ, tqJ);
}
- json_object_object_add(ucmJ,"tqs", tqsJ);
+ json_object_object_add(ucmJ, "tqs", tqsJ);
snd_use_case_free_list(tqList, tqCount);
}
-
- json_object_array_add (ucmJs, ucmJ);
+
+ json_object_array_add(ucmJs, ucmJ);
}
-
- afb_req_success (request, ucmJs, NULL);
+
+ afb_req_success(request, ucmJs, NULL);
snd_use_case_free_list(verbList, verbCount);
-
- OnErrorExit:
+
+OnErrorExit:
return;
}
-STATIC json_object *ucmGetValue (ucmHandleT *ucmHandle, const char *verb, const char *mod, const char *label) {
+STATIC json_object *ucmGetValue(ucmHandleT *ucmHandle, const char *verb, const char *mod, const char *label) {
char identifier[80];
char *value;
int err;
json_object *jValue;
-
+
// handle optional parameters
- if (!mod) mod="";
- if (!verb) verb="";
-
+ if (!mod) mod = "";
+ if (!verb) verb = "";
+
if (!label) {
- AFB_NOTICE ("ucmGetValue cardname=[%s] value label missing", ucmHandle->cardName);
- goto OnErrorExit;
+ AFB_NOTICE("ucmGetValue cardname=[%s] value label missing", ucmHandle->cardName);
+ goto OnErrorExit;
}
-
- snprintf (identifier, sizeof(identifier), "%s/%s/%s", label, mod, verb);
- err = snd_use_case_get (ucmHandle->ucm, identifier, (const char**)&value); // Note: value casting is a known "FEATURE" of AlsaUCM API
+
+ snprintf(identifier, sizeof (identifier), "%s/%s/%s", label, mod, verb);
+ err = snd_use_case_get(ucmHandle->ucm, identifier, (const char**) &value); // Note: value casting is a known "FEATURE" of AlsaUCM API
if (err) {
- AFB_DEBUG ("ucmGetValue cardname=[%s] identifier=[%s] error=%s", ucmHandle->cardName, identifier, snd_strerror (err));
+ AFB_DEBUG("ucmGetValue cardname=[%s] identifier=[%s] error=%s", ucmHandle->cardName, identifier, snd_strerror(err));
goto OnErrorExit;
}
-
+
// copy value into json object and free string
- jValue = json_object_new_string (value);
- free (value);
- return (jValue);
-
- OnErrorExit:
+ jValue = json_object_new_string(value);
+ free(value);
+ return (jValue);
+
+OnErrorExit:
return (NULL);
}
-PUBLIC void alsaUseCaseGet (struct afb_req request) {
+PUBLIC void alsaUseCaseGet(struct afb_req request) {
int ucmIdx, labelCount;
queryValuesT queryValues;
json_object *jResponse = json_object_new_object();
json_object *jWarnings = json_object_new_array();
- const char *warnings=NULL;
-
- json_object *queryJ = alsaCheckQuery (request, &queryValues);
+ const char *warnings = NULL;
+
+ json_object *queryJ = alsaCheckQuery(request, &queryValues);
if (!queryJ) goto OnErrorExit;
-;
-
- ucmIdx = alsaUseCaseOpen (request, &queryValues, TRUE);
+ ;
+
+ ucmIdx = alsaUseCaseOpen(request, &queryValues, TRUE);
if (ucmIdx < 0) goto OnErrorExit;
-
- 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");
-
+
+ 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");
+
if (dev && mod) {
- afb_req_fail_f (request, "ucmget-labels", "SndCard devid=[%s] name=[%s] UCM mod+dev incompatible", queryValues.devid, cardName);
- goto OnErrorExit;
- }
-
+ afb_req_fail_f(request, "ucmget-labels", "SndCard devid=[%s] name=[%s] UCM mod+dev incompatible", queryValues.devid, cardName);
+ goto OnErrorExit;
+ }
+
// device selection is handle as a modifier
- if (dev) mod=dev;
+ if (dev) mod = dev;
const char *labels = afb_req_value(request, "value");
if (!labels) {
- afb_req_fail_f (request, "ucmget-labels", "SndCard devid=[%s] name=[%s] UCM values name missing", queryValues.devid, cardName);
- goto OnErrorExit;
- }
-
+ afb_req_fail_f(request, "ucmget-labels", "SndCard devid=[%s] name=[%s] UCM values name missing", queryValues.devid, cardName);
+ goto OnErrorExit;
+ }
+
json_object *jLabels = json_tokener_parse(labels);
if (!jLabels) {
- afb_req_fail_f (request, "ucmget-notjson","labels=%s not a valid json entry", labels);
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucmget-notjson", "labels=%s not a valid json entry", labels);
+ goto OnErrorExit;
};
-
- enum json_type jtype= json_object_get_type(jLabels);
+
+ enum json_type jtype = json_object_get_type(jLabels);
switch (jtype) {
- json_object *tmpJ;
-
+ json_object *tmpJ;
+
case json_type_array:
- labelCount = json_object_array_length (jLabels);
+ labelCount = json_object_array_length(jLabels);
break;
-
+
case json_type_string:
- tmpJ = json_object_new_array ();
+ tmpJ = json_object_new_array();
labelCount = 1;
- json_object_array_add (tmpJ, jLabels);
- jLabels=tmpJ;
+ json_object_array_add(tmpJ, jLabels);
+ jLabels = tmpJ;
break;
-
- default:
- afb_req_fail_f (request, "ucmget-notarray","labels=%s not valid JSON array", labels);
- goto OnErrorExit;
+
+ default:
+ afb_req_fail_f(request, "ucmget-notarray", "labels=%s not valid JSON array", labels);
+ goto OnErrorExit;
}
- for (int idx=0; idx < labelCount; idx++) {
+ for (int idx = 0; idx < labelCount; idx++) {
json_object *jValue, *jLabel;
- const char *label ;
-
- jLabel= json_object_array_get_idx (jLabels, idx);
- label= json_object_get_string (jLabel);
- jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, mod, label);
- if (jValue) json_object_object_add (jResponse, label, jValue);
+ const char *label;
+
+ jLabel = json_object_array_get_idx(jLabels, idx);
+ label = json_object_get_string(jLabel);
+ jValue = ucmGetValue(&ucmHandles[ucmIdx], verb, mod, label);
+ if (jValue) json_object_object_add(jResponse, label, jValue);
else {
- json_object_array_add (jWarnings, jLabel);
+ json_object_array_add(jWarnings, jLabel);
}
}
-
+
// use info section to notified not found values label
- if (json_object_array_length (jWarnings) > 0) {
- json_object *tmpJ = json_object_new_object ();
- json_object_object_add (tmpJ, "no-context", jWarnings);
- warnings= json_object_get_string (tmpJ);
+ if (json_object_array_length(jWarnings) > 0) {
+ json_object *tmpJ = json_object_new_object();
+ json_object_object_add(tmpJ, "no-context", jWarnings);
+ warnings = json_object_get_string(tmpJ);
}
- afb_req_success (request, jResponse, warnings);
-
- OnErrorExit:
- return;
+ afb_req_success(request, jResponse, warnings);
+
+OnErrorExit:
+ return;
}
-
-PUBLIC void alsaUseCaseSet(struct afb_req request) {
+
+PUBLIC void alsaUseCaseSet(struct afb_req request) {
int err, ucmIdx;
queryValuesT queryValues;
json_object *jResponse = json_object_new_object();
-
- json_object *queryJ = alsaCheckQuery (request, &queryValues);
+
+ json_object *queryJ = alsaCheckQuery(request, &queryValues);
if (!queryJ) goto OnErrorExit;
-
- ucmIdx = alsaUseCaseOpen (request, &queryValues, TRUE);
+
+ 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;
-
+
+ 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");
+ 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));
+ 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));
+ 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));
+ 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, "value")) return alsaUseCaseGet(request);
-
+
if (queryValues.mode <= 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, dev, "OutputDspName");
+ if (jValue) json_object_object_add(jResponse, "OutputDspName", jValue);
- jValue = ucmGetValue (&ucmHandles[ucmIdx], verb, mod, "CapturePCM");
- if (jValue) json_object_object_add (jResponse, "CapturePCM", 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:
+ afb_req_success(request, jResponse, NULL);
+
+OnErrorExit:
return;
}
-
-
-PUBLIC void alsaUseCaseReset (struct afb_req request) {
+PUBLIC void alsaUseCaseReset(struct afb_req request) {
int err, ucmIdx;
queryValuesT queryValues;
-
- json_object *queryJ = alsaCheckQuery (request, &queryValues);
+
+ json_object *queryJ = alsaCheckQuery(request, &queryValues);
if (!queryJ) goto OnErrorExit;
-
- ucmIdx = alsaUseCaseOpen (request, &queryValues, FALSE);
+
+ ucmIdx = alsaUseCaseOpen(request, &queryValues, FALSE);
if (ucmIdx < 0) goto OnErrorExit;
-
- err= snd_use_case_mgr_reset (ucmHandles[ucmIdx].ucm);
+
+ err = snd_use_case_mgr_reset(ucmHandles[ucmIdx].ucm);
if (err) {
- afb_req_fail_f (request, "ucmreset-fail","devid=%s Card Name=%s", queryValues.devid, ucmHandles[ucmIdx].cardName);
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucmreset-fail", "devid=%s Card Name=%s", queryValues.devid, ucmHandles[ucmIdx].cardName);
+ goto OnErrorExit;
}
-
- afb_req_success (request, NULL, NULL);
-
- OnErrorExit:
- return;
+
+ afb_req_success(request, NULL, NULL);
+
+OnErrorExit:
+ return;
}
-
-PUBLIC void alsaUseCaseClose (struct afb_req request) {
+
+PUBLIC void alsaUseCaseClose(struct afb_req request) {
int err, ucmIdx;
queryValuesT queryValues;
-
- json_object *queryJ = alsaCheckQuery (request, &queryValues);
+
+ json_object *queryJ = alsaCheckQuery(request, &queryValues);
if (!queryJ) goto OnErrorExit;
-
- ucmIdx = alsaUseCaseOpen (request, &queryValues, FALSE);
+
+ ucmIdx = alsaUseCaseOpen(request, &queryValues, FALSE);
if (ucmIdx < 0) goto OnErrorExit;
-
- err= snd_use_case_mgr_close (ucmHandles[ucmIdx].ucm);
+
+ err = snd_use_case_mgr_close(ucmHandles[ucmIdx].ucm);
if (err) {
- afb_req_fail_f (request, "ucmreset-close","devid=%s Card Name=%s", queryValues.devid, ucmHandles[ucmIdx].cardName);
- goto OnErrorExit;
+ afb_req_fail_f(request, "ucmreset-close", "devid=%s Card Name=%s", queryValues.devid, ucmHandles[ucmIdx].cardName);
+ goto OnErrorExit;
}
-
+
// do not forget to release sound card name string
- free (ucmHandles[ucmIdx].cardName);
-
- afb_req_success (request, NULL, NULL);
-
- OnErrorExit:
- return;
+ free(ucmHandles[ucmIdx].cardName);
+
+ afb_req_success(request, NULL, NULL);
+
+OnErrorExit:
+ return;
}
-
+