aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--4a-hal-cfg-example/hal-4a-2ch-generic-usb.json17
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.c2
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-data.h3
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c36
-rw-r--r--lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h6
-rw-r--r--src/4a-internals-hal/4a-internals-hal-api-loader.c6
-rw-r--r--src/4a-internals-hal/4a-internals-hal-cb.c60
-rw-r--r--src/4a-internals-hal/4a-internals-hal-mixer-link.c114
-rw-r--r--src/4a-internals-hal/4a-internals-hal-mixer-link.h17
9 files changed, 41 insertions, 220 deletions
diff --git a/4a-hal-cfg-example/hal-4a-2ch-generic-usb.json b/4a-hal-cfg-example/hal-4a-2ch-generic-usb.json
index be3bdb6..ea7c00f 100644
--- a/4a-hal-cfg-example/hal-4a-2ch-generic-usb.json
+++ b/4a-hal-cfg-example/hal-4a-2ch-generic-usb.json
@@ -107,15 +107,6 @@
"rate": 48000
},
"sink": {
- "controls": {
- "volume": {
- "name": "Speaker Playback Volume",
- "value": 80
- },
- "mute": {
- "name": "Speaker Playback Switch"
- }
- },
"channels": [
{
"uid": "front-right",
@@ -135,14 +126,6 @@
"rate": 48000
},
"source": {
- "controls": {
- "volume": {
- "name": "Capture Volume"
- },
- "mute": {
- "name": "Capture Switch"
- }
- },
"channels": [
{
"uid": "mic-right",
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.c b/lib/4a-hal-utilities/4a-hal-utilities-data.c
index 8f30596..10fdf27 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.c
@@ -219,8 +219,6 @@ int HalUtlRemoveSelectedHalFromList(struct HalData **halDataList, struct HalData
free(matchingHal->internalHalData->prefix);
HalUtlRemoveAllMixerData(&matchingHal->internalHalData->streamsData);
- HalUtlRemoveAllMixerData(&matchingHal->internalHalData->playbacksData);
- HalUtlRemoveAllMixerData(&matchingHal->internalHalData->capturesData);
HalUtlFreeAlsaCtlsMap(matchingHal->internalHalData->alsaMapT);
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h
index a782417..b3874e7 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h
@@ -56,9 +56,6 @@ struct InternalHalData {
struct InternalHalMixerData *streamsData;
afb_event_t streamUpdates;
- struct InternalHalMixerData *playbacksData;
- struct InternalHalMixerData *capturesData;
-
struct InternalHalAlsaMapT *alsaMapT;
afb_api_t apiHandle;
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
index c38bfdd..806387a 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
+++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.c
@@ -103,8 +103,6 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
count = 1;
break;
- case ACTION_ON_MIXER_PLAYBACK:
- case ACTION_ON_MIXER_CAPTURE:
case ACTION_ON_MIXER_ALL_STREAM:
count = (int) HalUtlGetNumberOfMixerDataInList(&currentMixerData);
toReturnJ = json_object_new_object();
@@ -163,10 +161,8 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
}
// TBD JAI : When mixer events will be available, use them instead of generating events at calls
- if((actionType == ACTION_ON_MIXER_STREAM ||
- actionType == ACTION_ON_MIXER_ALL_STREAM) &&
- ((! currentMixerData->event) ||
- (afb_event_push(currentMixerData->event, json_object_get(responseJ)) < 0))) {
+ if(! currentMixerData->event ||
+ (afb_event_push(currentMixerData->event, json_object_get(responseJ)) < 0)) {
AFB_API_ERROR(apiHandle, "Could not generate an event for stream %s", currentMixerData->verb);
}
@@ -175,12 +171,6 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
toReturnJ = responseJ;
break;
- case ACTION_ON_MIXER_PLAYBACK:
- case ACTION_ON_MIXER_CAPTURE:
- json_object_object_add(toReturnJ, currentMixerData->verbToCall, responseJ);
- currentMixerData = currentMixerData->next;
- break;
-
case ACTION_ON_MIXER_ALL_STREAM:
json_object_object_add(toReturnJ, currentMixerData->verb, responseJ);
currentMixerData = currentMixerData->next;
@@ -200,18 +190,6 @@ void HalUtlActionOnMixer(afb_req_t request, enum ActionOnMixerType actionType)
apiToCall);
break;
- case ACTION_ON_MIXER_PLAYBACK:
- afb_req_success(request,
- toReturnJ,
- "Actions correctly transferred to all playbacks without any error raised");
- break;
-
- case ACTION_ON_MIXER_CAPTURE:
- afb_req_success(request,
- toReturnJ,
- "Actions correctly transferred to all captures without any error raised");
- break;
-
case ACTION_ON_MIXER_ALL_STREAM:
afb_req_success(request,
toReturnJ,
@@ -228,16 +206,6 @@ void HalUtlActionOnStream(afb_req_t request)
HalUtlActionOnMixer(request, ACTION_ON_MIXER_STREAM);
}
-void HalUtlActionOnPlayback(afb_req_t request)
-{
- HalUtlActionOnMixer(request, ACTION_ON_MIXER_PLAYBACK);
-}
-
-void HalUtlActionOnCapture(afb_req_t request)
-{
- HalUtlActionOnMixer(request, ACTION_ON_MIXER_CAPTURE);
-}
-
void HalUtlActionOnAllStream(afb_req_t request)
{
HalUtlActionOnMixer(request, ACTION_ON_MIXER_ALL_STREAM);
diff --git a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
index 204fe18..e6f0d99 100644
--- a/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
+++ b/lib/4a-hal-utilities/4a-hal-utilities-hal-streams-handler.h
@@ -27,15 +27,11 @@
// Enum for the type of action on mixer
enum ActionOnMixerType {
ACTION_ON_MIXER_STREAM = 1,
- ACTION_ON_MIXER_PLAYBACK = 2,
- ACTION_ON_MIXER_CAPTURE = 3,
- ACTION_ON_MIXER_ALL_STREAM = 4
+ ACTION_ON_MIXER_ALL_STREAM = 2
};
// Actions to be call when a stream verb is called
void HalUtlActionOnStream(afb_req_t request);
-void HalUtlActionOnPlayback(afb_req_t request);
-void HalUtlActionOnCapture(afb_req_t request);
void HalUtlActionOnAllStream(afb_req_t request);
// Add/Remove stream data and verb functions
diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.c b/src/4a-internals-hal/4a-internals-hal-api-loader.c
index 9d3912e..9cb3481 100644
--- a/src/4a-internals-hal/4a-internals-hal-api-loader.c
+++ b/src/4a-internals-hal/4a-internals-hal-api-loader.c
@@ -56,9 +56,9 @@ static CtlSectionT ctrlSectionsDefault[] =
static afb_verb_t InternalHalApiStaticVerbs[] =
{
/* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */
- { .verb = "info", .callback = InternalHalInfo, .info = "List available streams/playbacks/captures/controls for this api" },
- { .verb = "subscribe", .callback = InternalHalSubscribe, .info = "Subscribe to event(s) for values changes (streams/playbacks/captures/controls) for this api" },
- { .verb = "unsubscribe", .callback = InternalHalUnsubscribe, .info = "Unsubscribe to event(s) for values changes (streams/playbacks/captures/controls) for this api" },
+ { .verb = "info", .callback = InternalHalInfo, .info = "List available streams/controls for this api" },
+ { .verb = "subscribe", .callback = InternalHalSubscribe, .info = "Subscribe to event(s) for values changes (streams/controls) for this api" },
+ { .verb = "unsubscribe", .callback = InternalHalUnsubscribe, .info = "Unsubscribe to event(s) for values changes (streams/controls) for this api" },
{ .verb = NULL } // Marker for end of the array
};
diff --git a/src/4a-internals-hal/4a-internals-hal-cb.c b/src/4a-internals-hal/4a-internals-hal-cb.c
index bca4d82..4c5fb68 100644
--- a/src/4a-internals-hal/4a-internals-hal-cb.c
+++ b/src/4a-internals-hal/4a-internals-hal-cb.c
@@ -442,8 +442,7 @@ int InternalHalHalMapConfig(afb_api_t apiHandle, CtlSectionT *section, json_obje
******************************************************************************/
json_object *InternalHalGetJsonArrayForMixerDataTable(afb_api_t apiHandle,
- struct InternalHalMixerData **mixerDataList,
- enum MixerDataType dataType)
+ struct InternalHalMixerData **mixerDataList)
{
int wrapRet;
@@ -464,30 +463,12 @@ json_object *InternalHalGetJsonArrayForMixerDataTable(afb_api_t apiHandle,
currentMixerData = *mixerDataList;
while(currentMixerData) {
- switch(dataType) {
- case MIXER_DATA_STREAMS:
- wrapRet = wrap_json_pack(&currentMixerDataJ,
- "{s:s s:s}",
- "name", currentMixerData->verb,
- "cardId", currentMixerData->streamCardId);
- break;
-
- case MIXER_DATA_PLAYBACKS:
- case MIXER_DATA_CAPTURES :
- wrapRet = wrap_json_pack(&currentMixerDataJ,
- "{s:s s:s}",
- "name", currentMixerData->verb,
- "mixer-name", currentMixerData->verbToCall,
- "uid", currentMixerData->streamCardId ? currentMixerData->streamCardId : "none");
- break;
-
- default:
- json_object_put(mixerDataArrayJ);
- return NULL;
- }
-
+ wrapRet = wrap_json_pack(&currentMixerDataJ,
+ "{s:s s:s}",
+ "name", currentMixerData->verb,
+ "cardId", currentMixerData->streamCardId);
if(wrapRet) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current mixer/playbacks/captures json object");
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current mixer json object");
json_object_put(mixerDataArrayJ);
return NULL;
}
@@ -529,7 +510,7 @@ json_object *InternalHalGetJsonArrayForControls(afb_api_t apiHandle, struct Inte
"name", currentAlsaMapDataT->ctls[idx].uid,
"info", currentAlsaMapDataT->ctls[idx].info ? currentAlsaMapDataT->ctls[idx].info : "none");
if(wrapRet) {
- AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current mixer/playbacks/captures json object");
+ AFB_API_ERROR(apiHandle, "Didn't succeed to allocate current streams json object");
json_object_put(alsaMapDataArray);
return NULL;
}
@@ -555,8 +536,6 @@ void InternalHalInfo(afb_req_t request)
*toReturnJ = NULL,
*requestAnswer,
*streamsArray,
- *playbacksArray,
- *capturesArray,
*controlsArray;
apiHandle = afb_req_get_api(request);
@@ -602,29 +581,12 @@ void InternalHalInfo(afb_req_t request)
}
streamsArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle,
- &currentHalData->internalHalData->streamsData,
- MIXER_DATA_STREAMS);
+ &currentHalData->internalHalData->streamsData);
if(! streamsArray) {
afb_req_fail(request, "streams_data", "Didn't succeed to generate streams data array");
return;
}
- playbacksArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle,
- &currentHalData->internalHalData->playbacksData,
- MIXER_DATA_PLAYBACKS);
- if(! playbacksArray) {
- afb_req_fail(request, "playbacks_data", "Didn't succeed to generate playbacks data array");
- return;
- }
-
- capturesArray = InternalHalGetJsonArrayForMixerDataTable(apiHandle,
- &currentHalData->internalHalData->capturesData,
- MIXER_DATA_CAPTURES);
- if(! capturesArray) {
- afb_req_fail(request, "captures_data", "Didn't succeed to generate captures data array");
- return;
- }
-
controlsArray = InternalHalGetJsonArrayForControls(apiHandle,
currentHalData->internalHalData->alsaMapT);
if(! controlsArray) {
@@ -633,18 +595,14 @@ void InternalHalInfo(afb_req_t request)
}
wrapRet = wrap_json_pack(&requestAnswer,
- "{s:o s:o s:o s:o}",
+ "{s:o s:o}",
"streams", streamsArray,
- "playbacks", playbacksArray,
- "captures", capturesArray,
"controls", controlsArray);
if(wrapRet) {
afb_req_fail(request,
"halinfo_json_object",
"Didn't succeed to allocate hal info response json object");
json_object_put(streamsArray);
- json_object_put(playbacksArray);
- json_object_put(capturesArray);
json_object_put(controlsArray);
return;
}
diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.c b/src/4a-internals-hal/4a-internals-hal-mixer-link.c
index 553d58e..96f3e89 100644
--- a/src/4a-internals-hal/4a-internals-hal-mixer-link.c
+++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.c
@@ -37,8 +37,7 @@
int InternalHalHandleMixerData(afb_api_t apiHandle,
struct InternalHalMixerData **mixerDataList,
- json_object *currentDataJ,
- enum MixerDataType dataType)
+ json_object *currentDataJ)
{
int idx, mixerDataNb, verbStart, size;
int err = (int) MIXER_NO_ERROR;
@@ -48,8 +47,6 @@ int InternalHalHandleMixerData(afb_api_t apiHandle,
json_type currentDataType;
json_object *currentJ;
- struct InternalHalMixerData *currentMixerData;
-
currentDataType = json_object_get_type(currentDataJ);
switch(currentDataType) {
case json_type_object:
@@ -76,80 +73,31 @@ int InternalHalHandleMixerData(afb_api_t apiHandle,
AFB_API_ERROR(apiHandle, "Can't find verb in current data object");
err += (int) MIXER_ERROR_DATA_NAME_UNAVAILABLE;
}
- else if(dataType == MIXER_DATA_STREAMS && wrap_json_unpack(currentJ, "{s:s}", "alsa", &currentStreamCardId)) {
+ else if(wrap_json_unpack(currentJ, "{s:s}", "alsa", &currentStreamCardId)) {
AFB_API_ERROR(apiHandle, "Can't find card id in current data object");
err += (int) MIXER_ERROR_DATA_CARDID_UNAVAILABLE;
}
else {
- switch(dataType) {
- case MIXER_DATA_STREAMS:
- size = (int) strlen(currentDataVerbName);
- for(verbStart = 0; verbStart < size; verbStart++) {
- if(currentDataVerbName[verbStart] == '#') {
- verbStart++;
- break;
- }
- }
-
- if(verbStart == size)
- verbStart = 0;
-
- if(! HalUtlAddStreamDataAndCreateStreamVerb(apiHandle,
- &currentDataVerbName[verbStart],
- currentDataVerbName,
- currentStreamCardId)) {
- AFB_API_ERROR(apiHandle,
- "Error while adding stream '%s'",
- currentDataVerbName);
- err += (int) MIXER_ERROR_STREAM_NOT_ADDED;
- }
- break;
-
- case MIXER_DATA_PLAYBACKS:
- case MIXER_DATA_CAPTURES:
- currentMixerData = HalUtlAddMixerDataToMixerDataList(mixerDataList);
-
- currentMixerData->verb = strdup((dataType == MIXER_DATA_PLAYBACKS) ? HAL_PLAYBACK_ID : HAL_CAPTURE_ID);
- currentMixerData->verbToCall = strdup(currentDataVerbName);
-
- if(! currentMixerData->verb ||
- ! currentMixerData->verbToCall) {
- HalUtlRemoveSelectedMixerData(mixerDataList, currentMixerData);
- err += (int) MIXER_ERROR_STREAM_ALLOCATION_FAILED;
- }
- break;
-
- default:
+ size = (int) strlen(currentDataVerbName);
+ for(verbStart = 0; verbStart < size; verbStart++) {
+ if(currentDataVerbName[verbStart] == '#') {
+ verbStart++;
break;
+ }
}
- }
- }
- if(dataType == MIXER_DATA_PLAYBACKS) {
- if(afb_api_add_verb(apiHandle,
- HAL_PLAYBACK_ID,
- "Playback action transferred to mixer",
- HalUtlActionOnPlayback,
- (void *) *mixerDataList,
- NULL,
- 0,
- 0)) {
- AFB_API_ERROR(apiHandle, "Error while creating verb for playbacks : '%s'", HAL_PLAYBACK_ID);
- err += (int) MIXER_ERROR_PLAYBACK_VERB_NOT_CREATED;
- }
- }
-
- if(dataType == MIXER_DATA_CAPTURES) {
- if(afb_api_add_verb(apiHandle,
- HAL_CAPTURE_ID,
- "Capture action transferred to mixer",
- HalUtlActionOnCapture,
- (void *) *mixerDataList,
- NULL,
- 0,
- 0)) {
- AFB_API_ERROR(apiHandle, "Error while creating verb for captures : '%s'", HAL_CAPTURE_ID);
- err += (int) MIXER_ERROR_CAPTURE_VERB_NOT_CREATED;
+ if(verbStart == size)
+ verbStart = 0;
+
+ if(! HalUtlAddStreamDataAndCreateStreamVerb(apiHandle,
+ &currentDataVerbName[verbStart],
+ currentDataVerbName,
+ currentStreamCardId)) {
+ AFB_API_ERROR(apiHandle,
+ "Error while adding stream '%s'",
+ currentDataVerbName);
+ err += (int) MIXER_ERROR_STREAM_NOT_ADDED;
+ }
}
}
@@ -160,7 +108,7 @@ int InternalHalHandleMixerAttachResponse(afb_api_t apiHandle, struct InternalHal
{
int err = (int) MIXER_NO_ERROR;
- json_object *mixerStreamsJ = NULL, *mixerPlaybacksJ = NULL, *mixerCapturesJ = NULL;
+ json_object *mixerStreamsJ = NULL;
if(! apiHandle) {
AFB_API_ERROR(apiHandle, "Can't get current hal api handle");
@@ -168,32 +116,18 @@ int InternalHalHandleMixerAttachResponse(afb_api_t apiHandle, struct InternalHal
}
if(wrap_json_unpack(mixerResponseJ,
- "{s?:o s?:o s?:o}",
- "streams", &mixerStreamsJ,
- "playbacks", &mixerPlaybacksJ,
- "captures", &mixerCapturesJ)) {
- AFB_API_ERROR(apiHandle, "Can't get streams|playbacks|captures object in '%s'", json_object_get_string(mixerResponseJ));
+ "{s?:o}",
+ "streams", &mixerStreamsJ)) {
+ AFB_API_ERROR(apiHandle, "Can't get streams object in '%s'", json_object_get_string(mixerResponseJ));
return (int) MIXER_ERROR_DATA_UNAVAILABLE;
}
if(mixerStreamsJ) {
- err += InternalHalHandleMixerData(apiHandle, &currentHalSpecificData->streamsData, mixerStreamsJ, MIXER_DATA_STREAMS);
+ err += InternalHalHandleMixerData(apiHandle, &currentHalSpecificData->streamsData, mixerStreamsJ);
if(err)
AFB_API_ERROR(apiHandle, "Error during handling response mixer streams data '%s'", json_object_get_string(mixerStreamsJ));
}
- if(mixerPlaybacksJ) {
- err += InternalHalHandleMixerData(apiHandle, &currentHalSpecificData->playbacksData, mixerPlaybacksJ, MIXER_DATA_PLAYBACKS);
- if(err)
- AFB_API_ERROR(apiHandle, "Error during handling response mixer playbacks data '%s'", json_object_get_string(mixerPlaybacksJ));
- }
-
- if(mixerCapturesJ) {
- err += InternalHalHandleMixerData(apiHandle, &currentHalSpecificData->capturesData, mixerCapturesJ, MIXER_DATA_CAPTURES);
- if(err)
- AFB_API_ERROR(apiHandle, "Error during handling response mixer captures data '%s'", json_object_get_string(mixerCapturesJ));
- }
-
if(! currentHalSpecificData->streamsData) {
AFB_API_WARNING(apiHandle, "No stream detected in mixer response, %s verb won't be created", HAL_ALL_STREAMS_VERB);
}
diff --git a/src/4a-internals-hal/4a-internals-hal-mixer-link.h b/src/4a-internals-hal/4a-internals-hal-mixer-link.h
index 6c1f827..cc069fc 100644
--- a/src/4a-internals-hal/4a-internals-hal-mixer-link.h
+++ b/src/4a-internals-hal/4a-internals-hal-mixer-link.h
@@ -31,31 +31,18 @@
#define MIXER_ATTACH_VERB "attach"
#define MIXER_INFO_VERB "info"
-#define HAL_PLAYBACK_ID "playback"
-#define HAL_CAPTURE_ID "capture"
-
#define HAL_ALL_STREAMS_VERB "all-streams"
-// Enum for the type of object sent back by the mixer
-enum MixerDataType {
- MIXER_DATA_STREAMS = 1,
- MIXER_DATA_PLAYBACKS = 2,
- MIXER_DATA_CAPTURES = 3
-};
-
// Enum for the type of error detected
enum MixerStatus {
MIXER_NO_ERROR=0,
MIXER_ERROR_API_UNAVAILABLE=-1,
MIXER_ERROR_DATA_UNAVAILABLE=-2,
MIXER_ERROR_DATA_EMPTY =-3,
- MIXER_ERROR_PLAYBACK_VERB_NOT_CREATED =-4,
- MIXER_ERROR_CAPTURE_VERB_NOT_CREATED =-5,
- MIXER_ERROR_ALL_STREAMS_VERB_NOT_CREATED =-6,
+ MIXER_ERROR_ALL_STREAMS_VERB_NOT_CREATED =-4,
MIXER_ERROR_DATA_NAME_UNAVAILABLE=-10,
MIXER_ERROR_DATA_CARDID_UNAVAILABLE=-100,
- MIXER_ERROR_STREAM_NOT_ADDED =-1000,
- MIXER_ERROR_STREAM_ALLOCATION_FAILED =-10000
+ MIXER_ERROR_STREAM_NOT_ADDED =-1000
};
// Internals HAL handle mixer calls functions