Module Name: src Committed By: snj Date: Mon Jan 15 00:08:55 UTC 2018
Modified Files: src/share/man/man4 [netbsd-8]: audio.4 src/sys/dev [netbsd-8]: audio.c audiovar.h Log Message: Pull up following revision(s) (requested by nat in ticket #489): share/man/man4/audio.4: 1.81-1.82 sys/dev/audio.c: 1.376 via patch, 1.407-1.413, 1.415-1.440, 1.441 via patch, 1.443-1.450 sys/dev/audiovar.h: 1.59 via patch, 1.65-1.68 Improve audio_set_vchan_defaults(). - Correct confused input/output parameters. - Remove sc->{sc_channels, sc_precision, sc_frequency}. They are the same as sc->sc_vchan_params.{channels, precision, sample_rate}. The input parameter of audio_set_vchan_defaults() is now only sc->sc_vchan_params. Fix PR kern/52437 Move play/rec mix ring buffers into a virtual channel sc_mixring. NFCI. Call audio_mix for a third time - thus ensuring there is a block of data in the mix ring before the audio interrupt occurs. This addresses the instability seen in the audio atf tests. Improve logic in audio_initbufs(). No functional changes intended. Ensure proper use of sc_opens (play back) and sc_recopens (recording). Fix logic for /dev/sound so audiosetinfo is only called once. These changes are to ensure that init_output/input is only called once for the respective function play back or recording. For multiple recording or plack back streams init_input/output is only called once fot the first play/rec stream. This addresses PR kern/52580, PR kern/52581 and PR kern/52582 analyzed and reported by isaki@. Fix return value. fo_mmap is expected to return errno on error. Fix return value. fo_poll is expected to return revents on error. Fix return value. fo_kqfilter is expected to return errno on error. This is the rest of 1.226 (10 years ago). Add latency sysctl to adjust hw blocksize and hence latency of the mixer. usage: sysctl -w hw.hdafg0.lantency="value in milliseconds" It is possible to set the latency of the mixer unless a static blocksize is configured by the underlying hardware driver (pad, vcaudio on RPI). Documentation updates to audio.4 will occur in a follow up commit. OK christos@. Ensure that the low/high water marks are at least PREFILL_BLOCKS. Independent blocksizes for virtual channels where a static blocksize is not stipulated by the underlying hw driver. This improves latency in games esp. when the stream format differs from the harware format. OK christos@. No externs in .c files! Include ioconf.h for struct cfdriver xyz_cd. round_blocksize is only used for the hardware ring buffer. All other buffers (mix ring, streams) are set to be a power of 2. This allows for consistent latency where a static blocksize is enforced by the underlying audio device driver. Ok christos@. Move calculation of sc_latency into a function. The latency of the audio device is updated on attach in the audio auto config and shown on screen. Ok christos@. Only allow blocksizes greater or equal to the calculated one. This should help applications as the blocksize obtained (AUDIO_SET/GETINFO) will work without stutter. Ok christos@. Revert commit rev 1.419 to audio.c. This should address PR kern/52685. This also means that drivers that have a static block size will have more latency at lower sample rates/precision/channels. Also audio drivers that do more than supply rounded blocksizes in their round_blocksize functions will have to be changed. Use mix ring block size in audio write, startp, and audio drain. Allow for block sizes less than hw block size. This allows for the lowest possible latency for all precision, sample rate and frequencies. This is a rework of rev 1.419. Calc latency when altering precision, frequency and channels sysctls. No need to ratify block size twice as this is done in audio_initbufs. This is a rework of rev 1.421. Revert to previous. It is necessary to use the calculated blocksize if none supplied. Tested by martin@. Blocksizes sould be rounded to a power of 2 as OSS applications need this. Tested by martin@. AU_RING_SIZE -> s.bufsize in audio_initbufs. A sysctl is now available to disable the in kernel mixer. sysctl -w hw.hdafg0.usemixer=0 There currently is a problem draining the last block with the mixer disabled. I will fix this in a follow up commit. AFAIK there will be a problem wiht vs(4) on x68k with the mixer disabled as the filters for mulaw, alaw and unsigned linear have been removed post audio mixing changes. Documentation for this sysctl variable will be made to audio.4 in a follow up commit. Ok christos@. Use mixring blocksizes in the right places when mixer is enabled. This means that x68k's vs audio works once again with sysctl usemixer=1. Tested with xm6i. Don't return EIO falsely when dealing with the hardware vc. Draining of the hardware vc on close is now possible. Plug memory leak as the mixer state does not grow or shrink when audio mixing is disabled. This avoids triggering a panic also. Improved draining function for when the mixer is and is not enabled. One block of silence is also played in audio drivers using start_output when draining the hardware, this helps playback of short (less than blocksize) samples. Improved audiostartp for when audio mixing is disabled. audio_pint improvements for when audio mixing is disabled. When audio mixing is disabled there is only the hardware vc the mix ring is not used. The harware vc is rounded to a power of two then round_blocksize is called. This improves playback and makes it possibile to use mmapped audio on usb. For the virtual stream it is required to insert silence. As these streams are not harware streams audio_pint_silence is ineffective. As audio_mix() was the only consumer of audio_pint_silence it has been removed along with sc_sil_count - which was only used by this function. Add vc to debug messages in audio_mix. Also add debug message when available data in the vc is less than the mix ring blocksize. NFC. Use correct combination of mix ring block size and vc playring used low for signalling the writer or fetching data from the vc play ring filters. When dealing with the ring buffer sc_mpr.s it is necessary to use the hwvc or mixring block sizes as they represent the final size of the data to be played back from the stream vc. When dealing with sc_pustream when there is play back filters or not one should use the vc->sc_mpr.blocksize, as this represents the amount of data before going through play back filters. This should address PR kern/52685. Speed up improvements for MIX_FUNC. As suggested by jmcneill@. Only init the mix ring if sc_usemixer is enabled as with mixing set to false the mix ring is not used. Allow the hwvc block size to be set to any amount with audio mixing disabled. Convert double block size of data though the play back filters. This is primarily for when audio mixing is disabled to stop inserting silence when there is data available. This change should have no effect when mixing is enabled as there is only 1 block of data in the mix ring. Whitespace. Only signal a pause change on a transition of a pause change. This addresses a problem found in audio/sox causing high cpu usage. Path and analysis by Onno van der Linden. Rework of play/rec threads to ensure effective use of locks. Addresses part of PR kern/52889 where the mixing thread would not exit on audio detach. Forcefully detach children of audio instances. This addresses part of PR kern/52889 as children of pad(4) were not detaching. Document the hw.driverN.latency sysctl variable. Bump date for previous. Remove superfluous Pp. Allow open of audioctl devices whilst audio is open with the mixer disabled. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.79.2.1 src/share/man/man4/audio.4 cvs rdiff -u -r1.357.2.9 -r1.357.2.10 src/sys/dev/audio.c cvs rdiff -u -r1.55.2.4 -r1.55.2.5 src/sys/dev/audiovar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.