summaryrefslogtreecommitdiff
path: root/sys/dev/audio.c
AgeCommit message (Collapse)Author
2009-06-18fix previous: start playback when at least one block of data hasJacob Meuser
been written to the device, instead of waiting for a write(2) when the buffer is or will be over the high water mark. ok ratchov@
2009-03-21don't call uiomove(9) at IPL_AUDIO, slightly simplify the codeAlexandre Ratchov
help from and ok jakemsr
2009-03-16first stage of removing ``copying & needfeel'' flags thatAlexandre Ratchov
make the audio driver missing blocks and, thus, breaking full-duplex apps. help and ok jakemsr
2009-01-16deal with sample precisions that are not a power of 2.Jacob Meuser
discussed with and ok ratchov; manpage tweak from naddy, thanks
2008-10-30for devices that do not allow independent setting of recording andJacob Meuser
playback parameters (like the macppc i2s devices), be sure to synchronise recording parameters to playback parameters when configuring for full-duplex operation, as audio(4) dictates. ok ratchov
2008-10-25audio(9) says low level drivers are allowed to change the requestedJacob Meuser
values of the audio_params structure during AUDIO_SETINFO if the hardware cannot be set to exactly the requested mode. some drivers do this sometimes. others always return EINVAL if there isn't an exact match. be more consistent. only return EINVAL if an absurd parameter was requested, otherwise return a supported set of parameters, as close as possible to what was requested. with/ok ratchov@
2008-09-29account for data expansion due to emulation in AUDIO_GET{I,O}OFFSJacob Meuser
ioctls. ok ratchov@
2008-08-10'flus' -> 'flush', 'waitinf' -> 'waiting'. From Dawe via tech@.Kenneth R Westerback
2008-07-29When paused (or overrun), the record ring pointers are not incrementedAlexandre Ratchov
properly in audio_rint(), the periodic boundary conditions aren't met. This causes, later read(2) to return EFAULT while trying to access unmapped regions of the kernel address space. Fix this by using the correct pointer arithmetic. ok jakemsr@
2008-04-21allow low level audio drivers to specify a default sample format,Jacob Meuser
instead of 8-bit mono mulaw @ 8kHz. this is just the infrastructure; no drivers are specifying a default yet. ok ratchov@, deanna@
2008-04-04if full-duplex is being turned on, also set the oprtational mode toJacob Meuser
for both recording and playback. ok ratchov
2008-03-22add audio(4) driver the ability to use different block sizes for play andAlexandre Ratchov
record modes. This makes possible to have blocks of the same duration if the play and record formats are different. The API change is backward compatible, so it shouldn't be noticed by current audio ports. ok jakemsr
2008-03-22when setting the block size, use the scale factor only once inAlexandre Ratchov
audiosetinfo(), so the block size don't get scaled twice. Also fix the formula used in audiosetinfo(). ok jakemsr
2008-03-12Set the default high water mark to the buffer size, instead of the bufferAlexandre Ratchov
size minus one block. Otherwise, recording cannot work with 32kB blocks. ok jakemsr@
2008-02-28from audio(4):Jacob Meuser
blocksize sets the current audio blocksize. The generic audio driver layer and the hardware driver have the opportunity to ad- just this block size to get it within implementation-required limits. Upon return from an AUDIO_SETINFO call, the actual blocksize set is returned in this field. Normally the blocksize is calculated to correspond to 50ms of sound and it is recalcu- lated when the encoding parameter changes, but if the blocksize is set explicitly this value becomes sticky, i.e., it remains even when the encoding is changed. The stickiness can be cleared by reopening the device or setting the blocksize to 0. however, there were insufficient checks to make the blocksize is actually sticky once it is set by the user. this adds them. ok ratchov@
2007-11-17use tables to determine the best control to use for play.gain, record.gainAlexandre Ratchov
and monitor_gain; this makes play.gain always usable as general purpose volume knob even on devices that don't have outputs.master. ok jakemsr@, deanna@
2007-10-28prepare audio(4) for addition of the envy(4) driver: enable 32bit samplesAlexandre Ratchov
(basically only audio_fill_silence() must be updated) and bump max channel number to 12 ok jakemsr@
2007-10-28the pointer we give to audio_fill_silence() may point in the middle of aAlexandre Ratchov
sample (eg. if write(2) have written an odd number of bytes and 16bit encoding is used), so we'll not properly write silence. To fix this, round start pointer to fill with silence uncomplete samples too. ok jakemsr@
2007-10-27fix: when a block is captured audio_rint() is called, we mustAlexandre Ratchov
consider that the ring buffer has overrrun if (used >= usedhigh) and not if (used >= usedhigh + blksize), otherwise recording doesn't work when large enough blocks are used ok jakemsr@
2007-10-25sc->sc_pr.usedlow must be multiple of the block size, fixAlexandre Ratchov
audio_calcwater() to do so ok jakemsr@
2007-10-25return POLLOUT as long as (lowat + 1) isn't reached. without this audio(4)Alexandre Ratchov
is unusable with lowat = 1 ok jakemsr@
2007-10-23add a new audio_set_blksize() function that sets (and adjusts) the blockAlexandre Ratchov
size to the given number of frames per second, all changes pass through it. If parameters are changed or the user requested a new block size (or both), the block size is recalculated. ok jakemsr
2007-10-19fix audio_calc_blksize() not to return larger block sizes thanAlexandre Ratchov
the buffer size ok jakemsr
2007-10-03add two new audio ioctls, AUDIO_GETPRINFO and AUDIO_GETRRINFO, and theJacob Meuser
data structure these ioctls use, audio_bufinfo. these ioctls return information about the play and record buffers into the audio_bufinfo structure. these are being added to aid in porting non-native audio applications and libraries, and to fix issues in our OSS audio emulation. these ioctls exist only on OpenBSD and should not be used in code intended for distribution. ok ratchov
2007-09-24accept values > 1 for "output_muted". That's what SunOS do. SuggestedAlexandre Ratchov
by deanna@ ok jakemsr@
2007-09-24fix audioctl(1) returning bugus values of 'output_muted' because ofAlexandre Ratchov
uninitialized variable. found by deanna@, ok jackmsr@
2007-09-17implement the output_muted member of audio_info_t as found in originalJacob Meuser
Sun audio. input from and ok ratchov
2007-09-17use au_get_gain()/au_set_gain() and the new au_get_mute()/au_set_mute()Jacob Meuser
functions instead of doing things the hard way. also add some bits to au_set_gain() so it sets a gain that is within limits. its possible to pass in an out-of-range value through audioctl(1) as well. ok ratchov
2007-09-17add functions to mute/unmute outputJacob Meuser
ok ratchov
2007-09-10fix uninitialized linked list headAlexandre Ratchov
ok jakemsr@
2007-09-10initialize sc_outports->master and sc_inports->master. Fixes "set failed"Alexandre Ratchov
errors when running audioctl(1) on devices without master controls ok jakemsr@
2007-09-09don't try to set the recording gain or balance through /dev/audio[ctl]Jacob Meuser
if the selected recording port is not a port the limited /dev/audio[ctl] interface to mixer controls supports. ok ratchov@
2007-08-08revert the change in rev 1.60 of audio.c and the correspondingJacob Meuser
documentation change the audio layer is still too "imperfect" for this change fixes problems reported aanriot, matthieu and dtucker requested by deraadt
2007-08-02for consistency, keep the count of dropped data in HW sample size, andJacob Meuser
convert to userland sample size when needed. why this subsystem wasn't written with samples as the basic unit of measure is beyond me.
2007-08-02the MI audio layer never really knows what encoding the hardware uses;Jacob Meuser
the hardware drivers just set a conversion function. when the MI audio layer needs to add silence, it adds silence in the userland format, but the amount added is for the hardware sample size. this diff fixes both record mode by sending the right amount, and play mode by converting the silence to the right format.
2007-07-31always ignore attempts to set the record or play port to 0.Jacob Meuser
this interface to mixer functionality is very limited, and is only used for recording. it only recognizes 'mic', 'cd', and 'line' as valid recording inputs. many devices have other inputs. because of the way AUDIO_INITINFO works, it is impossible to expand this API to include all devices. this fixes another common cause of audioctl(1) problems. AUDIO_GETINFO returns 0 for record.port when the recording port is something other than 'mic', 'cd', or 'line', and the subsequent AUDIO_SETINFO would fail on this.
2007-07-18- when traversing mixer fields in the attach routine and connectingJacob Meuser
the mixer layer to the audio layer, differentiate between the 'monitor' class and the 'outputs' class instead of lumping them together. not all mixers have a monitor class entry which was causing the outputs class to be ignored. - look for monitor port in the monitor class, but if the monitor port is not found in the monitor class look in the outputs class as well. the code was effectively looking in both the monitor and outputs classes before, so this is no real change. sets up audio_info.play.[gain|balance] correctly on at least emu(4), auich(4), auvia(4) and snapper(4) ... probably most other AC'97 devices as well. as a result, audioctl(1) works much better and the overall volume can be set with /dev/audio instead of needing to go through /dev/mixer. from deanna@ thanks again to those who tested this change
2007-07-18move the processing of the pause attribute to the end of audiosetinfo(),Jacob Meuser
to allow buffer sizes and pointer to the buffer to be set to reasonable values for the sample size of the data to be read/written. fixes kernel corruption seen with azalia and probably other drivers that are using something other than 8kHz monaural mulaw as the default encoding when doing 'dd if=/dev/audio of=foo' as the first audio operation after boot. problem reported by deanna@
2007-07-17more places where the difference between the hardware sample sizeJacob Meuser
and the userland sample size matters. there may be different sample size factors for play and record, so use the appropriate factor when userland sets the blocksize. the reported blocksize, hiwat and lowat are only for the play buffer. IMO, it would be good to report the record blocksize, hiwat and lowat as well, but that is another issue. tested with emu(4) and an auvia(4) modified to only do stereo in hardware.
2007-07-17- the data in the read buffer, that was put there by the hardware,Jacob Meuser
may not be the same sample size as what userland is to receive. account for the discrepency between the sample sizes when comparing how much to copy out with what userland expects. - only copy out the part of the buffer that is in the format userland expects. emu(4) can now record with all encodings it claims to be able to. that is, dd if=/dev/audio of=foo does as audio(4) says (monaural mu-law) and does it correctly. AFAIKS, the only other driver that sets a read factor is uaudio(4), and that depends on what the hardware supports. tested on i386, amd64 and sgi with 3 different emu(4) cards
2007-07-14- ANSI function declarationsJacob Meuser
- remove argument names from function prototypes OK jasper@, ray@, "Didn't notice any errors" marc@
2007-07-10fix the bug rev 1.56 uncovered and rev 1.62 worked around.Jacob Meuser
data is expanded before it goes in the buffer. all sizes and offsets used internally are of this expanded data. there's no need to compensate for this fact except when showing information to the user in case their actions depend on how many bytes are in the buffer.
2007-07-09take into account possible expansion and be more careful not toJacob Meuser
try to go past the end of the buffer. this and the last commit allow ffplay and gnash to work properly on devices that may need to do mono to stereo conversion, like auich(4). problem reported by and much debugging deanna@
2007-07-09give the user what they expect instead of what we're working withJacob Meuser
by taking into account expansion we may have done in cases such as playing monoaural media on a device that only plays stereo, like auich(4).
2007-07-06- enable full-duplex mode by default if a device is openedJacob Meuser
read-write and it supports full-duplex operation. - update documentation to match this behaviour. see http://marc.info/?l=openbsd-tech&m=118310788926431&w=2 for more background on this change "patches look correct to me" marc@
2007-07-06the AUDIO_WSEEK ioctl should return the number of bytes in the playJacob Meuser
buffer, not the record buffer. inspired by recent similar change in NetBSD. "patches look correct to me" marc@
2007-07-06be sure to respect the pause attributeJacob Meuser
originally from Alexandre Ratchov "patches look correct to me" marco@
2007-07-06- there is no need for audio_init_ringbuffer() to always set the "pause"Jacob Meuser
attribute to '0'. this function may be called when executing an AUDIO_SETINFO ioctl where the pause attribute was set to '1', and setting it to '0' in this function will cause unexpected bahaviour. - according to audio(4), the AUDIO_FLUSH ioctl "restarts recording and playback". therefor, it should set the pause attributes to '0'. this was previously accomplished indirectly, because it calls audio_init_ringbuffer(), which was setting pause to '0'. - the pause attribute must be set to '0' in audio_open() so that recording and playback buffers can be "activated" when the device is opened. this was apparently forgotten when audiosetinfo() was split off of audio_open() and the logic in audiosetinfo() was changed to accomodate being run at times other than open(). also, this only really affects read() with poll(), which may explain why the problem was not noticed for some time. originally part of a patch Alexandre Ratchov sent to tech@ a while back fixes PR 3813 "patches look correct to me" marco@
2007-07-06The poll(2) syscall doesn't work correctly on audio(4) devices.Jacob Meuser
For instance, it may not set POLLIN when samples become available, or may set POLLOUT when write(2) will block. Fix this by making conditions used by poll (FILTREAD and FILTWRITE macros) match the blocking conditions in audio_read() and audio_write(). originally from Alexandre Ratchov, with a small tweak by me. "patches look correct to me" marco@
2007-05-31switch wskbd hotkeys over to workq. this eliminates quite a bit of code,Ted Unangst
so remove the option too. if you have audio and wskbd, you have hotkeys. ok dlg