summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/alsa/alsa-api-pcm.c')
-rw-r--r--plugins/alsa/alsa-api-pcm.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/plugins/alsa/alsa-api-pcm.c b/plugins/alsa/alsa-api-pcm.c
index ce74982..7fa97e1 100644
--- a/plugins/alsa/alsa-api-pcm.c
+++ b/plugins/alsa/alsa-api-pcm.c
@@ -59,7 +59,7 @@ STATIC AlsaPcmChannelT * ProcessOneChannel(SoftMixerT *mixer, const char *uid, j
}
int error = wrap_json_unpack(argsJ, "{ss,si !}", "uid", &channel->uid, "port", &channel->port);
if (error) {
- AFB_ApiError(mixer->api, "%s: sndcard=%s channel: missing (uid||port) error=%s json=%s",
+ AFB_API_ERROR(mixer->api, "%s: sndcard=%s channel: missing (uid||port) error=%s json=%s",
__func__, uid, wrap_json_get_error_string(error), json_object_get_string(argsJ));
goto fail_channel;
}
@@ -92,7 +92,7 @@ STATIC int PcmAttachOneCtl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, json_object
, "value", &value
);
if (error || (!numid && !name)) {
- AFB_ApiError(mixer->api,
+ AFB_API_ERROR(mixer->api,
"%s: cardid=%s channel: missing (numid|name|value) error=%s json=%s",
__func__, sndcard->cid.name, wrap_json_get_error_string(error), json_object_get_string(argsJ));
goto fail;
@@ -101,7 +101,7 @@ STATIC int PcmAttachOneCtl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, json_object
if (numid > 0) {
elemId = AlsaCtlGetNumidElemId(mixer, sndcard, numid);
if (!elemId) {
- AFB_ApiError(mixer->api, "%s sndard=%s fail to find control numid=%d",
+ AFB_API_ERROR(mixer->api, "%s sndard=%s fail to find control numid=%d",
__func__, sndcard->cid.cardid, numid);
goto fail;
}
@@ -109,7 +109,7 @@ STATIC int PcmAttachOneCtl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, json_object
} else {
elemId = AlsaCtlGetNameElemId(mixer, sndcard, name);
if (!elemId) {
- AFB_ApiError(mixer->api, "%s sndard=%s fail to find control name=%s",
+ AFB_API_ERROR(mixer->api, "%s sndard=%s fail to find control name=%s",
__func__, sndcard->cid.cardid, name);
goto fail;
}
@@ -125,13 +125,13 @@ STATIC int PcmAttachOneCtl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, json_object
control->numid = snd_ctl_elem_info_get_numid(elemInfo);
if (snd_ctl_elem_info(sndcard->ctl, elemInfo) < 0) {
- AFB_ApiError(mixer->api, "%s: sndard=%s numid=%d name='%s' not loadable",
+ AFB_API_ERROR(mixer->api, "%s: sndard=%s numid=%d name='%s' not loadable",
__func__, sndcard->cid.cardid, control->numid, control->name);
goto fail_control_name;
}
if (!snd_ctl_elem_info_is_writable(elemInfo)) {
- AFB_ApiError(mixer->api, "%s: sndard=%s numid=%d name='%s' not writable",
+ AFB_API_ERROR(mixer->api, "%s: sndard=%s numid=%d name='%s' not writable",
__func__, sndcard->cid.cardid, control->numid, control->name);
goto fail_control_name;
}
@@ -154,13 +154,13 @@ STATIC int PcmAttachOneCtl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, json_object
break;
default:
- AFB_ApiError(mixer->api, "%s: sndard=%s numid=%d name='%s' invalid/unsupported type=%d",
+ AFB_API_ERROR(mixer->api, "%s: sndard=%s numid=%d name='%s' invalid/unsupported type=%d",
__func__, sndcard->cid.cardid, control->numid, control->name, snd_ctl_elem_info_get_type(elemInfo));
goto fail_control_name;
}
if (error) {
- AFB_ApiError(mixer->api, "%s: sndard=%s numid=%d name='%s' not writable",
+ AFB_API_ERROR(mixer->api, "%s: sndard=%s numid=%d name='%s' not writable",
__func__, sndcard->cid.cardid, control->numid, control->name);
goto fail_control_name;
}
@@ -186,7 +186,7 @@ STATIC int PcmSetControl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaSndControl
elemId = AlsaCtlGetNumidElemId(mixer, sndcard, control->numid);
if (!elemId) {
- AFB_ApiError(mixer->api, "%s sndard=%s fail to find control numid=%d", __func__, sndcard->cid.cardid, control->numid);
+ AFB_API_ERROR(mixer->api, "%s sndard=%s fail to find control numid=%d", __func__, sndcard->cid.cardid, control->numid);
goto OnErrorExit;
}
@@ -194,18 +194,18 @@ STATIC int PcmSetControl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaSndControl
snd_ctl_elem_info_set_id(elemInfo, elemId);
if (snd_ctl_elem_info(sndcard->ctl, elemInfo) < 0) {
- AFB_ApiError(mixer->api, "%s: sndard=%s numid=%d name='%s' not loadable", __func__, sndcard->cid.cardid, control->numid, control->name);
+ AFB_API_ERROR(mixer->api, "%s: sndard=%s numid=%d name='%s' not loadable", __func__, sndcard->cid.cardid, control->numid, control->name);
goto OnErrorExit;
}
if (!snd_ctl_elem_info_is_writable(elemInfo)) {
- AFB_ApiError(mixer->api, "%s: sndard=%s numid=%d name='%s' not writable", __func__, sndcard->cid.cardid, control->numid, control->name);
+ AFB_API_ERROR(mixer->api, "%s: sndard=%s numid=%d name='%s' not writable", __func__, sndcard->cid.cardid, control->numid, control->name);
goto OnErrorExit;
}
error = CtlElemIdGetLong(mixer, sndcard, elemId, &curval);
if (error) {
- AFB_ApiError(mixer->api, "%s sndcard=%s fail to read control numid=%d", __func__, sndcard->cid.cardid, control->numid);
+ AFB_API_ERROR(mixer->api, "%s sndcard=%s fail to read control numid=%d", __func__, sndcard->cid.cardid, control->numid);
goto OnErrorExit;
}
@@ -231,18 +231,18 @@ STATIC int PcmSetControl(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaSndControl
error = CtlElemIdSetLong(mixer, sndcard, elemId, CONVERT_VOLUME(value, control->min, control->max));
if (error) {
- AFB_ApiError(mixer->api, "PcmSetControl sndard=%s fail to write control numid=%d value=%d", sndcard->cid.cardid, control->numid, value);
+ AFB_API_ERROR(mixer->api, "PcmSetControl sndard=%s fail to write control numid=%d value=%d", sndcard->cid.cardid, control->numid, value);
goto OnErrorExit;
}
break;
default:
- AFB_ApiError(mixer->api, "PcmSetControl: sndard=%s numid=%d name='%s' invalid/unsupported type=%d", sndcard->cid.cardid, control->numid, control->name, snd_ctl_elem_info_get_type(elemInfo));
+ AFB_API_ERROR(mixer->api, "PcmSetControl: sndard=%s numid=%d name='%s' invalid/unsupported type=%d", sndcard->cid.cardid, control->numid, control->name, snd_ctl_elem_info_get_type(elemInfo));
goto OnErrorExit;
}
if (error) {
- AFB_ApiError(mixer->api, "PcmSetControl: sndard=%s numid=%d name='%s' not writable", sndcard->cid.cardid, control->numid, control->name);
+ AFB_API_ERROR(mixer->api, "PcmSetControl: sndard=%s numid=%d name='%s' not writable", sndcard->cid.cardid, control->numid, control->name);
goto OnErrorExit;
}
@@ -256,7 +256,7 @@ OnErrorExit:
return -1;
}
-STATIC void ApiPcmVerbCB(AFB_ReqT request) {
+STATIC void ApiPcmVerbCB(afb_req_t request) {
apiVerbHandleT *handle = (apiVerbHandleT*) afb_req_get_vcbdata(request);
int error, verbose = 0, doInfo = 0, doToggle = 0, doMute = -1;
json_object *volumeJ = NULL;
@@ -275,7 +275,7 @@ STATIC void ApiPcmVerbCB(AFB_ReqT request) {
, "volume", &volumeJ
);
if (error) {
- AFB_ReqFailF(request, "syntax-error", "Missing 'mute|volume|toggle|quiet' args=%s error=%s", json_object_get_string(argsJ), wrap_json_get_error_string(error));
+ afb_req_fail_f(request, "syntax-error", "Missing 'mute|volume|toggle|quiet' args=%s error=%s", json_object_get_string(argsJ), wrap_json_get_error_string(error));
goto OnErrorExit;
}
@@ -286,7 +286,7 @@ STATIC void ApiPcmVerbCB(AFB_ReqT request) {
error += AlsaCtlNumidSetLong(mixer, sndcard, handle->pcm->mute.numid, mute);
if (error) {
- AFB_ReqFailF(request, "invalid-numid", "Fail to set pause numid=%d", handle->pcm->mute.numid);
+ afb_req_fail_f(request, "invalid-numid", "Fail to set pause numid=%d", handle->pcm->mute.numid);
goto OnErrorExit;
}
@@ -301,7 +301,7 @@ STATIC void ApiPcmVerbCB(AFB_ReqT request) {
error += AlsaCtlNumidGetLong(mixer, handle->pcm->sndcard, handle->pcm->mute.numid, &mute);
error += AlsaCtlNumidSetLong(mixer, handle->pcm->sndcard, handle->pcm->mute.numid, !mute);
if (error) {
- AFB_ReqFailF(request, "invalid-numid", "Fail to toogle pause numid=%d", handle->pcm->mute.numid);
+ afb_req_fail_f(request, "invalid-numid", "Fail to toogle pause numid=%d", handle->pcm->mute.numid);
goto OnErrorExit;
}
@@ -333,7 +333,7 @@ STATIC void ApiPcmVerbCB(AFB_ReqT request) {
error = sscanf(&volString[0], "%d", &newvol);
volType = RVOL_ABS;
if (error != 1) {
- AFB_ReqFailF(request, "not-integer", "relative volume should start by '+|-' value=%s", json_object_get_string(volumeJ));
+ afb_req_fail_f(request, "not-integer", "relative volume should start by '+|-' value=%s", json_object_get_string(volumeJ));
goto OnErrorExit;
}
}
@@ -347,14 +347,14 @@ STATIC void ApiPcmVerbCB(AFB_ReqT request) {
newvol=0;
break;
default:
- AFB_ReqFailF(request, "not-integer", "volume should be string or integer value=%s", json_object_get_string(volumeJ));
+ afb_req_fail_f(request, "not-integer", "volume should be string or integer value=%s", json_object_get_string(volumeJ));
goto OnErrorExit;
}
error = PcmSetControl(mixer, handle->pcm->sndcard, &handle->pcm->volume, volType, &newvol, &oldvol);
if (error) {
- AFB_ReqFailF(request, "invalid-ctl", "Fail to set volume hal=%s card=%s numid=%d name=%s value=%d"
+ afb_req_fail_f(request, "invalid-ctl", "Fail to set volume hal=%s card=%s numid=%d name=%s value=%d"
, handle->uid, handle->pcm->sndcard->cid.cardid, handle->pcm->volume.numid, handle->pcm->volume.name, newvol);
goto OnErrorExit;
}
@@ -365,7 +365,7 @@ STATIC void ApiPcmVerbCB(AFB_ReqT request) {
}
}
- AFB_ReqSuccess(request, responseJ, handle->uid);
+ afb_req_success(request, responseJ, handle->uid);
return;
OnErrorExit:
@@ -384,7 +384,7 @@ PUBLIC void ApiPcmDelParams(SoftMixerT* mixer, AlsaPcmHwInfoT* params) {
}
PUBLIC void ApiPcmParamsShow(SoftMixerT * mixer, const char *msg, const AlsaPcmHwInfoT * params) {
- AFB_ApiInfo(mixer->api, "%s PARAMS: rate=%d, format=%d, formatString=%s",
+ AFB_API_INFO(mixer->api, "%s PARAMS: rate=%d, format=%d, formatString=%s",
msg, params->rate, params->format, params->formatString);
}
@@ -410,7 +410,7 @@ PUBLIC AlsaPcmHwInfoT * ApiPcmSetParams(SoftMixerT *mixer, const char *uid, json
"format", &format,
"access", &access);
if (error) {
- AFB_ApiError(mixer->api, "%s: sndcard=%s invalid params=%s",
+ AFB_API_ERROR(mixer->api, "%s: sndcard=%s invalid params=%s",
__func__, uid, json_object_get_string(paramsJ));
goto fail_params;
}
@@ -443,11 +443,11 @@ PUBLIC AlsaPcmHwInfoT * ApiPcmSetParams(SoftMixerT *mixer, const char *uid, json
FORMAT_CHECK(FLOAT_LE);
FORMAT_CHECK(FLOAT_BE);
- AFB_ApiError(mixer->api, "%s: %s(params) unsupported format 'S16_LE|S32_L|...' format=%s", __func__, uid, format);
+ AFB_API_ERROR(mixer->api, "%s: %s(params) unsupported format 'S16_LE|S32_L|...' format=%s", __func__, uid, format);
goto fail_params;
check_access:
- AFB_ApiNotice(mixer->api, "%s: %s format set to SND_PCM_FORMAT_%s", __func__, uid, params->formatString);
+ AFB_API_NOTICE(mixer->api, "%s: %s format set to SND_PCM_FORMAT_%s", __func__, uid, params->formatString);
#define ACCESS_CHECK(arg) if (!strcmp(access,#arg)) { params->access = SND_PCM_ACCESS_##arg; goto success;}
@@ -462,13 +462,13 @@ check_access:
ACCESS_CHECK(RW_INTERLEAVED);
ACCESS_CHECK(RW_NONINTERLEAVED);
- AFB_ApiNotice(mixer->api,
+ AFB_API_NOTICE(mixer->api,
"%s:%s(params) unsupported access 'RW_INTERLEAVED|MMAP_INTERLEAVED|MMAP_COMPLEX' access=%s",
__func__,uid, access);
goto fail_params;
success:
- AFB_ApiNotice(mixer->api, "%s:%s access set to %s", __func__, uid, access);
+ AFB_API_NOTICE(mixer->api, "%s:%s access set to %s", __func__, uid, access);
return params;
fail_params:
@@ -479,7 +479,7 @@ fail:
static void pcmChannelsDestroy(SoftMixerT * mixer, AlsaSndPcmT * pcm) {
- AFB_ApiDebug(mixer->api, "\t%s: pcm %s (%d channels)", __func__, pcm->uid, pcm->nbChannels);
+ AFB_API_DEBUG(mixer->api, "\t%s: pcm %s (%d channels)", __func__, pcm->uid, pcm->nbChannels);
AlsaPcmChannelT * channel, *tmp;
cds_list_for_each_entry_safe(channel, tmp, &pcm->channels.list, list) {
@@ -487,12 +487,12 @@ static void pcmChannelsDestroy(SoftMixerT * mixer, AlsaSndPcmT * pcm) {
free((char *)channel->uid);
free(channel);
}
- AFB_ApiDebug(mixer->api, "\t%s: pcm %s DONE", __func__, pcm->uid);
+ AFB_API_DEBUG(mixer->api, "\t%s: pcm %s DONE", __func__, pcm->uid);
}
PUBLIC void ApiPcmDelete(SoftMixerT * mixer, AlsaSndPcmT * pcm) {
- AFB_ApiDebug(mixer->api, "%s: pcm %s", __func__, pcm->uid);
+ AFB_API_DEBUG(mixer->api, "%s: pcm %s", __func__, pcm->uid);
free(pcm->apiVerbHandle);
AlsaSndCtlT * card = pcm->sndcard;
@@ -511,14 +511,14 @@ PUBLIC void ApiPcmDelete(SoftMixerT * mixer, AlsaSndPcmT * pcm) {
(strcmp(pcm->verb, SOFTMIXER_VERB_NONE)!=0)) {
int error = afb_api_del_verb(mixer->api, pcm->verb, (void**)NULL);
if (error) {
- AFB_ApiError(mixer->api, "Failed to remove verb %s", pcm->verb);
+ AFB_API_ERROR(mixer->api, "Failed to remove verb %s", pcm->verb);
}
free((char*)pcm->verb);
}
free((char*)pcm->uid);
free(pcm);
- AFB_ApiDebug(mixer->api, "%s: done", __func__);
+ AFB_API_DEBUG(mixer->api, "%s: done", __func__);
}
PUBLIC AlsaSndPcmT * ApiPcmNew(SoftMixerT* mixer) {
@@ -566,7 +566,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
, "params", &paramsJ
);
if (error) {
- AFB_ApiError(mixer->api, "%s: hal=%s missing 'uid|path|cardid|device|sink|source|params' error=%s args=%s",
+ AFB_API_ERROR(mixer->api, "%s: hal=%s missing 'uid|path|cardid|device|sink|source|params' error=%s args=%s",
__func__, uid, wrap_json_get_error_string(error), json_object_get_string(argsJ));
goto fail_pcm_sndcard;
}
@@ -579,14 +579,14 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
// try to open sound card control interface
pcm->sndcard->ctl = AlsaByPathOpenCtl(mixer, pcm->uid, pcm->sndcard);
if (!pcm->sndcard->ctl) {
- AFB_ApiError(mixer->api, "%s: hal=%s Fail to open sndcard uid=%s devpath=%s cardid=%s",
+ AFB_API_ERROR(mixer->api, "%s: hal=%s Fail to open sndcard uid=%s devpath=%s cardid=%s",
__func__, uid, pcm->uid, pcm->sndcard->cid.devpath, pcm->sndcard->cid.cardid);
goto fail_pcm_sndcard;
}
if (direction == SND_PCM_STREAM_PLAYBACK) {
if (!sinkJ) {
- AFB_ApiError(mixer->api, "%s: hal=%s SND_PCM_STREAM_PLAYBACK require sinks args=%s",
+ AFB_API_ERROR(mixer->api, "%s: hal=%s SND_PCM_STREAM_PLAYBACK require sinks args=%s",
__func__, uid, json_object_get_string(argsJ));
goto fail_pcm_sndcard_ctl;
}
@@ -595,7 +595,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
if (direction == SND_PCM_STREAM_CAPTURE) {
if (!sourceJ) {
- AFB_ApiError(mixer->api, "%s: hal=%s SND_PCM_STREAM_CAPTURE require sources args=%s",
+ AFB_API_ERROR(mixer->api, "%s: hal=%s SND_PCM_STREAM_CAPTURE require sources args=%s",
__func__, uid, json_object_get_string(argsJ));
goto fail_pcm_sndcard_ctl;
}
@@ -608,7 +608,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
, "controls", &controlsJ
);
if (error) {
- AFB_ApiNotice(mixer->api, "%s: hal=%s pcms missing channels|[controls] error=%s (%s)",
+ AFB_API_NOTICE(mixer->api, "%s: hal=%s pcms missing channels|[controls] error=%s (%s)",
__func__, uid, wrap_json_get_error_string(error), json_object_get_string(argsJ));
goto fail_pcm_sndcard_ctl;
}
@@ -643,7 +643,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
break;
}
default:
- AFB_ApiError(mixer->api, "%s:%s invalid pcm=%s", pcm->uid, __func__, json_object_get_string(channelsJ));
+ AFB_API_ERROR(mixer->api, "%s:%s invalid pcm=%s", pcm->uid, __func__, json_object_get_string(channelsJ));
goto fail_pcm_sndcard_ctl;
}
}
@@ -651,7 +651,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
// check sndcard accepts params
pcm->sndcard->params = ApiPcmSetParams(mixer, pcm->uid, paramsJ);
if (!pcm->sndcard->params) {
- AFB_ApiError(mixer->api, "%s: hal=%s Fail to set params sndcard uid=%s params=%s",
+ AFB_API_ERROR(mixer->api, "%s: hal=%s Fail to set params sndcard uid=%s params=%s",
__func__, uid, pcm->uid, json_object_get_string(paramsJ));
goto fail_pcm_sndcard_ctl;
}
@@ -665,7 +665,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
, "mute", &muteJ
);
if (error) {
- AFB_ApiNotice(mixer->api,
+ AFB_API_NOTICE(mixer->api,
"%s: source missing [volume]|[mute] error=%s control=%s",
__func__, wrap_json_get_error_string(error), json_object_get_string(controlsJ));
goto fail_pcm_channels;
@@ -718,7 +718,7 @@ PUBLIC AlsaSndPcmT * ApiPcmAttachOne(SoftMixerT *mixer, const char *uid, snd_pcm
error = afb_api_add_verb(mixer->api, apiVerb, apiInfo, ApiPcmVerbCB, handle, NULL, 0, 0);
if (error) {
- AFB_ApiError(mixer->api, "%s mixer=%s verb=%s fail to Register Master control ",
+ AFB_API_ERROR(mixer->api, "%s mixer=%s verb=%s fail to Register Master control ",
__func__, mixer->uid, apiVerb);
goto fail_handle;
}