summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-mixer.c
AgeCommit message (Collapse)AuthorFilesLines
2019-06-06Prevent error when 'hal-dependencies' is receivedhalibut_7.99.3halibut_7.99.2halibut/7.99.3halibut/7.99.27.99.37.99.2Jonathan Aillet1-1/+2
Prevent error when 'hal-dependencies' data is received by softmixer when call to 'attach' verb is done. BUG-AGL: SPEC-2329 Change-Id: I434f95aa62cf2617e6edb1dde3c7c39778e1fb5d Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2019-02-20loops/avirt: forget saved loops after creationThierry Bultel1-7/+10
avirt needs a backup of loops, before creating the streams. However, this breaks software dynamic streams such as those of of type bluez-alsa, because the logic was re-calling the loop creation at each call of the 'attach' verb. The fix simply consists in forgetting the saved loops once they are created Change-Id: I63f492b89233bed12de583de6e1077ac1c9c3ccf Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-18alsa-transaction: simplify the cleanupThierry Bultel1-24/+18
This simplifies the invocation of cleanup, by only using AlsaMixerTransactionDelete that performs the 3 actions of cleanup, removal from list, and memory freeing. Fixes a bug at MixerExit, because the first transaction was not removed from the list and led to a double free error. Also added a boolean parameter to AlsaMixerTransactionObjectDelete (was AlsaMixerTransactionObjectForget before), that decides wether or not the found object must be destroyed with its destructor (for most of the cases) or simply freed in memory (which is needed for loop device). Change-Id: I2eacbf80a22e3d556dc432d393a1807fcd7c47fb Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-12Add support for AVIRTMark Farrugia1-11/+22
Leverage the new AVIRT driver for a more secure, more dynamically configurable loopback sound driver. To use, replace the file smixer-4a-default.json with smixer-4a-avirt.json, at /usr/libexec/agl/smixer/etc. The snd-avirt drivers are installed in AGL by default as of 6.99.2. The existing snd-aloop configuration is not broken by this change. Change-Id: I827636656c109a7393ad77997e05069a2462ea46 Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
2019-01-24Git submodule migration to separated librariesRomain Forlot1-44/+44
- Replace controller binder functions definition with the binder ones. and remove the last used submodules to use the separated libraries. - Add liburcu as a project dependency in addition to the others ones. Bug-AGL: SPEC-2139 Change-Id: If46eed24018e28e58d1e62397f4355d2aa46a58e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-22Implemented the bug cleanup at application exitStephane Desneux1-1/+49
Fixes most memory leaks in softmixer. The concept of 'transaction' for dynamic streams has been generalized to the objects created at startup. The cleanup is done via a handle set through a atexit() call. Also added a missing strdup in alsa-api-loop, that fixes a double free. Warning, the bluez-alsa PCM are not closed in this version. This is intentional due to a BUG in the bluealsa ioplug PCM, that crashes upon close (pthread_cancel is used to terminate the io_thread and things get very bad. I have a pending fix for that, relying on a cancellation pipe, but deeper testing must be done). As an effect, only one phone call can be made, else 4a needs to be restarted Change-Id: Idb84cafe15f17c0ef02fcc70296d541dc55a2dcf Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh> Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
2018-12-19Add support for bluetooth telephonyguppy_6.99.3guppy/6.99.36.99.3Thierry Bultel1-172/+170
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 <thierry.bultel@iot.bzh>
2018-11-13remove dead code and renamed unobvious variables6.9.0Thierry Bultel1-2/+2
Changed the ringbuffer "xxx_free" function to something more explicit, because it does not free anything. Changed "single letter" variables to nicer names Change-Id: I000c57aa5cc684d387105441889e011a45a6ccf3 Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-09-20Remove an unfilled response json objectJonathan Aillet1-3/+1
Remove an unfilled response json object when a call is received to change bluetooth streamed devbie. Change-Id: I72ad4cd71c29e3cdf1427813228f6c7df63b3144 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-09-10bluez-alsa: fixed the null device logicThierry Bultel1-2/+1
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-09-07fixed crash upon misconfiguration of capture/playback devicesThierry Bultel1-6/+8
The null pcmplug case was not correctly handled in various places. Also fixed some typos in the log Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-08-31Added bluez sound playback supportThierry Bultel1-8/+56
This adds sound playback for incoming sound from connected bluetooth devices. In this version, the softmixer relies on a modified bluez-alsa version (https://github.com/iotbzh/bluez-alsa), that provides an ioplug PCM bluezalsa connection proxy. The softmixer api has a new verb to dynamically set the device to listen to: afb-client-demo ws://localhost:1234/api?token=\uuid=123 smixer bluezalsa_dev '{"interface":"hci0", "device":"F6:32:15:2A:80:70", "profile":"a2dp"}' In this way it is possible to switch from a bluezalsa audio source to another without any further configuration. For now, only interface hci0 is supported. This commit also migrates the softmixer binding to API v3 Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-07-20rework the sound capture & playback modelThierry Bultel1-1/+1
Now uses two threads for in the playing loop The first one reads from the capture device (ie, a phys. capture, or snd_aloop) and writes data to a circular buffer. The second one gets data from the circular buffer and outputs it to the playback. This model solves a lot of correlated timing bugs between read & write tasks. The read tasks only wakes up the write task when the buffer is 80% full. The buffer size big enough to hold 2 seconds of sound. The mute implementation has also been simplified, since it has been found out that it was possible to recover from an interrupted read, by calling snd_pcm_start additionnally to snd_pcm_prepare. Thus, the mute code consists in listening to an extra file descriptor in the read loop. Reading from that descriptor gives the mute or unmute command sent at higher level (in the PCM control event callback). When a 'mute' order is get, the capture sound fd is simply backup and replaced by '-1' in the set of the poll of the read task. When a 'unmute' order is get, the fd is simply restored. The start threshold is only computed for capture, and hardcoded to 1 for playback. This removes most of the remaining EPIPE on playback. The stop threshold has been removed. It had bad side effects on the amount of writeable data returned by snd_pcm_avail_update (was returning too small chunks) Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-07-11stops the read/write loop when the stream is mutedThierry Bultel1-4/+5
when the stream is muted (due to the configuration, or due to a HAL request), the read/write loop is stopped. The benefit is that muting will work with capture devices that do not implement the mute in their driver. The inconvenient of stopping the read loop is that it has made appear an unexpected side-effect: the poll on capture does not trig for further incoming frames. The workaround is to completely close, then reopen and configure the capture PCM. Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-07-03Uses the APIv3 compatibility to vdynThierry Bultel1-12/+0
Uses the new compatibility for vdyn based on V3 Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-06-22plugins: code & log cleanupThierry Bultel1-3/+3
2018-06-22alsa-api-mixer: code & log cleanupThierry Bultel1-14/+42
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-06-11Correct issues when calling info verbJonathan Aillet1-7/+4
Correct issues when calling info verb : - Two 'AFB_ReqFail' was called when an error was detected on info call reqsuest json (generating an application framework error). - The error messages wasn't up to date. Change-Id: Ifbb94854bc8a9d13ddf702defa94eaa6cf87e9ba Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-06-10Authorize new section at mixer initializationJonathan Aillet1-1/+2
Authorize the new section 'mixerapi' to be present into the json sent to initialize mixer. Change-Id: I7feed818f19f2d93566f6e1634933462828dbdf0 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-06-10Documentation/cleanupfulup1-1/+2
2018-06-10Added cardid+verb return for capture+playback sndcardfulup1-71/+263
2018-06-10Added stream/ramp return to fit HAL attach requestfulup1-88/+155
2018-06-10Cleanup and added return of previous volume when setting new valuefulup1-61/+201
2018-06-06Move smixer API create+attach into controller onload sectionfulup1-71/+9
2018-06-06Fixed the MixerInfoAction replyThierry Bultel1-7/+4
Make it robust to empty source, and set the source when input is a direct capture device. Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-06-05Fix alsa URI within attach responsefulup1-2/+3
2018-06-05Use attach info verb to build attach response.fulup1-6/+8
2018-06-05Update info command and move HTML5 to new APIfulup1-25/+101
2018-06-04Fixed compilation issues with gcc >= 7.2Thierry Bultel1-1/+1
Fixed some warnings about uninitialized variables
2018-06-04Move to Dynamic Mixer API (work in progress)Fulup Ar Foll1-145/+214
2018-05-18Added create/close mixer APIFulup Ar Foll1-27/+96
2018-05-18Implements volume rampingFulup Ar Foll1-4/+4
2018-05-17Implemented sub API for stream with volume/pause/toggle/...Fulup Ar Foll1-4/+56
2018-05-17Initial version with dynamic APIsFulup Ar Foll1-0/+150