aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-softmixer.h
AgeCommit message (Collapse)AuthorFilesLines
2019-02-18plug route: added a calculation for the number of physical channelsThierry Bultel1-0/+1
Adds (mainly for debug purpose) a calculation on the actual number of physical channels that are used by the created ttable Change-Id: I5717046003851ebe297a494dcdd97c4d67e34d0b Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-18core pcm: use the same model for writing and reading audioThierry Bultel1-2/+5
Reading sound frames relies on usage of poll before calling snd_pcm_writei Recent seeks for bugs and CPU load issues have shown that the same thing must be done on the write side. Thus this commit uses the same mechanism, including the dedicated event pipe for the thread termination. Change-Id: Ifd5407c9e27da7801623583a6f7d4a2e845b43ea Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-18pcm plugs: rework the alsa config cleanupThierry Bultel1-3/+7
The alsa config (for softvol, routes, rate conversion ...) was cleaned up by the owner stream or zone, at their deletion time. This was a mistake, because when the stream or zone creation was not complete, the cleanup of the configuration was not done. Instead of doing that, the config is attached to the plug objects as private data (in the AlsaPcmCtlT structure). Since the AlsaPcmCtlT are always recorded in the creation transaction, it is easy to call the cleaning callback (when it exists) when the transaction is deleted. Change-Id: I952871518a20bfe0be6398887bc747338cf574fb Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-18alsa-api-pcm: added an 'optional' parameterThierry Bultel1-0/+5
This adds a boolean 'optional' parameter for both playback and capture devices. When the device is not detected, the stream(s) that use is are not created, without leading to the exit of the softmixer. Change-Id: I3effbd61bfe1d1d4a7cde573354b9db791f759cc Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-18alsa-api-pcm: added support of quirksThierry Bultel1-0/+6
Adds an optional array of quirks in the parameters of playback and captures. For now, the only known quirk is a needed workarround for writing sound output on the minnow board. Change-Id: I6c65d110a1f9333ccb77cd8f4eeb9c088d0d2eca Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2019-02-12Add support for AVIRTMark Farrugia1-4/+5
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-11/+11
- 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-3/+14
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-39/+109
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-08-31Added bluez sound playback supportThierry Bultel1-1/+4
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-8/+17
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-27/+35
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-06-29Update version of app-controller-submodule submodule.Loïc Collignon1-1/+1
Changes of app-controller-submodule: (0f3063b - Romain Forlot) Be able to dispatch required api at the wanted time (1ff524b - Romain Forlot) Change LUA package path at LUA interpreter load (738ae54 - Romain Forlot) Don't load two times a plugin even for LUA (c04f029 - Sebastien Douheret) Fixed hidden bound variable (apiHandle) (cfe3919 - Sebastien Douheret) Fixed null value when push Lua arguments (69c0585 - José Bollo) Adjust to compile with incoming bindings v3 (d7e260c - José Bollo) Remove declaration to not existing functions (8ac6625 - Romain Forlot) Add 2 lua utilities function (d3504bb - Jonathan Aillet) Update README.md for new metadata keys. Change-Id: I794ed0ca3a054e7baf11769207007ef733854474 Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
2018-06-26Rework the pcm copy loop and save a lot of CPUeelThierry Bultel1-2/+8
- removed the systemd polling usage - uses a while loop for reading - improved the write loop, leveraging the available space at each iteration Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-06-22pcm core: fixed spurious XRUN issuesThierry Bultel1-8/+16
This fixes the numerous XRUN issues seen on some cards. The trick is to set the buffer_size & period size in hw parameters. These ones are calculated from an expected maximum latency. Also, the writei is done in a loop to be robust to overruns and partial writes. Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-06-11Autorize direct zone to point on sndcardfulup1-1/+2
2018-06-10Added cardid+verb return for capture+playback sndcardfulup1-0/+1
2018-06-10Cleanup and added return of previous volume when setting new valuefulup1-2/+7
2018-06-05Use attach info verb to build attach response.fulup1-2/+2
2018-06-04Move to Dynamic Mixer API (work in progress)Fulup Ar Foll1-82/+140
2018-05-18Implements volume rampingFulup Ar Foll1-12/+61
2018-05-17Implemented sub API for stream with volume/pause/toggle/...Fulup Ar Foll1-0/+1
2018-05-17Initial version with dynamic APIsFulup Ar Foll1-13/+17
2018-05-17Cleanup soft vol control creationFulup Ar Foll1-1/+3
2018-05-14Move to new Romain controller versionfulup1-1/+13
2018-05-13First testable version.Fulup Ar Foll1-7/+20
Mixing with volume and mute per audio role works.
2018-05-13Initial version with softvol,Route,Multi,DmixFulup Ar Foll1-20/+76
2018-05-11Initial version with softvol control and DMIXFulup Ar Foll1-43/+41
2018-05-08Fist AlsaLoop model playing music (work in progress)Fulup Ar Foll1-7/+51
2018-04-30On going effort, now load and support LUA+C pluginFulup Ar Foll1-0/+49