From e0f57e523112e1bc73a04e8615d7a21355f0ce0e Mon Sep 17 00:00:00 2001 From: Thierry Bultel Date: Tue, 4 Dec 2018 23:11:20 +0100 Subject: Add support for bluetooth telephony This adds support for bluetooth telephony. A big rework in the softmixer internals has been mandatory, in order to support dynamic streams creation and deletions. Bluetooth telephony relies on the recent evolutions of bluez-alsa, the most important one being the support of HFP over Ofono. The softmixer opens PCM ioplugs provided by bluez-alsa. Bluetooth SCO needs 2 streams, one for listening and the other for talking. These streams are created upon requests sent by the hal-manager. The hal manager subscribes for bluez-alsa events and request the list of availalble transports. For each "attach" transaction verb, the softmixer maintains a list of the all created objects (sources, sinks, zones, ramps, streams, and more) Additionnally, it creates a new verb when the attach succeeds, that verb is typically something like "sco_XX:XX:XX:XX:XX:XX", and the only supported action at the present time is {"action":"remove"}, that performs all the cleanup of the registered objects. Change-Id: I1b119e6c079e60daf771e63c083a1ef33a39f379 Signed-off-by: Thierry Bultel --- plugins/alsa/alsa-effect-ramp.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'plugins/alsa/alsa-effect-ramp.c') diff --git a/plugins/alsa/alsa-effect-ramp.c b/plugins/alsa/alsa-effect-ramp.c index 312bdfa..e51879d 100644 --- a/plugins/alsa/alsa-effect-ramp.c +++ b/plugins/alsa/alsa-effect-ramp.c @@ -84,7 +84,7 @@ PUBLIC int AlsaVolRampApply(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaStreamA long curvol, newvol; const char *uid, *volS; json_object *volJ; - int error, index; + int error; uint64_t usec; int count = 0; @@ -93,7 +93,9 @@ PUBLIC int AlsaVolRampApply(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaStreamA , "volume", &volJ ); if (error) { - AFB_ApiError(mixer->api, "AlsaVolRampApply:mixer=%s stream=%s invalid-json should {uid:ramp, vol:[+,-,=]value} ramp=%s", mixer->uid, stream->uid, json_object_get_string(rampJ)); + AFB_ApiError(mixer->api, + "%s: mixer=%s stream=%s invalid-json should {uid:ramp, vol:[+,-,=]value} ramp=%s", + __func__, mixer->uid, stream->uid, json_object_get_string(rampJ)); goto OnErrorExit; } @@ -125,7 +127,9 @@ PUBLIC int AlsaVolRampApply(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaStreamA } if (count != 1) { - AFB_ApiError(mixer->api, "AlsaVolRampApply:mixer=%s stream=%s invalid-numeric expect {uid:%s, vol:[+,-,=]value} get vol:%s", mixer->uid, stream->uid, uid, json_object_get_string(volJ)); + AFB_ApiError(mixer->api, + "%s: mixer=%s stream=%s invalid-numeric expect {uid:%s, vol:[+,-,=]value} get vol:%s", + __func__, mixer->uid, stream->uid, uid, json_object_get_string(volJ)); goto OnErrorExit; } break; @@ -134,35 +138,47 @@ PUBLIC int AlsaVolRampApply(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaStreamA break; default: - AFB_ApiError(mixer->api, "AlsaVolRampApply:mixer=%s stream=%s invalid-type expect {uid:%s, vol:[+,-,=]value} get vol:%s", mixer->uid, stream->uid, uid, json_object_get_string(volJ)); + AFB_ApiError(mixer->api, + "%s :mixer=%s stream=%s invalid-type expect {uid:%s, vol:[+,-,=]value} get vol:%s", + __func__, mixer->uid, stream->uid, uid, json_object_get_string(volJ)); goto OnErrorExit; } error = AlsaCtlNumidGetLong(mixer, sndcard, stream->volume, &curvol); if (error) { - AFB_ApiError(mixer->api, "AlsaVolRampApply:mixer=%s stream=%s ramp=%s Fail to get volume from numid=%d", mixer->uid, stream->uid, uid, stream->volume); + AFB_ApiError(mixer->api, + "%s: mixer=%s stream=%s ramp=%s Fail to get volume from numid=%d", + __func__, mixer->uid, stream->uid, uid, stream->volume); goto OnErrorExit; } // search for ramp uid in mixer - for (index=0; index<= mixer->max.ramps; index++) { - if (!strcasecmp(mixer->ramps[index]->uid, uid)) { + AlsaVolRampT * ramp; + bool found = false; + cds_list_for_each_entry(ramp, &mixer->ramps.list, list) { + if (ramp->uid && !strcasecmp(ramp->uid, uid)) { break; } } - if (index == mixer->max.ramps) { - AFB_ApiError(mixer->api, "AlsaVolRampApply:mixer=%s stream=%s ramp=%s does not exit", mixer->uid, stream->uid, uid); + if (!found) { + AFB_ApiError(mixer->api, + "%s: mixer=%s stream=%s ramp=%s does not exit", + __func__, mixer->uid, stream->uid, uid); goto OnErrorExit; } VolRampHandleT *rHandle = calloc(1, sizeof (VolRampHandleT)); + if (rHandle == NULL) { + SOFTMIXER_NOMEM(mixer->api); + goto OnErrorExit; + } rHandle->uid = stream->uid; rHandle->numid = stream->volume; rHandle->sndcard = sndcard; rHandle->mixer = mixer; - rHandle->ramp = mixer->ramps[index]; + rHandle->ramp = ramp; rHandle->target = newvol; rHandle->current = curvol; rHandle->sdLoop = mixer->sdLoop; -- cgit 1.2.3-korg