summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* mixer: add documentation about postcondition of removal event processingTakashi Sakamoto2022-06-271-0/+12
| | | | | | | | | | | | | | | | | | | | PulseAudio and PipeWire seems to appear including careless code to process events of mixer element in implementation of mixer class. * https://lore.kernel.org/alsa-devel/YrbxZ2b+3rIdi7Ut@workstation/ They register own implementation of mixer class. At addition event, they attach own mixer element into hcontrol element. However at removal event, they never detach the mixer element from hcontrol element. They hit assertion in mixer API internal due to unsatisfied postcondition. This commit adds documentation about postcondition of removal event processing so that developer for implementation of mixer class easily realize the way to satisfy the postcondition. Fixes: https://github.com/alsa-project/alsa-lib/pull/244 Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: share plugin: handle -EINTRJaroslav Kysela2022-06-271-12/+18
| | | | | | Fixes: https://github.com/alsa-project/alsa-lib/pull/242 Fixes: b97047b4 ("pcm: share plugin: return error if socket read or write call fails") Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: share plugin: return error if socket read or write call failsTomohiro IKEDA2022-06-271-4/+7
| | | | | | Fixes: https://github.com/alsa-project/alsa-lib/pull/242 Signed-off-by: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* rawmidi: fix the params_mode check condition in snd_rawmidi_tread()Jaroslav Kysela2022-06-261-1/+1
| | | | | | | | The condition should be obviously reversed. Reported-by: Mark ZurSchmiede <zursch@gmail.com> Fixes: 5ac61983 ("rawmidi: allow timestamp reads only for the appropriate read mode") Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: dmix - Add error handler for `fgets`Tomohiro IKEDA2022-06-172-4/+2
| | | | | | Fixes: https://github.com/alsa-project/alsa-lib/pull/238 Signed-off-by: Tomohiro IKEDA <rilakkuma.san.xjapan@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: list also hardware configs (hw:X) in uc_mgr_scan_master_configs() fcnJaroslav Kysela2022-06-161-13/+58
| | | | | BugLink: https://github.com/alsa-project/alsa-ucm-conf/issues/168 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* control: eld - fix the decoding for older hwJaroslav Kysela2022-06-061-3/+13
| | | | | | | | | | | | It seems that the monitor name is not always present in the ELD structure. Add asterisk suffix to notify user about the monitor present for this case. Thanks goes to Bernhard Rosenkränzer <bero@lindev.ch> for the report. Fixes: https://github.com/alsa-project/alsa-lib/pull/233 Fixes: https://github.com/alsa-project/alsa-lib/pull/234 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* conf: Use ino64_t to save and compare inode numbersSimon McVittie2022-06-051-1/+1
| | | | | | | | | | | | | | | | | | On 32-bit platforms when not using the large-file-support ABI, struct stat64 contains ino64_t which is 64-bit, while ino_t is only 32-bit. snd_config_update_r() checks whether a file has been replaced by saving the ino member of a struct stat64 and comparing it with a previously-saved inode number. On 32-bit platforms, assigning the 64-bit member of struct stat64 to a 32-bit member of struct finfo will truncate it modulo 1<<32, which could conceivably result in libasound not reloading configuration when it should (although the inode number space is large enough to make this failure mode highly unlikely). Fixes: https://github.com/alsa-project/alsa-lib/pull/231 Signed-off-by: Simon McVittie <smcv@collabora.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: fix the reload call (snd_use_case_mgr_reload)Jaroslav Kysela2022-05-273-12/+16
| | | | | | Handle the local configuration and macros trees properly. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: implement disdevall sequence commandJaroslav Kysela2022-05-244-2/+39
| | | | | | | | It is useful to run all disable sequences for all UCM devices in a verb to ensure the valid, expected initial state. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: fix memory leak in the error path (Include)Jaroslav Kysela2022-05-231-3/+4
| | | | | | | The included configuration tree must be freed in the error path, too. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: hw: change rate range syntaxJaroslav Kysela2022-05-201-15/+33
| | | | | | | | | | | | Allow three configuration types: rate 48000 # single rate rate [ 48000 ] # single rate (2nd) rate [ 44100 48000 ] # range Fixes: https://github.com/alsa-project/alsa-lib/pull/191 Fixes: ac04cb63 ("hw: add "min_rate" and "max_rate" as alternatives to single "rate" parameter") Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: hw: add "min_rate" and "max_rate" as alternatives to single "rate" ↵Benedek Kupper2022-05-201-7/+45
| | | | | | | | parameter Fixes: https://github.com/alsa-project/alsa-lib/pull/191 Signed-off-by: Benedek Kupper <benedek.kupper@streamunlimited.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: rate - rewrite the may_wait_for_avail_min callback for the rate pluginJaroslav Kysela2022-05-204-28/+43
| | | | | | | | | | Shuffle the code to avoid special conditions using the plugin type in the generic plugin code. The rate plugin has the own may_wait_for_avail_min callback implementation now. Fixes: d21e0e01 ("pcm: plugin - fix avail_min calculation on rate plugin") Fixes: https://github.com/alsa-project/alsa-lib/pull/218 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: plugin - fix avail_min calculation on rate pluginAndreas Pape2022-05-203-0/+31
| | | | | | | | | | | | | | | | | commit 88e4ae27, ff1f669d introduced a dynamic recalculation of the slave's avail_min value. The calculated avail_min setting did not take into account, that the avail_min value depends on the used sampling rate and must be adapted accordingly if the slave is using a different sampling rate. That leads to too large/too small calculated avail_min settings and inaccurate period wake-up events if a rate converter plugin is used. This patch is adapting the avail_min calculation to consider a different sampling rate between actual pcm and it's slave. Fixes: https://github.com/alsa-project/alsa-lib/pull/218 Signed-off-by: Andreas Pape <apape@de.adit-jv.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: dmix: fix wrong scaling in 32bits pcm mixingKatsuhiro Suzuki2022-05-201-2/+2
| | | | | | | | | | | | Generic mixing function for 32bits pcm has used 8bits right shift for pre-scaling. But this is generating wrong result if pcm data is negative value because return value type of bswap_32() is unsigned int. This patch adds type cast bswap_32() result to signed int. Fixes: https://github.com/alsa-project/alsa-lib/pull/222 Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: ladspa - Use LFS calls (readdir64)Jaroslav Kysela2022-05-202-2/+5
| | | | | | | | Continue the work in commit ba86ac55 ("conf: Use LFS calls when reading config files") and fix the PCM LADSPA code, too. Fixes: https://github.com/alsa-project/alsa-lib/pull/223 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: Use LFS calls (stat, scandir)Jaroslav Kysela2022-05-204-19/+19
| | | | | | | | Continue the work in commit ba86ac55 ("conf: Use LFS calls when reading config files") and fix the UCM code, too. Fixes: https://github.com/alsa-project/alsa-lib/pull/223 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* conf: Use LFS calls when reading config filesSebastian Krzyszkowiak2022-05-201-9/+9
| | | | | | | | | | | Although at first glance it doesn't seem useful to support config files larger than 2GB, LFS also influences inode size. Without this, 32-bit libasound may be unable to read config files on filesystems with 64-bit inodes, such as Btrfs or NFS. Fixes: https://github.com/alsa-project/alsa-lib/pull/223 Signed-off-by: Sebastian Krzyszkowiak <dos@dosowisko.net> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: main - fix the compilation error (signess)Jaroslav Kysela2022-05-201-1/+1
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* control: eld - add missing ctype.h header inclusionJaroslav Kysela2022-05-201-0/+1
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: fix for the unitialized write bufferJaroslav Kysela2022-05-201-3/+3
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* conf: vc4-hdmi: use a proper hdmi pcm, fix broken default pcmMatthias Reichl2022-05-191-30/+48
| | | | | | | | | | | | | | | | | | | Userspace expects to see a HDMI pcm, so remove the somewhat broken front and iec958 pcms and add a proper hdmi pcm instead. The hdmi pcm supports HD/HBR audio passthrough and relays the IEC958 status bits on to the kernel driver so it can switch to HBR audio packets if needed. The control hook is marked optional because kernels before 5.14 didn't expose the IEC958 controls. The default pcm never worked as dmix doesn't support the iec958 format. So drop dmix, only use plug and softvol, and use the hdmi pcm for iec958 formatting. Fixes: https://github.com/alsa-project/alsa-lib/issues/229 Link: https://lore.kernel.org/alsa-devel/20220430142845.229409-1-hias@horus.com/ Signed-off-by: Matthias Reichl <hias@horus.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: macro - make argument names shorterJaroslav Kysela2022-05-192-8/+8
| | | | | | | | It seems that the use the macro name as the variable prefix is too large. Use just two underscores as prefix for the macro arguments to make macro definitions more readable. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: doc - describe variants, minor correctionsJaroslav Kysela2022-05-191-2/+37
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: implement enadev2 and disdev2 sequence commandsJaroslav Kysela2022-05-195-22/+90
| | | | | | | It may be useful to call the sequences from devices from the verb sequences or another device sequences. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: add support for verb variantsJaroslav Kysela2022-05-182-20/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | The bellow configuration example creates two verbs ("HiFi" and "HiFi 7+1") with different playback channels for the "Speaker" device. SectionUseCase."HiFi" { File "HiFi.conf" Variant."HiFi" { Comment "Default" } Variant."HiFi 7+1" { Comment "HiFi 7.1" } } SectionDevice."Speaker" { Value { PlaybackChannels 2 } Variant."HiFi 7+1".Value { PlaybackChannels 8 } } Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: set SYNTAX_VERSION_MAX to 6Jaroslav Kysela2022-05-181-1/+1
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: move macros and evali substitution to Syntax 6Jaroslav Kysela2022-05-182-6/+6
| | | | | | | There should be printed an error when the new configuration blocks are used with the older alsa-lib. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: macro - add deep call protection (recursion)Jaroslav Kysela2022-05-172-0/+7
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: macro call inplace evaluate inside macroJaroslav Kysela2022-05-171-0/+5
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: macro - fix the error message, print idJaroslav Kysela2022-05-171-1/+4
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: return empty string for undefined "open" variables (arguments)Jaroslav Kysela2022-05-171-0/+2
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: allow '-' prefix to avoid errors when the variable is not definedJaroslav Kysela2022-05-171-0/+7
| | | | | | It may be useful to check if variable is not defined. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: allow passing variables through ucm open stringJaroslav Kysela2022-05-162-0/+63
| | | | | | | | | | | | | | | | | It is useful to pass information like application capabilities to the UCM configuration parser. Those variables are prefixed with '@' for the configuration files. An example: "<<<v1='a b c',x=12>>>hw:1" Variables can substituted in the configuration: "${var:@v1}" -> "a b c" "${var:@x}" -> 12 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: implement MacroDefine and Macro subtree evaluationJaroslav Kysela2022-05-136-9/+252
| | | | | | | | | | | | | | | | | | | | | | | | The arguments are set as temporary variables as /MACRO_NAME/_/ARGUMENT_NAME/. Example: # define new macro MyMacro with arguments ctl_name and ctl_value DefineMacro.MyMacro { BootSequence [ cset "name='${var:MyMacro_ctl_name}' ${var:MyMacro_ctl_value}" ] } # instantiate macro for Speaker control (short version) Macro.headphone.MyMacro "ctl_name='Speaker Switch',ctl_value=off" # instantiate macro for Mic control (second version) Macro.mic.MyMacro { ctl_name "Mic Switch" ctl_value "off" } Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* conf: fix memory leak in snd_config_substitute() for stringsJaroslav Kysela2022-05-131-0/+2
| | | | | | | When destination type is SND_CONFIG_TYPE_STRING, the old string must be freed. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: local_config may be NULL (error path)Jaroslav Kysela2022-05-131-1/+2
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: add ${evali:} substitutionJaroslav Kysela2022-05-132-1/+44
| | | | | | | | | | | | Example: Define.var1 2 LibraryConfig.test.SubstiConfig { a "${evali:$var1+1}" } Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* control: shm - initialize write bufferJaroslav Kysela2022-05-051-1/+1
| | | | | | | | | ccontrol_shm.c: In function ‘snd_ctl_shm_action’: control_shm.c:54:23: error: invalid initializer 54 | char buf[1] = 0; | ^ Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* control: decode HDMI device name from ELDJaroslav Kysela2022-05-055-1/+111
| | | | | | | | | | | | | | | | | | | The HDMI drivers set an uniform PCM names. Use ELD (EDID) to obtain the HDMI device name and send this string to applications for a better user experience. Example (aplay -l): card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 vs improved: card 1: PCH [HDA Intel PCH], device 8: HDMI 2 [Philips 272P4] Subdevices: 1/1 Fixes: https://github.com/alsa-project/alsa-lib/issues/209 Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: multi: return correct hwptr and avail from snd_pcm_multi_status()Yutao Yuan2022-05-041-1/+11
| | | | | | | | | | Ensure the logic of snd_pcm_multi_status() is consistent with snd_pcm_multi_avail_update(). Fixes: https://github.com/alsa-project/alsa-lib/pull/224 Fixes: https://github.com/alsa-project/alsa-lib/issues/217 Signed-off-by: Yutao Yuan <infmagic2047reg@outlook.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: direct - allow 'off' string for hw_ptr_alignmentJaroslav Kysela2022-05-034-4/+4
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: direct - cleanups for snd_pcm_direct_reset_slave_ptr()Jaroslav Kysela2022-05-035-22/+16
| | | | | | | - improve readability - pass slave hw_ptr as argument - improves the code flow Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: direct - add support for channel bindings in snd_pcm_direct_query_chmaps()Jaroslav Kysela2022-04-061-1/+28
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* pcm: direct: Check xrun/suspend before the slave hwptr updateTakashi Iwai2022-03-103-9/+13
| | | | | | | | | | | The xrun/suspend may happen at any time and we should check it right after the slave hwptr update (but before the actual sync_ptr update in direct pcm side). Otherwise the hwptr value may be screwed and get unexpected large read/write. Reported-by: S.J. Wang <shengjiu.wang@nxp.com> Acked-by: Shengjiu Wang <shengjiu.wang@nxp.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* pcm: direct: Move slave PCM state checks into XRUN check helperTakashi Iwai2022-03-105-132/+33
| | | | | | | | | The check of slave PCM state is always done before the client's recoveries count check, so let's merge them to the common helper. Also rename the helper function to snd_pcm_direct_check_xrun() as it's checking both slave and client states now. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* pcm: direct: Improved suspend/resume supportTakashi Iwai2022-03-104-38/+52
| | | | | | | | | | | | | | | | | | | | | | | | The current resume handling in PCM direct plugins don't treat multiple clients properly: once after the slave PCM gets resumed by one client, the access from others at a later point is seen as already running although the internal state isn't updated and becomes inconsistent. This may end up a negative size, which eventually hangs up. This patch is an attempt to improve the handling for resume. Now the suspended state is treated similarly like XRUN; namely, we keep the slave PCM "recoveries" count that is modified at each time the slave PCM XRUN happens, so that we can check the inconsistency against the client's state. As a differentiation to XRUN, we set the highest bit of recoveries count when the slave stream hits SUSPENDED state. This bit is referred at comparing with clients, and the client's state is updated to either XRUN or SUSPENDED depending on this bit. Along with this change, the actual resume is done in snd_pcm_direct_slave_recover(), and snd_pcm_direct_resume() rather calls this internally. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* pcm: direct: Propagate error code from snd_pcm_direct_client_chk_xrun()Takashi Iwai2022-03-104-14/+21
| | | | | | | | | | Change the snd_pcm_direct_client_chk_xrun() function to return the current XRUN state via an error code instead of the state change. This allows the caller more straightforwardly returning its error, and also covers the case where XRUN has been set but the function gets called twice. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* pcm: rate: fix drain of partial period at end of bufferAlan Young2022-03-081-2/+11
| | | | | | | | | | | | | | | | | | | | | | | In the case that: * the buffer size is not an integer multiple of the period size, and * drain must flush a partial period located before the end of the buffer but without a full period available, where * these conditions may pertain to the source or slave pcm buffer, and * because rate conversion is always done on a full period, it is necessary to check that both a full source period is available before source pcm buffer wrap and a full slave period is available before slave pcm buffer wrap in order to use the simple, single-commit implementation in snd_pcm_rate_commit_area(). The alternative fix would be to change snd_pcm_rate_write_areas1() to take size and slave_size parameters. This would be more disruptive to the code base, tricky to get right, and is unnecessary given that snd_pcm_mmap_commit() only commits the partial period of actually valid converted samples. Fixes: 3047f8fa5a3d ("Fix possible problems of playback drain with rate plugin") Signed-off-by: Alan Young <consult.awy@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>