xref: /openbsd-src/lib/libsndio/sio_open.3 (revision 3678e56310dae9964579f0b551e6d3010cc8e371)
1.\" $OpenBSD: sio_open.3,v 1.56 2022/05/30 10:31:59 op Exp $
2.\"
3.\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: May 30 2022 $
18.Dt SIO_OPEN 3
19.Os
20.Sh NAME
21.Nm sio_open ,
22.Nm sio_close ,
23.Nm sio_setpar ,
24.Nm sio_getpar ,
25.Nm sio_getcap ,
26.Nm sio_start ,
27.Nm sio_stop ,
28.Nm sio_flush ,
29.Nm sio_read ,
30.Nm sio_write ,
31.Nm sio_onmove ,
32.Nm sio_nfds ,
33.Nm sio_pollfd ,
34.Nm sio_revents ,
35.Nm sio_eof ,
36.Nm sio_setvol ,
37.Nm sio_onvol ,
38.Nm sio_initpar ,
39.Nm SIO_BPS
40.Nd sndio interface to audio devices
41.Sh SYNOPSIS
42.In sndio.h
43.Ft "struct sio_hdl *"
44.Fn sio_open "const char *name" "unsigned int mode" "int nbio_flag"
45.Ft "void"
46.Fn sio_close "struct sio_hdl *hdl"
47.Ft "int"
48.Fn sio_setpar "struct sio_hdl *hdl" "struct sio_par *par"
49.Ft "int"
50.Fn sio_getpar "struct sio_hdl *hdl" "struct sio_par *par"
51.Ft "int"
52.Fn sio_getcap "struct sio_hdl *hdl" "struct sio_cap *cap"
53.Ft "int"
54.Fn sio_start "struct sio_hdl *hdl"
55.Ft "int"
56.Fn sio_stop "struct sio_hdl *hdl"
57.Ft "int"
58.Fn sio_flush "struct sio_hdl *hdl"
59.Ft "size_t"
60.Fn sio_read "struct sio_hdl *hdl" "void *addr" "size_t nbytes"
61.Ft "size_t"
62.Fn sio_write "struct sio_hdl *hdl" "const void *addr" "size_t nbytes"
63.Ft "void"
64.Fo sio_onmove
65.Fa "struct sio_hdl *hdl"
66.Fa "void (*cb)(void *arg, int delta)"
67.Fa "void *arg"
68.Fc
69.Ft "int"
70.Fn sio_nfds "struct sio_hdl *hdl"
71.Ft "int"
72.Fn sio_pollfd "struct sio_hdl *hdl" "struct pollfd *pfd" "int events"
73.Ft "int"
74.Fn sio_revents "struct sio_hdl *hdl" "struct pollfd *pfd"
75.Ft "int"
76.Fn sio_eof "struct sio_hdl *hdl"
77.Ft "int"
78.Fn sio_setvol "struct sio_hdl *hdl" "unsigned int vol"
79.Ft "int"
80.Fo sio_onvol
81.Fa "struct sio_hdl *hdl"
82.Fa "void (*cb)(void *arg, unsigned int vol)"
83.Fa "void *arg"
84.Fc
85.Ft "void"
86.Fn sio_initpar "struct sio_par *par"
87.Ft unsigned int
88.Fn SIO_BPS "unsigned int bits"
89.Sh DESCRIPTION
90The
91.Nm sndio
92library allows user processes to access
93.Xr audio 4
94hardware and the
95.Xr sndiod 8
96audio server in a uniform way.
97.Ss Opening and closing an audio device
98First the application must call the
99.Fn sio_open
100function to obtain a handle to the device;
101later it will be passed as the
102.Fa hdl
103argument of most other functions.
104The
105.Fa name
106parameter gives the device string discussed in
107.Xr sndio 7 .
108In most cases it should be set to
109.Dv SIO_DEVANY
110to allow the user to select it using the
111.Ev AUDIODEVICE
112environment variable.
113.Pp
114The following values of the
115.Fa mode
116parameter are supported:
117.Bl -tag -width "SIO_PLAY | SIO_REC"
118.It Dv SIO_PLAY
119Play-only mode: data written will be played by the device.
120.It Dv SIO_REC
121Record-only mode: samples are recorded by the device and must be read.
122.It Dv SIO_PLAY | SIO_REC
123The device plays and records synchronously; this means that
124the n-th recorded sample was physically sampled exactly when
125the n-th played sample was actually played.
126.El
127.Pp
128If the
129.Fa nbio_flag
130argument is true (i.e. non-zero), then the
131.Fn sio_read
132and
133.Fn sio_write
134functions (see below) will be non-blocking.
135.Pp
136The
137.Fn sio_close
138function stops the device as if
139.Fn sio_stop
140is called and frees the handle.
141Thus, no samples submitted with
142.Fn sio_write
143are discarded.
144.Ss Negotiating audio parameters
145Audio samples are interleaved.
146A frame consists of one sample for each channel.
147For example, a 16-bit stereo encoding has two samples per frame
148and, two bytes per sample (thus 4 bytes per frame).
149.Pp
150The set of parameters of the device that can be controlled
151is given by the following structure:
152.Bd -literal
153struct sio_par {
154	unsigned int bits;	/* bits per sample */
155	unsigned int bps;	/* bytes per sample */
156	unsigned int sig;	/* 1 = signed, 0 = unsigned int */
157	unsigned int le;	/* 1 = LE, 0 = BE byte order */
158	unsigned int msb;	/* 1 = MSB, 0 = LSB aligned */
159	unsigned int rchan;	/* number channels for recording */
160	unsigned int pchan;	/* number channels for playback */
161	unsigned int rate;	/* frames per second */
162	unsigned int appbufsz;	/* minimum buffer size without xruns */
163	unsigned int bufsz;	/* end-to-end buffer size (read-only) */
164	unsigned int round;	/* optimal buffer size divisor */
165#define SIO_IGNORE	0	/* pause during xrun */
166#define SIO_SYNC	1	/* resync after xrun */
167#define SIO_ERROR	2	/* terminate on xrun */
168	unsigned int xrun;	/* what to do on overrun/underrun */
169};
170.Ed
171.Pp
172The parameters are as follows:
173.Bl -tag -width "appbufsz"
174.It Fa bits
175Number of bits per sample: must be between 1 and 32.
176.It Fa bps
177Bytes per samples; if specified, it must be large enough to hold all bits.
178By default it's set to the smallest power of two large enough to hold
179.Fa bits .
180.It Fa sig
181If set (i.e. non-zero) then the samples are signed, else unsigned.
182.It Fa le
183If set, then the byte order is little endian, else big endian;
184it's meaningful only if
185.Fa bps No > 1 .
186.It Fa msb
187If set, then the
188.Fa bits
189are aligned in the packet to the most significant bit
190(i.e. lower bits are padded),
191else to the least significant bit
192(i.e. higher bits are padded);
193it's meaningful only if
194.Fa bits No < Fa bps No * 8 .
195.It Fa rchan
196The number of recorded channels; meaningful only if
197.Dv SIO_REC
198mode was selected.
199.It Fa pchan
200The number of played channels; meaningful only if
201.Dv SIO_PLAY
202mode was selected.
203.It Fa rate
204The sampling frequency in Hz.
205.It Fa appbufsz
206Size of the buffer in frames the application must maintain non-empty
207(on the play end) or non-full (on the record end) by calling
208.Fn sio_write
209or
210.Fn sio_read
211fast enough to avoid overrun or underrun conditions.
212The audio subsystem may use additional buffering, thus this
213parameter cannot be used for latency calculations.
214.It Fa bufsz
215The maximum number of frames that may be buffered.
216This parameter takes into account any buffers, and
217can be used for latency calculations.
218It is read-only.
219.It Fa round
220Optimal number of frames that the application buffers
221should be a multiple of, to get best performance.
222Applications can use this parameter to round their block size.
223.It Fa xrun
224The action when the client doesn't accept
225recorded data or doesn't provide data to play fast enough;
226it can be set to one of the
227.Dv SIO_IGNORE ,
228.Dv SIO_SYNC ,
229or
230.Dv SIO_ERROR
231constants.
232.El
233.Pp
234The following approach is recommended to negotiate device parameters:
235.Bl -bullet
236.It
237Initialize a
238.Vt sio_par
239structure using
240.Fn sio_initpar
241and fill it with
242the desired parameters.
243Then call
244.Fn sio_setpar
245to request the device to use them.
246Parameters left unset in the
247.Vt sio_par
248structure will be set to device-specific defaults.
249.It
250Call
251.Fn sio_getpar
252to retrieve the actual parameters of the device
253and check that they are usable.
254If they are not, then fail or set up a conversion layer.
255Sometimes the rate set can be slightly different to what was requested.
256A difference of about 0.5% is not audible and should be ignored.
257.El
258.Pp
259Parameters cannot be changed after
260.Fn sio_start
261has been called,
262.Fn sio_stop
263or
264.Fn sio_flush
265must be called before parameters can be changed.
266.Pp
267If the device is exposed by the
268.Xr sndiod 8
269server, which is the default configuration,
270a transparent emulation layer will
271automatically be set up, and in this case any combination of
272rate, encoding and numbers of channels is supported.
273.Pp
274To ease filling the
275.Vt sio_par
276structure, the
277following macros can be used:
278.Bl -tag -width "SIO_BPS(bits)"
279.It Fn SIO_BPS bits
280Return the smallest value for
281.Fa bps
282that is a power of two and that is large enough to
283hold
284.Fa bits .
285.It Dv SIO_LE_NATIVE
286Can be used to set the
287.Fa le
288parameter when native byte order is required.
289It is 1 if the native byte order is little endian or 0 otherwise.
290.El
291.Ss Getting device capabilities
292There's no way to get an exhaustive list of all parameter
293combinations the device supports.
294Applications that need to have a set of working
295parameter combinations in advance can use the
296.Fn sio_getcap
297function.
298However, for most new applications it's generally
299not recommended to use
300.Fn sio_getcap .
301Instead, follow the recommendations for negotiating
302device parameters (see above).
303.Pp
304The
305.Vt sio_cap
306structure contains the list of parameter configurations.
307Each configuration contains multiple parameter sets.
308The application must examine all configurations, and
309choose its parameter set from
310.Em one
311of the configurations.
312Parameters of different configurations
313.Em are not
314usable together.
315.Bd -literal
316struct sio_cap {
317	struct sio_enc {		/* allowed encodings */
318		unsigned int bits;
319		unsigned int bps;
320		unsigned int sig;
321		unsigned int le;
322		unsigned int msb;
323	} enc[SIO_NENC];
324	unsigned int rchan[SIO_NCHAN];	/* allowed rchans */
325	unsigned int pchan[SIO_NCHAN];	/* allowed pchans */
326	unsigned int rate[SIO_NRATE];	/* allowed rates */
327	unsigned int nconf;		/* num. of confs[] */
328	struct sio_conf {
329		unsigned int enc;	/* bitmask of enc[] indexes */
330		unsigned int rchan;	/* bitmask of rchan[] indexes */
331		unsigned int pchan;	/* bitmask of pchan[] indexes */
332		unsigned int rate;	/* bitmask of rate[] indexes */
333	} confs[SIO_NCONF];
334};
335.Ed
336.Pp
337The parameters are as follows:
338.Bl -tag -width "rchan[SIO_NCHAN]"
339.It Fa enc Ns Bq Dv SIO_NENC
340Array of supported encodings.
341The tuple of
342.Fa bits ,
343.Fa bps ,
344.Fa sig ,
345.Fa le ,
346and
347.Fa msb
348parameters are usable in the corresponding parameters
349of the
350.Vt sio_par
351structure.
352.It Fa rchan Ns Bq Dv SIO_NCHAN
353Array of supported channel numbers for recording usable
354in the
355.Vt sio_par
356structure.
357.It Fa pchan Ns Bq Dv SIO_NCHAN
358Array of supported channel numbers for playback usable
359in the
360.Vt sio_par
361structure.
362.It Fa rate Ns Bq Dv SIO_NRATE
363Array of supported sample rates usable
364in the
365.Vt sio_par
366structure.
367.It Fa nconf
368Number of different configurations available, i.e. number
369of filled elements of the
370.Fa confs Ns Bq
371array.
372.It Fa confs Ns Bq Dv SIO_NCONF
373Array of available configurations.
374Each configuration contains bitmasks indicating which
375elements of the above parameter arrays are valid for the
376given configuration.
377For instance, if the second bit of
378.Fa rate
379is set, in the
380.Vt sio_conf
381structure, then the second element of the
382.Fa rate Ns Bq Dv SIO_NRATE
383array of the
384.Vt sio_cap
385structure is valid for this configuration.
386As such, when reading the array elements in the
387.Vt sio_cap
388structure, the corresponding
389.Vt sio_conf
390bitmasks should always be used.
391.El
392.Ss Starting and stopping the device
393The
394.Fn sio_start
395function prepares the device to start.
396Once the play buffer is full, i.e.\&
397.Fa sio_par.bufsz
398samples are queued with
399.Fn sio_write ,
400playback starts automatically.
401If record-only mode is selected, then
402.Fn sio_start
403starts recording immediately.
404In full-duplex mode, playback and recording will start
405synchronously as soon as the play buffer is full.
406.Pp
407The
408.Fn sio_stop
409function puts the audio subsystem
410in the same state as before
411.Fn sio_start
412was called.
413It stops recording, drains the play buffer and then stops playback.
414If samples to play are queued but playback hasn't started yet
415then playback is forced immediately; playback will actually stop
416once the buffer is drained.
417In no case are samples in the play buffer discarded.
418.Pp
419The
420.Fn sio_flush
421function stops playback and recording immediately,
422possibly discarding play buffer contents, and puts the audio subsystem
423in the same state as before
424.Fn sio_start
425was called.
426.Ss Playing and recording
427When record mode is selected, the
428.Fn sio_read
429function must be called to retrieve recorded data; it must be called
430often enough to ensure that internal buffers will not overrun.
431It will store at most
432.Fa nbytes
433bytes at the
434.Fa addr
435location and return the number of bytes stored.
436Unless the
437.Fa nbio_flag
438flag is set, it will block until data becomes available and
439will return zero only on error.
440.Pp
441Similarly, when play mode is selected, the
442.Fn sio_write
443function must be called to provide data to play.
444Unless the
445.Fa nbio_flag
446is set,
447.Fn sio_write
448will block until the requested amount of data is written.
449.Ss Non-blocking mode operation
450If the
451.Fa nbio_flag
452is set on
453.Fn sio_open ,
454then the
455.Fn sio_read
456and
457.Fn sio_write
458functions will never block; if no data is available, they will
459return zero immediately.
460.Pp
461The
462.Xr poll 2
463system call can be used to check if data can be
464read from or written to the device.
465The
466.Fn sio_pollfd
467function fills the array
468.Fa pfd
469of
470.Vt pollfd
471structures, used by
472.Xr poll 2 ,
473with
474.Fa events ;
475the latter is a bit-mask of
476.Dv POLLIN
477and
478.Dv POLLOUT
479constants; refer to
480.Xr poll 2
481for more details.
482The
483.Fn sio_revents
484function returns the bit-mask set by
485.Xr poll 2
486in the
487.Fa pfd
488array of
489.Vt pollfd
490structures.
491If
492.Dv POLLIN
493is set, recorded samples are available in the device buffer
494and can be read with
495.Fn sio_read .
496If
497.Dv POLLOUT
498is set, space is available in the device buffer and new samples
499to play can be submitted with
500.Fn sio_write .
501.Dv POLLHUP
502may be set if an error occurs, even if
503it is not selected with
504.Fn sio_pollfd .
505.Pp
506The size of the
507.Fa pfd
508array, which the caller must pre-allocate, is provided by the
509.Fn sio_nfds
510function.
511.Ss Synchronizing non-audio events to the audio stream in real-time
512In order to perform actions at precise positions of the audio stream,
513such as displaying video in sync with the audio stream,
514the application must be notified in real-time of the exact
515position in the stream the hardware is processing.
516.Pp
517The
518.Fn sio_onmove
519function can be used to register the
520.Fn cb
521callback function called at regular time intervals.
522The
523.Fa delta
524argument contains the number of frames the hardware played and/or recorded
525since the last call of
526.Fn cb .
527It is called by
528.Fn sio_read ,
529.Fn sio_write ,
530and
531.Fn sio_revents .
532When the first sample is played and/or recorded, right after the device starts,
533the callback is invoked with a zero
534.Fa delta
535argument.
536The value of the
537.Fa arg
538pointer is passed to the callback and can contain anything.
539.Pp
540If desired, the application can maintain the current position by
541starting from zero (when
542.Fn sio_start
543is called) and adding to the current position
544.Fa delta
545every time
546.Fn cb
547is called.
548.Ss Measuring the latency and buffers usage
549The playback latency is the delay it will take for the
550frame just written to become audible, expressed in number of frames.
551The exact playback
552latency can be obtained by subtracting the current position
553from the number of frames written.
554Once playback is actually started (first sample audible),
555the latency will never exceed the
556.Fa bufsz
557parameter (see the sections above).
558There's a phase during which
559.Fn sio_write
560only queues data;
561once there's enough data, actual playback starts.
562During this phase talking about latency is meaningless.
563.Pp
564In any cases, at most
565.Fa bufsz
566frames are buffered.
567This value takes into account all buffers.
568The number of frames stored is equal to the number of frames
569written minus the current position.
570.Pp
571The recording latency is obtained similarly, by subtracting
572the number of frames read from the current position.
573.Pp
574Note that
575.Fn sio_write
576might block even if there is buffer space left;
577using the buffer usage to guess if
578.Fn sio_write
579would block is false and leads to unreliable programs \(en consider using
580.Xr poll 2
581for this.
582.Ss Handling buffer overruns and underruns
583When the application cannot accept recorded data fast enough,
584the record buffer (of size
585.Fa appbufsz )
586might overrun; in this case recorded data is lost.
587Similarly if the application cannot provide data to play
588fast enough, the play buffer underruns and silence is played
589instead.
590Depending on the
591.Fa xrun
592parameter of the
593.Vt sio_par
594structure, the audio subsystem will behave as follows:
595.Bl -tag -width "SIO_IGNORE"
596.It Dv SIO_IGNORE
597The device pauses during overruns and underruns,
598thus the current position (obtained through
599.Fn sio_onmove )
600stops being incremented.
601Once the overrun and/or underrun condition is gone, the device resumes;
602play and record are always kept in sync.
603With this mode, the application cannot notice
604underruns and/or overruns and shouldn't care about them.
605.Pp
606This mode is the default.
607It's suitable for applications,
608like audio players and telephony, where time
609is not important and overruns or underruns are not short.
610.It Dv SIO_SYNC
611If the play buffer underruns, then silence is played,
612but in order to reach the right position in time,
613the same amount of written samples will be
614discarded once the application is unblocked.
615Similarly, if the record buffer overruns, then
616samples are discarded, but the same amount of silence will be
617returned later.
618The current position (obtained through
619.Fn sio_onmove )
620is still incremented.
621When the play buffer underruns the play latency might become negative;
622when the record buffer overruns, the record latency might become
623larger than
624.Fa bufsz .
625.Pp
626This mode is suitable for applications, like music production,
627where time is important and where underruns or overruns are
628short and rare.
629.It Dv SIO_ERROR
630With this mode, on the first play buffer underrun or
631record buffer overrun, playback and/or recording is terminated and
632no other function than
633.Fn sio_close
634will succeed.
635.Pp
636This mode is mostly useful for testing.
637.El
638.Ss Controlling the volume
639The
640.Fn sio_setvol
641function can be used to set playback attenuation.
642The
643.Fa vol
644parameter takes a value between 0 (maximum attenuation)
645and
646.Dv SIO_MAXVOL
647(no attenuation).
648It specifies the weight the audio subsystem will
649give to this stream.
650It is not meant to control hardware parameters like
651speaker gain; the
652.Xr mixerctl 8
653interface should be used for that purpose instead.
654.Pp
655An application can use the
656.Fn sio_onvol
657function to register a callback function that
658will be called each time the volume is changed,
659including when
660.Fn sio_setvol
661is used.
662The callback is always invoked when
663.Fn sio_onvol
664is called in order to provide the initial volume.
665An application can safely assume that once
666.Fn sio_onvol
667has returned a non-zero value,
668the callback has been invoked and thus
669the current volume is available.
670If there's no volume setting available,
671.Fn sio_onvol
672returns 0 and the callback is never invoked and calls to
673.Fn sio_setvol
674are ignored.
675.Pp
676The
677.Fn sio_onvol
678function can be called with a
679.Dv NULL
680argument to check whether a volume knob is available.
681.Ss Error handling
682Errors related to the audio subsystem
683(like hardware errors, dropped connections) and
684programming errors (e.g. call to
685.Fn sio_read
686on a play-only stream) are considered fatal.
687Once an error occurs, all functions taking a
688.Fa sio_hdl
689argument, except
690.Fn sio_close
691and
692.Fn sio_eof ,
693stop working (i.e. always return 0).
694The
695.Fn sio_eof
696function can be used at any stage.
697.Ss Use with Xr pledge 2
698If the
699.Nm sndio
700library is used in combination with
701.Xr pledge 2 ,
702then the
703.Fn sio_open
704function needs the
705.Cm stdio ,
706.Cm rpath ,
707.Cm wpath ,
708.Cm cpath ,
709.Cm inet ,
710.Cm unix ,
711.Cm dns ,
712and
713.Cm audio
714.Xr pledge 2
715promises.
716.Bl -bullet
717.It
718.Cm rpath ,
719.Cm wpath ,
720and
721.Cm cpath
722are needed to read, write or create the authentication cookie
723.Pa ~/.sndio/cookie .
724.It
725.Cm rpath ,
726.Cm wpath ,
727and
728.Cm audio
729are needed when the device is a local raw device.
730.It
731.Cm unix
732is needed when the device is a local
733.Xr sndiod 8
734sub-device.
735.It
736.Cm inet
737and
738.Cm dns
739are needed when the device is a remote
740.Xr sndiod 8
741sub-device.
742.El
743.Pp
744Once no further calls to
745.Fn sio_open
746will be made, all these
747.Xr pledge 2
748promises may be dropped, except for the
749.Cm audio
750promise.
751.Sh RETURN VALUES
752The
753.Fn sio_open
754function returns the newly created handle on success or
755.Dv NULL
756on failure.
757.Pp
758The
759.Fn sio_setpar ,
760.Fn sio_getpar ,
761.Fn sio_getcap ,
762.Fn sio_start ,
763.Fn sio_stop ,
764.Fn sio_flush ,
765and
766.Fn sio_setvol
767functions return 1 on success and 0 on failure.
768.Pp
769The
770.Fn sio_pollfd
771function returns the number of
772.Vt pollfd
773structures filled.
774The
775.Fn sio_nfds
776function returns the number of
777.Vt pollfd
778structures the caller must preallocate in order to be sure
779that
780.Fn sio_pollfd
781will never overrun.
782.Pp
783The
784.Fn sio_read
785and
786.Fn sio_write
787functions return the number of bytes transferred.
788.Pp
789The
790.Fn sio_eof
791function returns 0 if there's no pending error, and a non-zero
792value if there's an error.
793.Sh ENVIRONMENT
794.Bl -tag -width "SNDIO_DEBUGXXX" -compact
795.It Ev AUDIODEVICE
796Device to use if
797.Fn sio_open
798is called with
799.Dv SIO_DEVANY
800as the
801.Fa name
802argument.
803.It Ev SNDIO_DEBUG
804The debug level:
805may be a value between 0 and 2.
806.El
807.Sh SEE ALSO
808.Xr pledge 2 ,
809.Xr mio_open 3 ,
810.Xr sioctl_open 3 ,
811.Xr audio 4 ,
812.Xr sndio 7 ,
813.Xr sndiod 8 ,
814.Xr audio 9
815.Sh HISTORY
816These functions first appeared in
817.Ox 4.5 .
818.Sh AUTHORS
819.An Alexandre Ratchov Aq Mt ratchov@openbsd.org
820.Sh BUGS
821The
822.Xr audio 4
823driver doesn't drain playback buffers, thus if sndio
824is used to directly access an
825.Xr audio 4
826device,
827the
828.Fn sio_stop
829function will stop playback immediately.
830.Pp
831If the application doesn't consume recorded data fast enough then
832.Dq "control messages"
833from the
834.Xr sndiod 8
835server are delayed and consequently
836.Fn sio_onmove
837callback or volume changes may be delayed.
838.Pp
839The
840.Fn sio_open ,
841.Fn sio_setpar ,
842.Fn sio_getpar ,
843.Fn sio_getcap ,
844.Fn sio_start ,
845.Fn sio_stop ,
846and
847.Fn sio_flush
848functions may block for a very short period of time, thus they should
849be avoided in code sections where blocking is not desirable.
850