summaryrefslogtreecommitdiffstats
path: root/alsa-binding
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-08-14 16:35:28 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-08-14 16:37:12 +0200
commit33e6fa922e81bcf7341c0476c20f095b9e778e12 (patch)
tree736319e3fae5729bda5f7c047a77876babaef85c /alsa-binding
parent9b71be04ea600189e390bb111624ad5c2d248a4c (diff)
Minor syntax changes in get card info functions
Minor syntax changes in get card info functions. Bug-AGL: SPEC-2749 Change-Id: I90c896618fca73dbae9e51ff996ac5613713d7b6 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'alsa-binding')
-rw-r--r--alsa-binding/Alsa-SetGet.c65
1 files changed, 42 insertions, 23 deletions
diff --git a/alsa-binding/Alsa-SetGet.c b/alsa-binding/Alsa-SetGet.c
index ad205a1..533d2f5 100644
--- a/alsa-binding/Alsa-SetGet.c
+++ b/alsa-binding/Alsa-SetGet.c
@@ -381,7 +381,8 @@ STATIC int searchInQueryForAlsaCardToProbe(queryCardInfo *queryInfo, int *cardTo
}
if(queryInfo->cardPath) {
- if((cardPathFileId = open(queryInfo->cardPath, O_RDONLY)) < 0) {
+ cardPathFileId = open(queryInfo->cardPath, O_RDONLY);
+ if(cardPathFileId < 0) {
AFB_ERROR("CardPath '%s' error %i during open", queryInfo->cardPath, cardPathFileId);
return -4;
}
@@ -413,7 +414,8 @@ STATIC int searchInQueryForAlsaCardToProbe(queryCardInfo *queryInfo, int *cardTo
if(*cardToProbe != NO_CARD_SELECTED)
return 0;
- if((err = snd_card_next(cardToProbe)) < 0) {
+ err = snd_card_next(cardToProbe);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to get next ALSA card number", err);
return -8;
}
@@ -447,12 +449,14 @@ STATIC int jumpToCardNextDevice(unsigned int card, int *currentDevice)
snprintf(cardString, sizeof(cardString), "hw:%d", card);
- if((err = snd_ctl_open(&cardHandle, cardString, 0)) < 0) {
+ err = snd_ctl_open(&cardHandle, cardString, 0);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to open ALSA card %i", err, *currentDevice);
return -3;
}
- if((err = snd_ctl_pcm_next_device(cardHandle, currentDevice)) < 0) {
+ err = snd_ctl_pcm_next_device(cardHandle, currentDevice);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to get ALSA card %i next device number", err, *currentDevice);
snd_ctl_close(cardHandle);
return -4;
@@ -497,12 +501,14 @@ STATIC int checkIfCardIsCorrespondingToQuery(queryCardInfo *queryInfo, int card)
snprintf(cardString, sizeof(cardString), "hw:%d", card);
- if((err = snd_ctl_open(&cardHandle, cardString, 0)) < 0) {
+ err = snd_ctl_open(&cardHandle, cardString, 0);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to open ALSA card %i", err, card);
return -4;
}
- if((err = snd_ctl_card_info(cardHandle, cardInfo)) < 0) {
+ err = snd_ctl_card_info(cardHandle, cardInfo);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to get ALSA card %i info", err, card);
snd_ctl_close(cardHandle);
return -5;
@@ -571,7 +577,8 @@ STATIC int checkIfPlaybackDeviceIsCorrespondingToQuery(queryCardInfo *queryInfo,
snprintf(cardString, sizeof(cardString), "hw:%d", card);
- if((err = snd_ctl_open(&cardHandle, cardString, 0)) < 0) {
+ err = snd_ctl_open(&cardHandle, cardString, 0);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to open ALSA card %i", err, card);
return -5;
}
@@ -580,7 +587,8 @@ STATIC int checkIfPlaybackDeviceIsCorrespondingToQuery(queryCardInfo *queryInfo,
snd_pcm_info_set_subdevice(cardPcminfo, 0);
snd_pcm_info_set_stream(cardPcminfo, SND_PCM_STREAM_PLAYBACK);
- if((err = snd_ctl_pcm_info(cardHandle, cardPcminfo)) == -ENOENT) {
+ err = snd_ctl_pcm_info(cardHandle, cardPcminfo);
+ if(err == -ENOENT) {
snd_ctl_close(cardHandle);
return 0;
}
@@ -626,12 +634,14 @@ STATIC json_object *getCardInfo(int card)
snprintf(cardString, sizeof(cardString), "hw:%d", card);
- if((err = snd_ctl_open(&cardHandle, cardString, 0)) < 0) {
+ err = snd_ctl_open(&cardHandle, cardString, 0);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to open ALSA card %i", err, card);
return NULL;
}
- if((err = snd_ctl_card_info(cardHandle, cardInfo)) < 0) {
+ err = snd_ctl_card_info(cardHandle, cardInfo);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to get ALSA card %i info", err, card);
snd_ctl_close(cardHandle);
return NULL;
@@ -676,7 +686,8 @@ STATIC json_object *getDeviceInfo(int card, int device)
snprintf(cardString, sizeof(cardString), "hw:%d", card);
- if((err = snd_ctl_open(&cardHandle, cardString, 0)) < 0) {
+ err = snd_ctl_open(&cardHandle, cardString, 0);
+ if(err < 0) {
AFB_ERROR("Error %i happened when tried to open ALSA card %i", err, card);
return NULL;
}
@@ -685,7 +696,8 @@ STATIC json_object *getDeviceInfo(int card, int device)
snd_pcm_info_set_subdevice(cardPcminfo, 0);
snd_pcm_info_set_stream(cardPcminfo, SND_PCM_STREAM_PLAYBACK);
- if((err = snd_ctl_pcm_info(cardHandle, cardPcminfo)) == -ENOENT) {
+ err = snd_ctl_pcm_info(cardHandle, cardPcminfo);
+ if(err == -ENOENT) {
snd_ctl_close(cardHandle);
return NULL;
}
@@ -746,17 +758,20 @@ STATIC json_object *alsaCardProbe(queryCardInfo *queryInfo) {
return NULL;
}
- if((multipleCardToCheck = searchInQueryForAlsaCardToProbe(queryInfo, &cardToProbe)) < 0)
+ multipleCardToCheck = searchInQueryForAlsaCardToProbe(queryInfo, &cardToProbe);
+ if(multipleCardToCheck < 0)
return NULL;
- if(! (toReturnJ = json_object_new_array())) {
+ toReturnJ = json_object_new_array();
+ if(! toReturnJ) {
AFB_ERROR("Error while allocating answer json array");
return NULL;
}
while(cardToProbe >= 0 &&
cardToProbe < MAX_SND_CARD) {
- if((isCardCorresponding = checkIfCardIsCorrespondingToQuery(queryInfo, cardToProbe)) < 0) {
+ isCardCorresponding = checkIfCardIsCorrespondingToQuery(queryInfo, cardToProbe);
+ if(isCardCorresponding < 0) {
json_object_put(toReturnJ);
return NULL;
}
@@ -792,7 +807,8 @@ STATIC json_object *alsaCardProbe(queryCardInfo *queryInfo) {
while(playbackDeviceToProbe >= 0 &&
playbackDeviceToProbe < MAX_CARD_DEVICES) {
- if((isDeviceCorresponding = checkIfPlaybackDeviceIsCorrespondingToQuery(queryInfo, correspondingCard, playbackDeviceToProbe)) < 0) {
+ isDeviceCorresponding = checkIfPlaybackDeviceIsCorrespondingToQuery(queryInfo, correspondingCard, playbackDeviceToProbe);
+ if(isDeviceCorresponding < 0) {
json_object_put(correspondingCardJ);
json_object_put(toReturnJ);
return NULL;
@@ -855,13 +871,15 @@ PUBLIC void alsaGetInfo(afb_req_t request) {
queryCardInfo queryInfo;
- if(! (requestJ = afb_req_json(request))) {
- if(snd_card_next(&card) >= 0 &&
- card >= 0) {
+ requestJ = afb_req_json(request);
+ if(! requestJ) {
+ if((snd_card_next(&card) >= 0) &&
+ (card >= 0)) {
toReturnJ = json_object_new_array();
while(card >= 0) {
- if((currentCardInfoJ = getCardInfo(card)))
+ currentCardInfoJ = getCardInfo(card);
+ if(currentCardInfoJ)
json_object_array_add(toReturnJ, currentCardInfoJ);
if(snd_card_next(&card) < 0)
@@ -873,7 +891,8 @@ PUBLIC void alsaGetInfo(afb_req_t request) {
return;
}
- switch((requestJType = json_object_get_type(requestJ))) {
+ requestJType = json_object_get_type(requestJ);
+ switch(requestJType) {
case json_type_object:
count = 1;
break;
@@ -933,7 +952,7 @@ PUBLIC void alsaGetInfo(afb_req_t request) {
switch(requestJType) {
case json_type_object:
- if((currentCardInfoJ))
+ if(currentCardInfoJ)
afb_req_success(request,
currentCardInfoJ,
"Requested sound card properties are available in returned Json");
@@ -945,7 +964,7 @@ PUBLIC void alsaGetInfo(afb_req_t request) {
return;
case json_type_array:
- if((currentCardInfoJ))
+ if(currentCardInfoJ)
json_object_array_add(toReturnJ, currentCardInfoJ);
else
json_object_array_add(toReturnJ, json_object_new_string("sndcard-not-found"));