5 * \author Jaroslav Kysela <perex@suse.cz>
6 * \author Abramo Bagnara <abramo@alsa-project.org>
9 * PCM Interface is designed to write or read digital audio frames. A
10 * frame is the data unit converted into/from sound in one time unit
11 * (1/rate seconds), by example if you set your playback PCM rate to
12 * 44100 you'll hear 44100 frames per second. The size in bytes of a
13 * frame may be obtained from bits needed to store a sample and
16 * See the \ref pcm page for more details.
19 * PCM Interface - main file
20 * Copyright (c) 1998 by Jaroslav Kysela <perex@suse.cz>
21 * Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
23 * This library is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU Lesser General Public License as
25 * published by the Free Software Foundation; either version 2.1 of
26 * the License, or (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Lesser General Public License for more details.
33 * You should have received a copy of the GNU Lesser General Public
34 * License along with this library; if not, write to the Free Software
35 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 /*! \page pcm PCM (digital audio) interface
41 <P>Although abbreviation PCM stands for Pulse Code Modulation, we are
42 understanding it as general digital audio processing with volume samples
43 generated in continuous time periods.</P>
45 <P>The analog signal is recorded via analog to digital converters (ADC).
46 The digital value (de-facto a volume at a specific time) obtained
47 from ADC can be further processed. The following picture shows a perfect
53 <P>Next image shows digitized representation:</P>
58 <P>As you may see, the quality of digital audio signal depends on the time
59 (recording rate) and voltage resolution (usually in an linear integer
60 representation with basic unit one bit).</P>
62 <P>The stored digital signal can be converted back to voltage (analog)
63 representation via digital to analog converters (DAC).</P>
65 <P>One digital value is called sample. More samples are collected to frames
66 (frame is terminology for ALSA) depending on count of converters used at one
67 specific time. One frame might contain one sample (when only one converter is
68 used - mono) or more samples (for example: stereo has signals from two converters
69 recorded at same time). Digital audio stream contains collection of frames
70 recorded at boundaries of continuous time periods.</P>
72 \section pcm_general_overview General overview
74 ALSA uses the ring buffer to store outgoing (playback) and incoming (capture,
75 record) samples. There are two pointers being maintained to allow
76 a precise communication between application and device pointing to current
77 processed sample by hardware and last processed sample by application.
78 The modern audio chips allow to program the transfer time periods.
79 It means that the stream of samples is divided to small chunks. Device
80 acknowledges to application when the transfer of a chunk is complete.
82 \section pcm_transfer Transfer methods in UNIX environments
84 In the UNIX environment, data chunk acknowledges are received via standard I/O
85 calls or event waiting routines (poll or select function). To accomplish
86 this list, the asynchronous notification of acknowledges should be listed
87 here. The ALSA implementation for these methods is described in
88 the \ref alsa_transfers section.
90 \subsection pcm_transfer_io Standard I/O transfers
92 The standard I/O transfers are using the read (see 'man 2 read') and write
93 (see 'man 2 write') C functions. There are two basic behaviours of these
94 functions - blocked and non-blocked (see the O_NONBLOCK flag for the
95 standard C open function - see 'man 2 open'). In non-blocked behaviour,
96 these I/O functions never stops, they return -EAGAIN error code, when no
97 data can be transferred (the ring buffer is full in our case). In blocked
98 behaviour, these I/O functions stop and wait until there is a room in the
99 ring buffer (playback) or until there are a new samples (capture). The ALSA
100 implementation can be found in the \ref alsa_pcm_rw section.
102 \subsection pcm_transfer_event Event waiting routines
104 The poll or select functions (see 'man 2 poll' or 'man 2 select' for further
105 details) allows to receive requests/events from the device while
106 an application is waiting on events from other sources (like keyboard, screen,
107 network etc.), too. The select function is old and deprecated in modern
108 applications, so the ALSA library does not support it. The implemented
109 transfer routines can be found in the \ref alsa_transfers section.
111 \subsection pcm_transfer_async Asynchronous notification
113 ALSA driver and library knows to handle the asynchronous notifications over
114 the SIGIO signal. This signal allows to interrupt application and transfer
115 data in the signal handler. For further details see the sigaction function
116 ('man 2 sigaction'). The section \ref pcm_async describes the ALSA API for
117 this extension. The implemented transfer routines can be found in the
118 \ref alsa_transfers section.
120 \section pcm_open_behaviour Blocked and non-blocked open
122 The ALSA PCM API uses a different behaviour when the device is opened
123 with blocked or non-blocked mode. The mode can be specified with
124 \a mode argument in \link ::snd_pcm_open() \endlink function.
125 The blocked mode is the default (without \link ::SND_PCM_NONBLOCK \endlink mode).
126 In this mode, the behaviour is that if the resources have already used
127 with another application, then it blocks the caller, until resources are
128 free. The non-blocked behaviour (with \link ::SND_PCM_NONBLOCK \endlink)
129 doesn't block the caller in any way and returns -EBUSY error when the
130 resources are not available. Note that the mode also determines the
131 behaviour of standard I/O calls, returning -EAGAIN when non-blocked mode is
132 used and the ring buffer is full (playback) or empty (capture).
133 The operation mode for I/O calls can be changed later with
134 the \link snd_pcm_nonblock() \endlink function.
136 \section pcm_async Asynchronous mode
138 There is also possibility to receive asynchronous notification after
139 specified time periods. You may see the \link ::SND_PCM_ASYNC \endlink
140 mode for \link ::snd_pcm_open() \endlink function and
141 \link ::snd_async_add_pcm_handler() \endlink function for further details.
143 \section pcm_handshake Handshake between application and library
145 The ALSA PCM API design uses the states to determine the communication
146 phase between application and library. The actual state can be determined
147 using \link ::snd_pcm_state() \endlink call. There are these states:
149 \par SND_PCM_STATE_OPEN
150 The PCM device is in the open state. After the \link ::snd_pcm_open() \endlink open call,
151 the device is in this state. Also, when \link ::snd_pcm_hw_params() \endlink call fails,
152 then this state is entered to force application calling
153 \link ::snd_pcm_hw_params() \endlink function to set right communication
156 \par SND_PCM_STATE_SETUP
157 The PCM device has accepted communication parameters and it is waiting
158 for \link ::snd_pcm_prepare() \endlink call to prepare the hardware for
159 selected operation (playback or capture).
161 \par SND_PCM_STATE_PREPARE
162 The PCM device is prepared for operation. Application can use
163 \link ::snd_pcm_start() \endlink call, write or read data to start
166 \par SND_PCM_STATE_RUNNING
167 The PCM device is running. It processes the samples. The stream can
168 be stopped using the \link ::snd_pcm_drop() \endlink or
169 \link ::snd_pcm_drain \endlink calls.
171 \par SND_PCM_STATE_XRUN
172 The PCM device reached overrun (capture) or underrun (playback).
173 You can use the -EPIPE return code from I/O functions
174 (\link ::snd_pcm_writei() \endlink, \link ::snd_pcm_writen() \endlink,
175 \link ::snd_pcm_readi() \endlink, \link ::snd_pcm_readi() \endlink)
176 to determine this state without checking
177 the actual state via \link ::snd_pcm_state() \endlink call. You can recover from
178 this state with \link ::snd_pcm_prepare() \endlink,
179 \link ::snd_pcm_drop() \endlink or \link ::snd_pcm_drain() \endlink calls.
181 \par SND_PCM_STATE_DRAINING
182 The device is in this state when application using the capture mode
183 called \link ::snd_pcm_drain() \endlink function. Until all data are
184 read from the internal ring buffer using I/O routines
185 (\link ::snd_pcm_readi() \endlink, \link ::snd_pcm_readn() \endlink),
186 then the device stays in this state.
188 \par SND_PCM_STATE_PAUSED
189 The device is in this state when application called
190 the \link ::snd_pcm_pause() \endlink function until the pause is released.
191 Not all hardware supports this feature. Application should check the
192 capability with the \link ::snd_pcm_hw_params_can_pause() \endlink.
194 \par SND_PCM_STATE_SUSPENDED
195 The device is in the suspend state provoked with the power management
196 system. The stream can be resumed using \link ::snd_pcm_resume() \endlink
197 call, but not all hardware supports this feature. Application should check
198 the capability with the \link ::snd_pcm_hw_params_can_resume() \endlink.
199 In other case, the calls \link ::snd_pcm_prepare() \endlink,
200 \link ::snd_pcm_drop() \endlink, \link ::snd_pcm_drain() \endlink can be used
203 \section pcm_formats PCM formats
205 The full list of formats present the \link ::snd_pcm_format_t \endlink type.
206 The 24-bit linear samples uses 32-bit physical space, but the sample is
207 stored in low three bits. Some hardware does not support processing of full
208 range, thus you may get the significant bits for linear samples via
209 \link ::snd_pcm_hw_params_get_sbits \endlink function. The example: ICE1712
210 chips support 32-bit sample processing, but low byte is ignored (playback)
211 or zero (capture). The function \link ::snd_pcm_hw_params_get_sbits() \endlink
212 returns 24 in the case.
214 \section alsa_transfers ALSA transfers
216 There are two methods to transfer samples in application. The first method
217 is the standard read / write one. The second method, uses the direct audio
218 buffer to communicate with the device while ALSA library manages this space
219 itself. You can find examples of all communication schemes for playback
220 in \ref example_test_pcm "Sine-wave generator example". To complete the
221 list, we should note that \link ::snd_pcm_wait \endlink function contains
222 embedded poll waiting implementation.
224 \subsection alsa_pcm_rw Read / Write transfer
226 There are two versions of read / write routines. The first expects the
227 interleaved samples at input (#SND_PCM_ACCESS_RW_INTERLEAVED access method),
228 and the second one expects non-interleaved (samples in separated buffers -
229 #SND_PCM_ACCESS_RW_NONINTERLEAVED access method) at input. There are these
230 functions for interleaved transfers: \link ::snd_pcm_writei \endlink,
231 \link ::snd_pcm_readi \endlink. For non-interleaved transfers, there are
232 these functions: \link ::snd_pcm_writen \endlink and \link ::snd_pcm_readn
235 \subsection alsa_mmap_rw Direct Read / Write transfer (via mmap'ed areas)
237 Three kinds of organization of ring buffer memory areas exist in ALSA API.
238 Access #SND_PCM_ACCESS_MMAP_INTERLEAVED has interleaved samples. Access
239 #SND_PCM_ACCESS_MMAP_NONINTERLEAVED expects continous sample areas for
240 one channel. Access #SND_PCM_ACCESS_MMAP_COMPLEX does not fit to interleaved
241 and non-interleaved ring buffer organization.
244 There are two functions for this kind of transfer. Application can get an
245 access to memory areas via \link ::snd_pcm_mmap_begin \endlink function.
246 This function returns the areas (single area is equal to a channel)
247 containing the direct pointers to memory and sample position description
248 in \link ::snd_pcm_channel_area_t \endlink structure. After application
249 transfers the data in the memory areas, then it must be acknowledged
250 the end of transfer via \link ::snd_pcm_mmap_commit() \endlink function
251 to allow the ALSA library update the pointers to ring buffer. This kind of
252 communication is also called "zero-copy", because the device does not require
253 to copy the samples from application to another place in system memory.
256 If you like to use the compatibility functions in mmap mode, there are
257 read / write routines equaling to standard read / write transfers. Using
258 these functions discards the benefits of direct access to memory region.
259 See the \link ::snd_pcm_mmap_readi() \endlink,
260 \link ::snd_pcm_writei() \endlink, \link ::snd_pcm_readn() \endlink
261 and \link ::snd_pcm_writen() \endlink functions.
263 \section pcm_params Managing parameters
265 The ALSA PCM device uses two groups of PCM related parameters. The hardware
266 parameters contains the stream description like format, rate, count of
267 channels, ring buffer size etc. The software parameters contains the
268 software (driver) related parameters. The communication behaviour can be
269 controlled via these parameters, like automatic start, automatic stop,
270 interrupting (chunk acknowledge) etc. The software parameters can be
271 modified at any time (when valid hardware parameters are set). It includes
272 the running state as well.
274 \subsection pcm_hw_params Hardware related parameters
276 The ALSA PCM devices use the parameter refining system for hardware
277 parameters - \link ::snd_pcm_hw_params_t \endlink. It means, that
278 application choose the full-range of configurations at first and then
279 application sets single parameters until all parameters are elementary
284 ALSA knows about five access modes. The first three can be used for direct
285 communication. The access mode \link ::SND_PCM_ACCESS_MMAP_INTERLEAVED \endlink
286 determines the direct memory area and interleaved sample organization.
287 Interleaved organization means, that samples from channels are mixed together.
288 The access mode \link ::SND_PCM_ACCESS_MMAP_NONINTERLEAVED \endlink
289 determines the direct memory area and non-interleaved sample organization.
290 Each channel has a separate buffer in the case. The complex direct memory
291 organization represents the \link ::SND_PCM_ACCESS_MMAP_COMPLEX \endlink
292 access mode. The sample organization does not fit the interleaved or
293 non-interleaved access modes in the case. The last two access modes
294 describes the read / write access methods.
295 The \link ::SND_PCM_ACCESS_RW_INTERLEAVED \endlink access represents the read /
296 write interleaved access and the \link ::SND_PCM_ACCESS_RW_NONINTERLEAVED \endlink
297 represents the non-interleaved access.
301 The full list of formats is available in \link ::snd_pcm_format_t \endlink
304 \subsection pcm_sw_params Software related parameters
306 These parameters - \link ::snd_pcm_sw_params_t \endlink can be modified at
307 any time including the running state.
309 \par Minimum available count of samples
311 This parameter controls the wakeup point. If the count of available samples
312 is equal or greater than this value, then application will be activated.
316 The timestamp mode specifies, if timestamps are activated. Currently, only
317 \link ::SND_PCM_TSTAMP_NONE \endlink and \link ::SND_PCM_TSTAMP_MMAP
318 \endlink modes are known. The mmap mode means that timestamp is taken
319 on every period time boundary.
323 This parameters means the minimum of ticks to sleep using a standalone
324 timer (usually the system timer). The tick resolution can be obtained
325 via the function \link ::snd_pcm_hw_params_get_tick_time \endlink. This
326 function can be used to fine-tune the transfer acknowledge process. It could
327 be useful especially when some hardware does not support small transfer
332 The read / write transfers can be aligned to this sample count. The modulo
333 is ignored by device. Usually, this value is set to one (no align).
337 The start threshold parameter is used to determine the start point in
338 stream. For playback, if samples in ring buffer is equal or greater than
339 the start threshold parameters and the stream is not running, the stream will
340 be started automatically from the device. For capture, if the application wants
341 to read count of samples equal or greater then the stream will be started.
342 If you want to use explicit start (\link ::snd_pcm_start \endlink), you can
343 set this value greater than ring buffer size (in samples), but use the
344 constant MAXINT is not a bad idea.
348 Similarly, the stop threshold parameter is used to automatically stop
349 the running stream, when the available samples crosses this boundary.
350 It means, for playback, the empty samples in ring buffer and for capture,
351 the filled (used) samples in ring buffer.
353 \par Silence threshold
355 The silence threshold specifies count of samples filled with silence
356 ahead of the current application pointer for playback. It is usable
357 for applications when an overrun is possible (like tasks depending on
358 network I/O etc.). If application wants to manage the ahead samples itself,
359 the \link ::snd_pcm_rewind() \endlink function allows to forget the last
360 samples in the stream.
362 \section pcm_status Obtaining stream status
364 The stream status is stored in \link ::snd_pcm_status_t \endlink structure.
365 These parameters can be obtained: the current stream state -
366 \link ::snd_pcm_status_get_state \endlink, timestamp of trigger -
367 \link ::snd_pcm_status_get_trigger_tstamp \endlink, timestamp of last
368 update \link ::snd_pcm_status_get_tstamp \endlink, delay in samples -
369 \link ::snd_pcm_status_get_delay \endlink, available count in samples -
370 \link ::snd_pcm_status_get_avail \endlink, maximum available samples -
371 \link ::snd_pcm_status_get_avail_max \endlink, ADC over-range count in
372 samples - \link ::snd_pcm_status_get_overrange \endlink. The last two
373 parameters - avail_max and overrange are reset to zero after the status
376 \subsection pcm_status_fast Obtaining stream state fast and update r/w pointer
378 The function \link ::snd_pcm_avail_update \endlink updates the current
379 available count of samples for writing (playback) or filled samples for
380 reading (capture). This call is mandatory for updating actual r/w pointer.
381 Using standalone, it is a light method to obtain current stream position,
382 because it does not require the user <-> kernel context switch, but the value
383 is less accurate, because ring buffer pointers are updated in kernel drivers
384 only when an interrupt occurs. If you want to get accurate stream state,
385 use functions \link ::snd_pcm_avail \endlink or \link ::snd_pcm_delay \endlink.
386 Note that both of these functions do not update the current r/w pointer
387 for applications, so the function \link ::snd_pcm_avail_update \endlink must
388 be called afterwards before any read/write begin+commit operations.
390 The function \link ::snd_pcm_avail \endlink returns current available space
391 in the ring buffer. Note that this function does not update the current r/w
392 pointer for applications, so the function \link ::snd_pcm_avail_update \endlink
393 must be called afterwards before any read/write/begin+commit operations.
395 The function \link ::snd_pcm_delay \endlink returns the delay in samples.
396 For playback, it means count of samples in the ring buffer before
397 the next sample will be sent to DAC. For capture, it means count of samples
398 in the ring buffer before the next sample will be captured from ADC. It works
399 only when the stream is in the running or draining (playback only) state.
400 Note that this function does not update the current r/w pointer for applications,
401 so the function \link ::snd_pcm_avail_update \endlink must be called afterwards
402 before any read/write begin+commit operations.
404 \section pcm_action Managing the stream state
406 These functions directly and indirectly affecting the stream state:
408 \par snd_pcm_hw_params
409 The \link ::snd_pcm_hw_params \endlink function brings the stream state
410 to \link ::SND_PCM_STATE_SETUP \endlink
411 if successfully finishes, otherwise the state \link ::SND_PCM_STATE_OPEN
415 The \link ::snd_pcm_prepare \endlink function enters the
416 \link ::SND_PCM_STATE_PREPARED \endlink after a successful finish.
419 The \link ::snd_pcm_start \endlink function enters
420 the \link ::SND_PCM_STATE_RUNNING \endlink after a successful finish.
423 The \link ::snd_pcm_drop \endlink function enters the
424 \link ::SND_PCM_STATE_SETUP \endlink state.
427 The \link ::snd_pcm_drain \endlink function enters the
428 \link ::SND_PCM_STATE_DRAINING \endlink, if
429 the capture device has some samples in the ring buffer otherwise
430 \link ::SND_PCM_STATE_SETUP \endlink state is entered.
433 The \link ::snd_pcm_pause \endlink function enters the
434 \link ::SND_PCM_STATE_PAUSED \endlink or
435 \link ::SND_PCM_STATE_RUNNING \endlink.
437 \par snd_pcm_writei, snd_pcm_writen
438 The \link ::snd_pcm_writei \endlink and \link ::snd_pcm_writen \endlink
439 functions can conditionally start the stream -
440 \link ::SND_PCM_STATE_RUNNING \endlink. They depend on the start threshold
443 \par snd_pcm_readi, snd_pcm_readn
444 The \link ::snd_pcm_readi \endlink and \link ::snd_pcm_readn \endlink
445 functions can conditionally start the stream -
446 \link ::SND_PCM_STATE_RUNNING \endlink. They depend on the start threshold
449 \section pcm_sync Streams synchronization
451 There are two functions allowing link multiple streams together. In the
452 case, the linking means that all operations are synchronized. Because the
453 drivers cannot guarantee the synchronization (sample resolution) on hardware
454 lacking this feature, the \link ::snd_pcm_info_get_sync \endlink function
455 returns synchronization ID - \link ::snd_pcm_sync_id_t \endlink, which is equal
456 for hardware synchronized streams. When the \link ::snd_pcm_link \endlink
457 function is called, all operations managing the stream state for these two
458 streams are joined. The opposite function is \link ::snd_pcm_unlink \endlink.
460 \section pcm_dev_names PCM naming conventions
462 The ALSA library uses a generic string representation for names of devices.
463 The devices might be virtual, physical or a mix of both. The generic string
464 is passed to \link ::snd_pcm_open() \endlink or \link ::snd_pcm_open_lconf() \endlink.
465 It contains two parts: device name and arguments. Devices and arguments are described
466 in configuration files. The usual place for default definitions is at /usr/share/alsa/alsa.conf.
467 For detailed descriptions about integrated PCM plugins look to \ref pcm_plugins.
469 \subsection pcm_dev_names_default Default device
471 The default device is equal to plug plugin with hw plugin as slave. The defaults are
475 defaults.pcm.device 0
476 defaults.pcm.subdevice -1
478 These defaults can be freely overwritten in local configuration files.
486 \subsection pcm_dev_names_hw HW device
488 The hw device description uses the hw plugin. The three arguments (in order: CARD,DEV,SUBDEV)
489 specify card number or identifier, device number and subdevice number (-1 means any).
499 hw:DEV=1,CARD=soundwave,SUBDEV=2
502 \subsection pcm_dev_names_plughw Plug->HW device
504 The plughw device description uses the plug plugin and hw plugin as slave. The arguments
505 are same as for hw device.
515 plughw:DEV=1,CARD=soundwave,SUBDEV=2
518 \subsection pcm_dev_names_plug Plug device
520 The plug device uses the plug plugin. The one SLAVE argument specifies the slave plugin.
531 \subsection pcm_dev_names_shm Shared memory device
533 The shm device uses the shm plugin. The two arguments (in order: SOCKET,PCM) specify
534 UNIX socket name (for example /tmp/alsa.socket) for server communication and server's PCM name.
539 shm:'/tmp/alsa.sock',default
540 shm:SOCKET='/tmp/alsa.sock',PCM=default
543 \subsection pcm_dev_names_tee Tee device
545 The tee device stores contents of a stream to given file plus transfers it to given slave plugin.
546 The three arguments (in order: SLAVE,FILE,FORMAT) specify slave plugin, filename and file format.
551 tee:hw,'/tmp/out.raw',raw
554 \subsection pcm_dev_names_file File device
556 The file device is file plugin with null plugin as slave. The arguments (in order: FILE,FORMAT)
557 specify filename and file format.
562 file:'/tmp/out.raw',raw
565 \subsection pcm_dev_names_null Null device
567 The null device is null plugin. This device has not any arguments.
570 \section pcm_examples Examples
572 The full featured examples with cross-links:
574 \par Sine-wave generator
575 \ref example_test_pcm "example code"
577 This example shows various transfer methods for the playback direction.
579 \par Latency measuring tool
580 \ref example_test_latency "example code"
582 This example shows the measuring of minimal latency between capture and
588 * \example ../test/pcm.c
589 * \anchor example_test_pcm
592 * \example ../test/latency.c
593 * \anchor example_test_latency
603 #include <sys/ioctl.h>
604 #include <sys/poll.h>
606 #include <sys/mman.h>
608 #include "pcm_local.h"
611 * \brief get identifier of PCM handle
612 * \param pcm PCM handle
613 * \return ascii identifier of PCM handle
615 * Returns the ASCII identifier of given PCM handle. It's the same
616 * identifier specified in snd_pcm_open().
618 const char *snd_pcm_name(snd_pcm_t *pcm)
625 * \brief get type of PCM handle
626 * \param pcm PCM handle
627 * \return type of PCM handle
629 * Returns the type #snd_pcm_type_t of given PCM handle.
631 snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm)
638 * \brief get stream for a PCM handle
639 * \param pcm PCM handle
640 * \return stream of PCM handle
642 * Returns the type #snd_pcm_stream_t of given PCM handle.
644 snd_pcm_stream_t snd_pcm_stream(snd_pcm_t *pcm)
651 * \brief close PCM handle
652 * \param pcm PCM handle
653 * \return 0 on success otherwise a negative error code
655 * Closes the specified PCM handle and frees all associated
658 int snd_pcm_close(snd_pcm_t *pcm)
664 err = snd_pcm_hw_free(pcm);
668 while (!list_empty(&pcm->async_handlers)) {
669 snd_async_handler_t *h = list_entry(pcm->async_handlers.next, snd_async_handler_t, hlist);
670 snd_async_del_handler(h);
672 err = pcm->ops->close(pcm->op_arg);
677 if (pcm->hw.link_dst)
678 free(pcm->hw.link_dst);
679 if (pcm->appl.link_dst)
680 free(pcm->appl.link_dst);
686 * \brief set nonblock mode
687 * \param pcm PCM handle
688 * \param nonblock 0 = block, 1 = nonblock mode
689 * \return 0 on success otherwise a negative error code
691 int snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock)
695 if ((err = pcm->ops->nonblock(pcm->op_arg, nonblock)) < 0)
698 pcm->mode |= SND_PCM_NONBLOCK;
700 pcm->mode &= ~SND_PCM_NONBLOCK;
706 * \brief set async mode
707 * \param pcm PCM handle
708 * \param sig Signal to raise: < 0 disable, 0 default (SIGIO)
709 * \param pid Process ID to signal: 0 current
710 * \return 0 on success otherwise a negative error code
712 * A signal is raised every period.
714 int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid)
721 return pcm->ops->async(pcm->op_arg, sig, pid);
726 * \brief Obtain general (static) information for PCM handle
727 * \param pcm PCM handle
728 * \param info Information container
729 * \return 0 on success otherwise a negative error code
731 int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
734 return pcm->ops->info(pcm->op_arg, info);
737 /** \brief Retreive current PCM hardware configuration chosen with #snd_pcm_hw_params
738 * \param pcm PCM handle
739 * \param params Configuration space definition container
740 * \return 0 on success otherwise a negative error code
742 int snd_pcm_hw_params_current(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
744 unsigned int frame_bits;
746 assert(pcm && params);
749 snd_pcm_hw_params_clear(params);
750 snd_mask_copy(¶ms->masks[SND_PCM_HW_PARAM_ACCESS], (snd_mask_t *)&pcm->access);
751 snd_mask_copy(¶ms->masks[SND_PCM_HW_PARAM_FORMAT], (snd_mask_t *)&pcm->format);
752 snd_mask_copy(¶ms->masks[SND_PCM_HW_PARAM_SUBFORMAT], (snd_mask_t *)&pcm->subformat);
753 frame_bits = snd_pcm_format_physical_width(pcm->format) * pcm->channels;
754 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_FRAME_BITS], frame_bits);
755 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_CHANNELS], pcm->channels);
756 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_RATE], pcm->rate);
757 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_PERIOD_TIME], pcm->period_time);
758 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_PERIOD_SIZE], pcm->period_size);
759 snd_interval_copy(¶ms->intervals[SND_PCM_HW_PARAM_PERIODS], &pcm->periods);
760 snd_interval_copy(¶ms->intervals[SND_PCM_HW_PARAM_BUFFER_TIME], &pcm->buffer_time);
761 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_BUFFER_SIZE], pcm->buffer_size);
762 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_BUFFER_BYTES], (pcm->buffer_size * frame_bits) / 8);
763 snd_interval_set_value(¶ms->intervals[SND_PCM_HW_PARAM_TICK_TIME], pcm->tick_time);
764 params->info = pcm->info;
765 params->msbits = pcm->msbits;
766 params->rate_num = pcm->rate_num;
767 params->rate_den = pcm->rate_den;
768 params->fifo_size = pcm->fifo_size;
772 /** \brief Install one PCM hardware configuration chosen from a configuration space and #snd_pcm_prepare it
773 * \param pcm PCM handle
774 * \param params Configuration space definition container
775 * \return 0 on success otherwise a negative error code
777 * The configuration is chosen fixing single parameters in this order:
778 * first access, first format, first subformat, min channels, min rate,
779 * min period time, max buffer size, min tick time
781 int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
784 assert(pcm && params);
785 err = _snd_pcm_hw_params(pcm, params);
788 err = snd_pcm_prepare(pcm);
792 /** \brief Remove PCM hardware configuration and free associated resources
793 * \param pcm PCM handle
794 * \return 0 on success otherwise a negative error code
796 int snd_pcm_hw_free(snd_pcm_t *pcm)
800 if (pcm->mmap_channels) {
801 err = snd_pcm_munmap(pcm);
805 // assert(snd_pcm_state(pcm) == SND_PCM_STATE_SETUP ||
806 // snd_pcm_state(pcm) == SND_PCM_STATE_PREPARED);
807 err = pcm->ops->hw_free(pcm->op_arg);
814 /** \brief Install PCM software configuration defined by params
815 * \param pcm PCM handle
816 * \param params Configuration container
817 * \return 0 on success otherwise a negative error code
819 int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
822 err = pcm->ops->sw_params(pcm->op_arg, params);
825 pcm->tstamp_mode = snd_pcm_sw_params_get_tstamp_mode(params);
826 pcm->period_step = params->period_step;
827 pcm->sleep_min = params->sleep_min;
828 pcm->avail_min = params->avail_min;
829 pcm->xfer_align = params->xfer_align;
830 pcm->start_threshold = params->start_threshold;
831 pcm->stop_threshold = params->stop_threshold;
832 pcm->silence_threshold = params->silence_threshold;
833 pcm->silence_size = params->silence_size;
834 pcm->boundary = params->boundary;
839 * \brief Obtain status (runtime) information for PCM handle
840 * \param pcm PCM handle
841 * \param status Status container
842 * \return 0 on success otherwise a negative error code
844 int snd_pcm_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
846 assert(pcm && status);
847 return pcm->fast_ops->status(pcm->fast_op_arg, status);
851 * \brief Return PCM state
852 * \param pcm PCM handle
853 * \return PCM state #snd_pcm_state_t of given PCM handle
855 snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm)
858 return pcm->fast_ops->state(pcm->fast_op_arg);
862 * \brief Synchronize stream position with hardware
863 * \param pcm PCM handle
864 * \return 0 on success otherwise a negative error code
866 * Note this function does not update the actual r/w pointer
867 * for applications. The function \link ::snd_pcm_avail_update \endlink
868 * have to be called before any read/write/begin+commit operation.
870 int snd_pcm_hwsync(snd_pcm_t *pcm)
874 return pcm->fast_ops->hwsync(pcm->fast_op_arg);
878 * \brief Obtain delay for a running PCM handle
879 * \param pcm PCM handle
880 * \param delayp Returned delay in frames
881 * \return 0 on success otherwise a negative error code
883 * Delay is distance between current application frame position and
884 * sound frame position.
885 * It's positive and less than buffer size in normal situation,
886 * negative on playback underrun and greater than buffer size on
889 * Note this function does not update the actual r/w pointer
890 * for applications. The function \link ::snd_pcm_avail_update \endlink
891 * have to be called before any read/write/begin+commit operation.
893 int snd_pcm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
897 return pcm->fast_ops->delay(pcm->fast_op_arg, delayp);
901 * \brief Resume from suspend, no samples are lost
902 * \param pcm PCM handle
903 * \return 0 on success otherwise a negative error code
904 * \retval -EAGAIN resume can't be proceed immediately (audio hardware is probably still suspended)
905 * \retval -ENOSYS hardware doesn't support this feature
907 * This function can be used when the stream is in the suspend state
908 * to do the fine resume from this state. Not all hardware supports
909 * this feature, when an -ENOSYS error is returned, use the snd_pcm_prepare
910 * function to recovery.
912 int snd_pcm_resume(snd_pcm_t *pcm)
916 return pcm->fast_ops->resume(pcm->fast_op_arg);
920 * \brief Prepare PCM for use
921 * \param pcm PCM handle
922 * \return 0 on success otherwise a negative error code
924 int snd_pcm_prepare(snd_pcm_t *pcm)
928 return pcm->fast_ops->prepare(pcm->fast_op_arg);
932 * \brief Reset PCM position
933 * \param pcm PCM handle
934 * \return 0 on success otherwise a negative error code
936 * Reduce PCM delay to 0.
938 int snd_pcm_reset(snd_pcm_t *pcm)
942 return pcm->fast_ops->reset(pcm->fast_op_arg);
947 * \param pcm PCM handle
948 * \return 0 on success otherwise a negative error code
950 int snd_pcm_start(snd_pcm_t *pcm)
954 return pcm->fast_ops->start(pcm->fast_op_arg);
958 * \brief Stop a PCM dropping pending frames
959 * \param pcm PCM handle
960 * \return 0 on success otherwise a negative error code
962 int snd_pcm_drop(snd_pcm_t *pcm)
966 return pcm->fast_ops->drop(pcm->fast_op_arg);
970 * \brief Stop a PCM preserving pending frames
971 * \param pcm PCM handle
972 * \return 0 on success otherwise a negative error code
973 * \retval -ESTRPIPE a suspend event occurred
975 * For playback wait for all pending frames to be played and then stop
977 * For capture stop PCM permitting to retrieve residual frames.
979 int snd_pcm_drain(snd_pcm_t *pcm)
983 return pcm->fast_ops->drain(pcm->fast_op_arg);
987 * \brief Pause/resume PCM
988 * \param pcm PCM handle
989 * \param pause 0 = resume, 1 = pause
990 * \return 0 on success otherwise a negative error code
992 int snd_pcm_pause(snd_pcm_t *pcm, int enable)
996 return pcm->fast_ops->pause(pcm->fast_op_arg, enable);
1000 * \brief Move application frame position backward
1001 * \param pcm PCM handle
1002 * \param frames wanted displacement in frames
1003 * \return a positive number for actual displacement otherwise a
1004 * negative error code
1006 snd_pcm_sframes_t snd_pcm_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
1011 return pcm->fast_ops->rewind(pcm->fast_op_arg, frames);
1015 * \brief Write interleaved frames to a PCM
1016 * \param pcm PCM handle
1017 * \param buffer frames containing buffer
1018 * \param size frames to be written
1019 * \return a positive number of frames actually written otherwise a
1020 * negative error code
1021 * \retval -EBADFD PCM is not in the right state (#SND_PCM_STATE_PREPARED or #SND_PCM_STATE_RUNNING)
1022 * \retval -EPIPE an underrun occurred
1023 * \retval -ESTRPIPE a suspend event occurred (stream is suspended and waiting for an application recovery)
1025 * If the blocking behaviour is selected, then routine waits until
1026 * all requested bytes are played or put to the playback ring buffer.
1027 * The count of bytes can be less only if a signal or underrun occurred.
1029 * If the non-blocking behaviour is selected, then routine doesn't wait at all.
1031 snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
1034 assert(size == 0 || buffer);
1036 assert(pcm->access == SND_PCM_ACCESS_RW_INTERLEAVED);
1037 return _snd_pcm_writei(pcm, buffer, size);
1041 * \brief Write non interleaved frames to a PCM
1042 * \param pcm PCM handle
1043 * \param bufs frames containing buffers (one for each channel)
1044 * \param size frames to be written
1045 * \return a positive number of frames actually written otherwise a
1046 * negative error code
1047 * \retval -EBADFD PCM is not in the right state (#SND_PCM_STATE_PREPARED or #SND_PCM_STATE_RUNNING)
1048 * \retval -EPIPE an underrun occurred
1049 * \retval -ESTRPIPE a suspend event occurred (stream is suspended and waiting for an application recovery)
1051 * If the blocking behaviour is selected, then routine waits until
1052 * all requested bytes are played or put to the playback ring buffer.
1053 * The count of bytes can be less only if a signal or underrun occurred.
1055 * If the non-blocking behaviour is selected, then routine doesn't wait at all.
1057 snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
1060 assert(size == 0 || bufs);
1062 assert(pcm->access == SND_PCM_ACCESS_RW_NONINTERLEAVED);
1063 return _snd_pcm_writen(pcm, bufs, size);
1067 * \brief Read interleaved frames from a PCM
1068 * \param pcm PCM handle
1069 * \param buffer frames containing buffer
1070 * \param size frames to be written
1071 * \return a positive number of frames actually read otherwise a
1072 * negative error code
1073 * \retval -EBADFD PCM is not in the right state (#SND_PCM_STATE_PREPARED or #SND_PCM_STATE_RUNNING)
1074 * \retval -EPIPE an overrun occurred
1075 * \retval -ESTRPIPE a suspend event occurred (stream is suspended and waiting for an application recovery)
1077 * If the blocking behaviour was selected, then routine waits until
1078 * all requested bytes are filled. The count of bytes can be less only
1079 * if a signal or underrun occurred.
1081 * If the non-blocking behaviour is selected, then routine doesn't wait at all.
1083 snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)
1086 assert(size == 0 || buffer);
1088 assert(pcm->access == SND_PCM_ACCESS_RW_INTERLEAVED);
1089 return _snd_pcm_readi(pcm, buffer, size);
1093 * \brief Read non interleaved frames to a PCM
1094 * \param pcm PCM handle
1095 * \param bufs frames containing buffers (one for each channel)
1096 * \param size frames to be written
1097 * \return a positive number of frames actually read otherwise a
1098 * negative error code
1099 * \retval -EBADFD PCM is not in the right state (#SND_PCM_STATE_PREPARED or #SND_PCM_STATE_RUNNING)
1100 * \retval -EPIPE an overrun occurred
1101 * \retval -ESTRPIPE a suspend event occurred (stream is suspended and waiting for an application recovery)
1103 * If the blocking behaviour was selected, then routine waits until
1104 * all requested bytes are filled. The count of bytes can be less only
1105 * if a signal or underrun occurred.
1107 * If the non-blocking behaviour is selected, then routine doesn't wait at all.
1109 snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size)
1112 assert(size == 0 || bufs);
1114 assert(pcm->access == SND_PCM_ACCESS_RW_NONINTERLEAVED);
1115 return _snd_pcm_readn(pcm, bufs, size);
1119 * \brief Link two PCMs
1120 * \param pcm1 first PCM handle
1121 * \param pcm2 first PCM handle
1122 * \return 0 on success otherwise a negative error code
1124 * The two PCMs will start/stop/prepare in sync.
1126 int snd_pcm_link(snd_pcm_t *pcm1, snd_pcm_t *pcm2)
1128 int fd1 = _snd_pcm_link_descriptor(pcm1);
1129 int fd2 = _snd_pcm_link_descriptor(pcm2);
1130 if (fd1 < 0 || fd2 < 0)
1132 if (ioctl(fd1, SNDRV_PCM_IOCTL_LINK, fd2) < 0) {
1133 SYSERR("SNDRV_PCM_IOCTL_LINK failed");
1140 * \brief Remove a PCM from a linked group
1141 * \param pcm PCM handle
1142 * \return 0 on success otherwise a negative error code
1144 int snd_pcm_unlink(snd_pcm_t *pcm)
1147 fd = _snd_pcm_link_descriptor(pcm);
1148 if (ioctl(fd, SNDRV_PCM_IOCTL_UNLINK) < 0) {
1149 SYSERR("SNDRV_PCM_IOCTL_UNLINK failed");
1156 * \brief get count of poll descriptors for PCM handle
1157 * \param pcm PCM handle
1158 * \return count of poll descriptors
1160 int snd_pcm_poll_descriptors_count(snd_pcm_t *pcm)
1168 * \brief get poll descriptors
1169 * \param pcm PCM handle
1170 * \param pfds array of poll descriptors
1171 * \param space space in the poll descriptor array
1172 * \return count of filled descriptors
1174 int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space)
1176 assert(pcm && pfds);
1177 if (space >= 1 && pfds) {
1178 pfds->fd = pcm->poll_fd;
1179 pfds->events = pcm->stream == SND_PCM_STREAM_PLAYBACK ? (POLLOUT|POLLERR) : (POLLIN|POLLERR);
1186 * \brief get returned events from poll descriptors
1187 * \param pcm PCM handle
1188 * \param pfds array of poll descriptors
1189 * \param nfds count of poll descriptors
1190 * \param revents returned events
1191 * \return zero if success, otherwise a negative error code
1193 int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
1195 assert(pcm && pfds && revents);
1197 *revents = pfds->revents;
1204 #define STATE(v) [SND_PCM_STATE_##v] = #v
1205 #define STREAM(v) [SND_PCM_STREAM_##v] = #v
1206 #define READY(v) [SND_PCM_READY_##v] = #v
1207 #define XRUN(v) [SND_PCM_XRUN_##v] = #v
1208 #define SILENCE(v) [SND_PCM_SILENCE_##v] = #v
1209 #define TSTAMP(v) [SND_PCM_TSTAMP_##v] = #v
1210 #define ACCESS(v) [SND_PCM_ACCESS_##v] = #v
1211 #define START(v) [SND_PCM_START_##v] = #v
1212 #define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v
1213 #define SW_PARAM(v) [SND_PCM_SW_PARAM_##v] = #v
1214 #define FORMAT(v) [SND_PCM_FORMAT_##v] = #v
1215 #define SUBFORMAT(v) [SND_PCM_SUBFORMAT_##v] = #v
1217 #define FORMATD(v, d) [SND_PCM_FORMAT_##v] = d
1218 #define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d
1220 static const char *snd_pcm_stream_names[] = {
1225 static const char *snd_pcm_state_names[] = {
1236 static const char *snd_pcm_access_names[] = {
1237 ACCESS(MMAP_INTERLEAVED),
1238 ACCESS(MMAP_NONINTERLEAVED),
1239 ACCESS(MMAP_COMPLEX),
1240 ACCESS(RW_INTERLEAVED),
1241 ACCESS(RW_NONINTERLEAVED),
1244 static const char *snd_pcm_format_names[] = {
1263 FORMAT(IEC958_SUBFRAME_LE),
1264 FORMAT(IEC958_SUBFRAME_BE),
1285 static const char *snd_pcm_format_descriptions[] = {
1286 FORMATD(S8, "Signed 8 bit"),
1287 FORMATD(U8, "Unsigned 8 bit"),
1288 FORMATD(S16_LE, "Signed 16 bit Little Endian"),
1289 FORMATD(S16_BE, "Signed 16 bit Big Endian"),
1290 FORMATD(U16_LE, "Unsigned 16 bit Little Endian"),
1291 FORMATD(U16_BE, "Unsigned 16 bit Big Endian"),
1292 FORMATD(S24_LE, "Signed 24 bit Little Endian"),
1293 FORMATD(S24_BE, "Signed 24 bit Big Endian"),
1294 FORMATD(U24_LE, "Unsigned 24 bit Little Endian"),
1295 FORMATD(U24_BE, "Unsigned 24 bit Big Endian"),
1296 FORMATD(S32_LE, "Signed 32 bit Little Endian"),
1297 FORMATD(S32_BE, "Signed 32 bit Big Endian"),
1298 FORMATD(U32_LE, "Unsigned 32 bit Little Endian"),
1299 FORMATD(U32_BE, "Unsigned 32 bit Big Endian"),
1300 FORMATD(FLOAT_LE, "Float 32 bit Little Endian"),
1301 FORMATD(FLOAT_BE, "Float 32 bit Big Endian"),
1302 FORMATD(FLOAT64_LE, "Float 64 bit Little Endian"),
1303 FORMATD(FLOAT64_BE, "Float 64 bit Big Endian"),
1304 FORMATD(IEC958_SUBFRAME_LE, "IEC-958 Little Endian"),
1305 FORMATD(IEC958_SUBFRAME_BE, "IEC-958 Big Endian"),
1306 FORMATD(MU_LAW, "Mu-Law"),
1307 FORMATD(A_LAW, "A-Law"),
1308 FORMATD(IMA_ADPCM, "Ima-ADPCM"),
1309 FORMATD(MPEG, "MPEG"),
1310 FORMATD(GSM, "GSM"),
1311 FORMATD(SPECIAL, "Special"),
1312 FORMATD(S24_3LE, "Signed 24 bit Little Endian in 3bytes"),
1313 FORMATD(S24_3BE, "Signed 24 bit Big Endian in 3bytes"),
1314 FORMATD(U24_3LE, "Unsigned 24 bit Little Endian in 3bytes"),
1315 FORMATD(U24_3BE, "Unsigned 24 bit Big Endian in 3bytes"),
1316 FORMATD(S20_3LE, "Signed 20 bit Little Endian in 3bytes"),
1317 FORMATD(S20_3BE, "Signed 20 bit Big Endian in 3bytes"),
1318 FORMATD(U20_3LE, "Unsigned 20 bit Little Endian in 3bytes"),
1319 FORMATD(U20_3BE, "Unsigned 20 bit Big Endian in 3bytes"),
1320 FORMATD(S18_3LE, "Signed 18 bit Little Endian in 3bytes"),
1321 FORMATD(S18_3BE, "Signed 18 bit Big Endian in 3bytes"),
1322 FORMATD(U18_3LE, "Unsigned 18 bit Little Endian in 3bytes"),
1323 FORMATD(U18_3BE, "Unsigned 18 bit Big Endian in 3bytes"),
1326 static const char *snd_pcm_subformat_names[] = {
1330 static const char *snd_pcm_subformat_descriptions[] = {
1331 SUBFORMATD(STD, "Standard"),
1334 static const char *snd_pcm_start_mode_names[] = {
1339 static const char *snd_pcm_xrun_mode_names[] = {
1344 static const char *snd_pcm_tstamp_mode_names[] = {
1351 * \brief get name of PCM stream
1352 * \param stream PCM stream
1353 * \return ascii name of PCM stream
1355 const char *snd_pcm_stream_name(snd_pcm_stream_t stream)
1357 assert(stream <= SND_PCM_STREAM_LAST);
1358 return snd_pcm_stream_names[stream];
1362 * \brief get name of PCM access type
1363 * \param access PCM access type
1364 * \return ascii name of PCM access type
1366 const char *snd_pcm_access_name(snd_pcm_access_t acc)
1368 if (acc > SND_PCM_ACCESS_LAST)
1370 return snd_pcm_access_names[acc];
1374 * \brief get name of PCM sample format
1375 * \param format PCM sample format
1376 * \return ascii name of PCM sample format
1378 const char *snd_pcm_format_name(snd_pcm_format_t format)
1380 if (format > SND_PCM_FORMAT_LAST)
1382 return snd_pcm_format_names[format];
1386 * \brief get description of PCM sample format
1387 * \param format PCM sample format
1388 * \return ascii description of PCM sample format
1390 const char *snd_pcm_format_description(snd_pcm_format_t format)
1392 if (format > SND_PCM_FORMAT_LAST)
1394 return snd_pcm_format_descriptions[format];
1398 * \brief get PCM sample format from name
1399 * \param name PCM sample format name (case insensitive)
1400 * \return PCM sample format
1402 snd_pcm_format_t snd_pcm_format_value(const char* name)
1404 snd_pcm_format_t format;
1405 for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
1406 if (snd_pcm_format_names[format] &&
1407 strcasecmp(name, snd_pcm_format_names[format]) == 0) {
1411 for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
1412 if (snd_pcm_format_descriptions[format] &&
1413 strcasecmp(name, snd_pcm_format_descriptions[format]) == 0) {
1417 return SND_PCM_FORMAT_UNKNOWN;
1421 * \brief get name of PCM sample subformat
1422 * \param format PCM sample subformat
1423 * \return ascii name of PCM sample subformat
1425 const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
1427 if (subformat > SND_PCM_SUBFORMAT_LAST)
1429 return snd_pcm_subformat_names[subformat];
1433 * \brief get description of PCM sample subformat
1434 * \param subformat PCM sample subformat
1435 * \return ascii description of PCM sample subformat
1437 const char *snd_pcm_subformat_description(snd_pcm_subformat_t subformat)
1439 if (subformat > SND_PCM_SUBFORMAT_LAST)
1441 return snd_pcm_subformat_descriptions[subformat];
1445 * \brief (DEPRECATED) get name of PCM start mode setting
1446 * \param mode PCM start mode
1447 * \return ascii name of PCM start mode setting
1449 const char *snd_pcm_start_mode_name(snd_pcm_start_t mode)
1451 assert(mode <= SND_PCM_START_LAST);
1452 return snd_pcm_start_mode_names[mode];
1456 link_warning(snd_pcm_start_mode_name, "Warning: start_mode is deprecated, consider to use start_threshold");
1460 * \brief (DEPRECATED) get name of PCM xrun mode setting
1461 * \param mode PCM xrun mode
1462 * \return ascii name of PCM xrun mode setting
1464 const char *snd_pcm_xrun_mode_name(snd_pcm_xrun_t mode)
1466 assert(mode <= SND_PCM_XRUN_LAST);
1467 return snd_pcm_xrun_mode_names[mode];
1471 link_warning(snd_pcm_xrun_mode_name, "Warning: xrun_mode is deprecated, consider to use stop_threshold");
1475 * \brief get name of PCM tstamp mode setting
1476 * \param mode PCM tstamp mode
1477 * \return ascii name of PCM tstamp mode setting
1479 const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode)
1481 if (mode > SND_PCM_TSTAMP_LAST)
1483 return snd_pcm_tstamp_mode_names[mode];
1487 * \brief get name of PCM state
1488 * \param state PCM state
1489 * \return ascii name of PCM state
1491 const char *snd_pcm_state_name(snd_pcm_state_t state)
1493 if (state > SND_PCM_STATE_LAST)
1495 return snd_pcm_state_names[state];
1499 * \brief Dump current hardware setup for PCM
1500 * \param pcm PCM handle
1501 * \param out Output handle
1502 * \return 0 on success otherwise a negative error code
1504 int snd_pcm_dump_hw_setup(snd_pcm_t *pcm, snd_output_t *out)
1509 snd_output_printf(out, "stream : %s\n", snd_pcm_stream_name(pcm->stream));
1510 snd_output_printf(out, "access : %s\n", snd_pcm_access_name(pcm->access));
1511 snd_output_printf(out, "format : %s\n", snd_pcm_format_name(pcm->format));
1512 snd_output_printf(out, "subformat : %s\n", snd_pcm_subformat_name(pcm->subformat));
1513 snd_output_printf(out, "channels : %u\n", pcm->channels);
1514 snd_output_printf(out, "rate : %u\n", pcm->rate);
1515 snd_output_printf(out, "exact rate : %g (%u/%u)\n", (double) pcm->rate_num / pcm->rate_den, pcm->rate_num, pcm->rate_den);
1516 snd_output_printf(out, "msbits : %u\n", pcm->msbits);
1517 snd_output_printf(out, "buffer_size : %lu\n", pcm->buffer_size);
1518 snd_output_printf(out, "period_size : %lu\n", pcm->period_size);
1519 snd_output_printf(out, "period_time : %u\n", pcm->period_time);
1520 snd_output_printf(out, "tick_time : %u\n", pcm->tick_time);
1525 * \brief Dump current software setup for PCM
1526 * \param pcm PCM handle
1527 * \param out Output handle
1528 * \return 0 on success otherwise a negative error code
1530 int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out)
1535 snd_output_printf(out, "tstamp_mode : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode));
1536 snd_output_printf(out, "period_step : %d\n", pcm->period_step);
1537 snd_output_printf(out, "sleep_min : %d\n", pcm->sleep_min);
1538 snd_output_printf(out, "avail_min : %ld\n", pcm->avail_min);
1539 snd_output_printf(out, "xfer_align : %ld\n", pcm->xfer_align);
1540 snd_output_printf(out, "start_threshold : %ld\n", pcm->start_threshold);
1541 snd_output_printf(out, "stop_threshold : %ld\n", pcm->stop_threshold);
1542 snd_output_printf(out, "silence_threshold: %ld\n", pcm->silence_threshold);
1543 snd_output_printf(out, "silence_size : %ld\n", pcm->silence_size);
1544 snd_output_printf(out, "boundary : %ld\n", pcm->boundary);
1549 * \brief Dump current setup (hardware and software) for PCM
1550 * \param pcm PCM handle
1551 * \param out Output handle
1552 * \return 0 on success otherwise a negative error code
1554 int snd_pcm_dump_setup(snd_pcm_t *pcm, snd_output_t *out)
1556 snd_pcm_dump_hw_setup(pcm, out);
1557 snd_pcm_dump_sw_setup(pcm, out);
1562 * \brief Dump status
1563 * \param status Status container
1564 * \param out Output handle
1565 * \return 0 on success otherwise a negative error code
1567 int snd_pcm_status_dump(snd_pcm_status_t *status, snd_output_t *out)
1570 snd_output_printf(out, "state : %s\n", snd_pcm_state_name((snd_pcm_state_t) status->state));
1571 snd_output_printf(out, "trigger_time: %ld.%06ld\n",
1572 status->trigger_tstamp.tv_sec, status->trigger_tstamp.tv_usec);
1573 snd_output_printf(out, "tstamp : %ld.%06ld\n",
1574 status->tstamp.tv_sec, status->tstamp.tv_usec);
1575 snd_output_printf(out, "delay : %ld\n", (long)status->delay);
1576 snd_output_printf(out, "avail : %ld\n", (long)status->avail);
1577 snd_output_printf(out, "avail_max : %ld\n", (long)status->avail_max);
1582 * \brief Dump PCM info
1583 * \param pcm PCM handle
1584 * \param out Output handle
1585 * \return 0 on success otherwise a negative error code
1587 int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out)
1591 pcm->ops->dump(pcm->op_arg, out);
1596 * \brief Convert bytes in frames for a PCM
1597 * \param pcm PCM handle
1598 * \param bytes quantity in bytes
1599 * \return quantity expressed in frames
1601 snd_pcm_sframes_t snd_pcm_bytes_to_frames(snd_pcm_t *pcm, ssize_t bytes)
1605 return bytes * 8 / pcm->frame_bits;
1609 * \brief Convert frames in bytes for a PCM
1610 * \param pcm PCM handle
1611 * \param frames quantity in frames
1612 * \return quantity expressed in bytes
1614 ssize_t snd_pcm_frames_to_bytes(snd_pcm_t *pcm, snd_pcm_sframes_t frames)
1618 return frames * pcm->frame_bits / 8;
1622 * \brief Convert bytes in samples for a PCM
1623 * \param pcm PCM handle
1624 * \param bytes quantity in bytes
1625 * \return quantity expressed in samples
1627 long snd_pcm_bytes_to_samples(snd_pcm_t *pcm, ssize_t bytes)
1631 return bytes * 8 / pcm->sample_bits;
1635 * \brief Convert samples in bytes for a PCM
1636 * \param pcm PCM handle
1637 * \param samples quantity in samples
1638 * \return quantity expressed in bytes
1640 ssize_t snd_pcm_samples_to_bytes(snd_pcm_t *pcm, long samples)
1644 return samples * pcm->sample_bits / 8;
1648 * \brief Add an async handler for a PCM
1649 * \param handler Returned handler handle
1650 * \param pcm PCM handle
1651 * \param callback Callback function
1652 * \param private_data Callback private data
1653 * \return 0 otherwise a negative error code on failure
1655 * The asynchronous callback is called when period boundary elapses.
1657 int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm,
1658 snd_async_callback_t callback, void *private_data)
1662 snd_async_handler_t *h;
1663 err = snd_async_add_handler(&h, _snd_pcm_async_descriptor(pcm),
1664 callback, private_data);
1667 h->type = SND_ASYNC_HANDLER_PCM;
1669 was_empty = list_empty(&pcm->async_handlers);
1670 list_add_tail(&h->hlist, &pcm->async_handlers);
1672 err = snd_pcm_async(pcm, snd_async_handler_get_signo(h), getpid());
1674 snd_async_del_handler(h);
1683 * \brief Return PCM handle related to an async handler
1684 * \param handler Async handler handle
1685 * \return PCM handle
1687 snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler)
1689 assert(handler->type = SND_ASYNC_HANDLER_PCM);
1690 return handler->u.pcm;
1693 static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
1694 snd_config_t *pcm_root, snd_config_t *pcm_conf,
1695 snd_pcm_stream_t stream, int mode)
1700 snd_config_t *conf, *type_conf = NULL;
1701 snd_config_iterator_t i, next;
1703 const char *lib = NULL, *open_name = NULL;
1704 int (*open_func)(snd_pcm_t **, const char *,
1705 snd_config_t *, snd_config_t *,
1706 snd_pcm_stream_t, int) = NULL;
1708 extern void *snd_pcm_open_symbols(void);
1711 if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
1714 snd_config_get_id(pcm_conf, &id);
1716 snd_config_get_ascii(pcm_conf, &val);
1717 SNDERR("Invalid type for PCM %s%sdefinition (id: %s, value: %s)", name ? name : "", name ? " " : "", id, val);
1722 err = snd_config_search(pcm_conf, "type", &conf);
1724 SNDERR("type is not defined");
1727 err = snd_config_get_id(conf, &id);
1729 SNDERR("unable to get id");
1732 err = snd_config_get_string(conf, &str);
1734 SNDERR("Invalid type for %s", id);
1737 err = snd_config_search_definition(pcm_root, "pcm_type", str, &type_conf);
1739 if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
1740 SNDERR("Invalid type for PCM type %s definition", str);
1743 snd_config_for_each(i, next, type_conf) {
1744 snd_config_t *n = snd_config_iterator_entry(i);
1746 if (snd_config_get_id(n, &id) < 0)
1748 if (strcmp(id, "comment") == 0)
1750 if (strcmp(id, "lib") == 0) {
1751 err = snd_config_get_string(n, &lib);
1753 SNDERR("Invalid type for %s", id);
1758 if (strcmp(id, "open") == 0) {
1759 err = snd_config_get_string(n, &open_name);
1761 SNDERR("Invalid type for %s", id);
1766 SNDERR("Unknown field %s", id);
1773 snprintf(buf, sizeof(buf), "_snd_pcm_%s_open", str);
1776 snd_pcm_open_symbols(); /* this call is for static linking only */
1778 h = snd_dlopen(lib, RTLD_NOW);
1780 open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION));
1783 SNDERR("Cannot open shared library %s", lib);
1785 } else if (!open_func) {
1786 SNDERR("symbol %s is not defined inside %s", open_name, lib);
1792 snd_config_delete(type_conf);
1793 return err >= 0 ? open_func(pcmp, name, pcm_root, pcm_conf, stream, mode) : err;
1796 static int snd_pcm_open_noupdate(snd_pcm_t **pcmp, snd_config_t *root,
1797 const char *name, snd_pcm_stream_t stream, int mode)
1800 snd_config_t *pcm_conf;
1801 err = snd_config_search_definition(root, "pcm", name, &pcm_conf);
1803 SNDERR("Unknown PCM %s", name);
1806 err = snd_pcm_open_conf(pcmp, name, root, pcm_conf, stream, mode);
1807 snd_config_delete(pcm_conf);
1812 * \brief Opens a PCM
1813 * \param pcmp Returned PCM handle
1814 * \param name ASCII identifier of the PCM handle
1815 * \param stream Wanted stream
1816 * \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC)
1817 * \return 0 on success otherwise a negative error code
1819 int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
1820 snd_pcm_stream_t stream, int mode)
1823 assert(pcmp && name);
1824 err = snd_config_update();
1827 return snd_pcm_open_noupdate(pcmp, snd_config, name, stream, mode);
1831 * \brief Opens a PCM using local configuration
1832 * \param pcmp Returned PCM handle
1833 * \param name ASCII identifier of the PCM handle
1834 * \param stream Wanted stream
1835 * \param mode Open mode (see #SND_PCM_NONBLOCK, #SND_PCM_ASYNC)
1836 * \param lconf Local configuration
1837 * \return 0 on success otherwise a negative error code
1839 int snd_pcm_open_lconf(snd_pcm_t **pcmp, const char *name,
1840 snd_pcm_stream_t stream, int mode,
1841 snd_config_t *lconf)
1843 assert(pcmp && name && lconf);
1844 return snd_pcm_open_noupdate(pcmp, lconf, name, stream, mode);
1848 int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
1849 snd_pcm_stream_t stream, int mode)
1852 pcm = calloc(1, sizeof(*pcm));
1857 pcm->name = strdup(name);
1858 pcm->stream = stream;
1861 pcm->fast_op_arg = pcm;
1862 INIT_LIST_HEAD(&pcm->async_handlers);
1867 int snd_pcm_open_slave(snd_pcm_t **pcmp, snd_config_t *root,
1868 snd_config_t *conf, snd_pcm_stream_t stream,
1872 if (snd_config_get_string(conf, &str) >= 0)
1873 return snd_pcm_open_noupdate(pcmp, root, str, stream, mode);
1874 return snd_pcm_open_conf(pcmp, NULL, root, conf, stream, mode);
1879 * \brief Wait for a PCM to become ready
1880 * \param pcm PCM handle
1881 * \param timeout maximum time in milliseconds to wait
1882 * \return a positive value on success otherwise a negative error code
1883 * \retval 0 timeout occurred
1884 * \retval 1 PCM stream is ready for I/O
1886 int snd_pcm_wait(snd_pcm_t *pcm, int timeout)
1890 err = snd_pcm_poll_descriptors(pcm, &pfd, 1);
1892 err = poll(&pfd, 1, timeout);
1895 return err > 0 ? 1 : 0;
1899 * \brief Return number of frames ready to be read/written
1900 * \param pcm PCM handle
1901 * \return a positive number of frames ready otherwise a negative
1904 * On capture does all the actions needed to transport to application
1905 * level all the ready frames across underlying layers.
1907 snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm)
1909 return pcm->fast_ops->avail_update(pcm->fast_op_arg);
1913 * \brief Silence an area
1914 * \param dst_area area specification
1915 * \param dst_offset offset in frames inside area
1916 * \param samples samples to silence
1917 * \param format PCM sample format
1918 * \return 0 on success otherwise a negative error code
1920 int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset,
1921 unsigned int samples, snd_pcm_format_t format)
1923 /* FIXME: sub byte resolution and odd dst_offset */
1925 unsigned int dst_step;
1928 if (!dst_area->addr)
1930 dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
1931 width = snd_pcm_format_physical_width(format);
1932 silence = snd_pcm_format_silence_64(format);
1933 if (dst_area->step == (unsigned int) width) {
1934 unsigned int dwords = samples * width / 64;
1935 samples -= dwords * 64 / width;
1936 while (dwords-- > 0)
1937 *((u_int64_t*)dst)++ = silence;
1941 dst_step = dst_area->step / 8;
1944 u_int8_t s0 = silence & 0xf0;
1945 u_int8_t s1 = silence & 0x0f;
1946 int dstbit = dst_area->first % 8;
1947 int dstbit_step = dst_area->step % 8;
1948 while (samples-- > 0) {
1957 dstbit += dstbit_step;
1966 u_int8_t sil = silence;
1967 while (samples-- > 0) {
1974 u_int16_t sil = silence;
1975 while (samples-- > 0) {
1976 *(u_int16_t*)dst = sil;
1982 #ifdef SNDRV_LITTLE_ENDIAN
1983 *(dst + 0) = silence >> 0;
1984 *(dst + 1) = silence >> 8;
1985 *(dst + 2) = silence >> 16;
1987 *(dst + 2) = silence >> 0;
1988 *(dst + 1) = silence >> 8;
1989 *(dst + 0) = silence >> 16;
1993 u_int32_t sil = silence;
1994 while (samples-- > 0) {
1995 *(u_int32_t*)dst = sil;
2001 while (samples-- > 0) {
2002 *(u_int64_t*)dst = silence;
2014 * \brief Silence one or more areas
2015 * \param dst_areas areas specification (one for each channel)
2016 * \param dst_offset offset in frames inside area
2017 * \param channels channels count
2018 * \param frames frames to silence
2019 * \param format PCM sample format
2020 * \return 0 on success otherwise a negative error code
2022 int snd_pcm_areas_silence(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
2023 unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format)
2025 int width = snd_pcm_format_physical_width(format);
2026 while (channels > 0) {
2027 void *addr = dst_areas->addr;
2028 unsigned int step = dst_areas->step;
2029 const snd_pcm_channel_area_t *begin = dst_areas;
2030 int channels1 = channels;
2031 unsigned int chns = 0;
2037 if (channels1 == 0 ||
2038 dst_areas->addr != addr ||
2039 dst_areas->step != step ||
2040 dst_areas->first != dst_areas[-1].first + width)
2043 if (chns > 1 && chns * width == step) {
2044 /* Collapse the areas */
2045 snd_pcm_channel_area_t d;
2046 d.addr = begin->addr;
2047 d.first = begin->first;
2049 err = snd_pcm_area_silence(&d, dst_offset * chns, frames * chns, format);
2052 err = snd_pcm_area_silence(begin, dst_offset, frames, format);
2053 dst_areas = begin + 1;
2064 * \brief Copy an area
2065 * \param dst_area destination area specification
2066 * \param dst_offset offset in frames inside destination area
2067 * \param src_area source area specification
2068 * \param src_offset offset in frames inside source area
2069 * \param samples samples to copy
2070 * \param format PCM sample format
2071 * \return 0 on success otherwise a negative error code
2073 int snd_pcm_area_copy(const snd_pcm_channel_area_t *dst_area, snd_pcm_uframes_t dst_offset,
2074 const snd_pcm_channel_area_t *src_area, snd_pcm_uframes_t src_offset,
2075 unsigned int samples, snd_pcm_format_t format)
2077 /* FIXME: sub byte resolution and odd dst_offset */
2081 int src_step, dst_step;
2082 if (!src_area->addr)
2083 return snd_pcm_area_silence(dst_area, dst_offset, samples, format);
2084 src = snd_pcm_channel_area_addr(src_area, src_offset);
2085 if (!dst_area->addr)
2087 dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
2088 width = snd_pcm_format_physical_width(format);
2089 if (src_area->step == (unsigned int) width &&
2090 dst_area->step == (unsigned int) width) {
2091 size_t bytes = samples * width / 8;
2092 samples -= bytes * 8 / width;
2093 memcpy(dst, src, bytes);
2097 src_step = src_area->step / 8;
2098 dst_step = dst_area->step / 8;
2101 int srcbit = src_area->first % 8;
2102 int srcbit_step = src_area->step % 8;
2103 int dstbit = dst_area->first % 8;
2104 int dstbit_step = dst_area->step % 8;
2105 while (samples-- > 0) {
2106 unsigned char srcval;
2108 srcval = *src & 0x0f;
2110 srcval = *src & 0xf0;
2117 srcbit += srcbit_step;
2123 dstbit += dstbit_step;
2132 while (samples-- > 0) {
2140 while (samples-- > 0) {
2141 *(u_int16_t*)dst = *(const u_int16_t*)src;
2148 while (samples-- > 0) {
2149 *(u_int32_t*)dst = *(const u_int32_t*)src;
2156 while (samples-- > 0) {
2157 *(u_int64_t*)dst = *(const u_int64_t*)src;
2170 * \brief Copy one or more areas
2171 * \param dst_areas destination areas specification (one for each channel)
2172 * \param dst_offset offset in frames inside destination area
2173 * \param src_areas source areas specification (one for each channel)
2174 * \param src_offset offset in frames inside source area
2175 * \param channels channels count
2176 * \param frames frames to copy
2177 * \param format PCM sample format
2178 * \return 0 on success otherwise a negative error code
2180 int snd_pcm_areas_copy(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset,
2181 const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset,
2182 unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format)
2184 int width = snd_pcm_format_physical_width(format);
2187 assert(channels > 0);
2189 while (channels > 0) {
2190 unsigned int step = src_areas->step;
2191 void *src_addr = src_areas->addr;
2192 const snd_pcm_channel_area_t *src_start = src_areas;
2193 void *dst_addr = dst_areas->addr;
2194 const snd_pcm_channel_area_t *dst_start = dst_areas;
2195 int channels1 = channels;
2196 unsigned int chns = 0;
2197 while (dst_areas->step == step) {
2202 if (channels1 == 0 ||
2203 src_areas->step != step ||
2204 src_areas->addr != src_addr ||
2205 dst_areas->addr != dst_addr ||
2206 src_areas->first != src_areas[-1].first + width ||
2207 dst_areas->first != dst_areas[-1].first + width)
2210 if (chns > 1 && chns * width == step) {
2211 /* Collapse the areas */
2212 snd_pcm_channel_area_t s, d;
2213 s.addr = src_start->addr;
2214 s.first = src_start->first;
2216 d.addr = dst_start->addr;
2217 d.first = dst_start->first;
2219 snd_pcm_area_copy(&d, dst_offset * chns,
2220 &s, src_offset * chns,
2221 frames * chns, format);
2224 snd_pcm_area_copy(dst_start, dst_offset,
2225 src_start, src_offset,
2227 src_areas = src_start + 1;
2228 dst_areas = dst_start + 1;
2235 static void dump_one_param(snd_pcm_hw_params_t *params, unsigned int k, snd_output_t *out)
2237 snd_output_printf(out, "%s: ", snd_pcm_hw_param_name(k));
2238 snd_pcm_hw_param_dump(params, k, out);
2239 snd_output_putc(out, '\n');
2243 * \brief Dump a PCM hardware configuration space
2244 * \param params Configuration space
2245 * \param out Output handle
2246 * \return 0 on success otherwise a negative error code
2248 int snd_pcm_hw_params_dump(snd_pcm_hw_params_t *params, snd_output_t *out)
2251 for (k = SND_PCM_HW_PARAM_FIRST_MASK; k <= SND_PCM_HW_PARAM_LAST_MASK; k++)
2252 dump_one_param(params, k, out);
2253 for (k = SND_PCM_HW_PARAM_FIRST_INTERVAL; k <= SND_PCM_HW_PARAM_LAST_INTERVAL; k++)
2254 dump_one_param(params, k, out);
2259 * \brief Check, if hardware supports sample-resolution mmap for given configuration
2260 * \param param Configuration space
2261 * \return Boolean value
2262 * \retval 0 Hardware doesn't support sample-resolution mmap
2263 * \retval 1 Hardware supports sample-resolution mmap
2265 int snd_pcm_hw_params_can_mmap_sample_resolution(const snd_pcm_hw_params_t *params)
2268 return !!(params->info & SNDRV_PCM_INFO_MMAP_VALID);
2272 * \brief Check, if hardware does double buffering for start/stop for given configuration
2273 * \param param Configuration space
2274 * \return Boolean value
2275 * \retval 0 Hardware doesn't do double buffering for start/stop
2276 * \retval 1 Hardware does double buffering for start/stop
2278 int snd_pcm_hw_params_is_double(const snd_pcm_hw_params_t *params)
2281 return !!(params->info & SNDRV_PCM_INFO_DOUBLE);
2285 * \brief Check, if hardware does double buffering for data transfers for given configuration
2286 * \param param Configuration space
2287 * \return Boolean value
2288 * \retval 0 Hardware doesn't do double buffering for data transfers
2289 * \retval 1 Hardware does double buffering for data transfers
2291 int snd_pcm_hw_params_is_batch(const snd_pcm_hw_params_t *params)
2294 return !!(params->info & SNDRV_PCM_INFO_BATCH);
2298 * \brief Check, if hardware does block transfers for samples for given configuration
2299 * \param param Configuration space
2300 * \return Boolean value
2301 * \retval 0 Hardware doesn't block transfers
2302 * \retval 1 Hardware does block transfers
2304 int snd_pcm_hw_params_is_block_transfer(const snd_pcm_hw_params_t *params)
2307 return !!(params->info & SNDRV_PCM_INFO_BLOCK_TRANSFER);
2311 * \brief Check, if hardware supports overrange detection
2312 * \param param Configuration space
2313 * \return Boolean value
2314 * \retval 0 Hardware doesn't support overrange detection
2315 * \retval 1 Hardware supports overrange detection
2317 int snd_pcm_hw_params_can_overrange(const snd_pcm_hw_params_t *params)
2320 return !!(params->info & SNDRV_PCM_INFO_OVERRANGE);
2324 * \brief Check, if hardware supports pause
2325 * \param param Configuration space
2326 * \return Boolean value
2327 * \retval 0 Hardware doesn't support pause
2328 * \retval 1 Hardware supports pause
2330 int snd_pcm_hw_params_can_pause(const snd_pcm_hw_params_t *params)
2333 return !!(params->info & SNDRV_PCM_INFO_PAUSE);
2337 * \brief Check, if hardware supports resume
2338 * \param param Configuration space
2339 * \return Boolean value
2340 * \retval 0 Hardware doesn't support resume
2341 * \retval 1 Hardware supports resume
2343 int snd_pcm_hw_params_can_resume(const snd_pcm_hw_params_t *params)
2346 return !!(params->info & SNDRV_PCM_INFO_RESUME);
2350 * \brief Check, if hardware does half-duplex only
2351 * \param param Configuration space
2352 * \return Boolean value
2353 * \retval 0 Hardware doesn't do half-duplex
2354 * \retval 1 Hardware does half-duplex
2356 int snd_pcm_hw_params_is_half_duplex(const snd_pcm_hw_params_t *params)
2359 return !!(params->info & SNDRV_PCM_INFO_HALF_DUPLEX);
2363 * \brief Check, if hardware does joint-duplex (playback and capture are somewhat correlated)
2364 * \param param Configuration space
2365 * \return Boolean value
2366 * \retval 0 Hardware doesn't do joint-duplex
2367 * \retval 1 Hardware does joint-duplex
2369 int snd_pcm_hw_params_is_joint_duplex(const snd_pcm_hw_params_t *params)
2372 return !!(params->info & SNDRV_PCM_INFO_JOINT_DUPLEX);
2376 * \brief Check, if hardware supports synchronized start with sample resolution
2377 * \param param Configuration space
2378 * \return Boolean value
2379 * \retval 0 Hardware doesn't support synchronized start
2380 * \retval 1 Hardware supports synchronized start
2382 int snd_pcm_hw_params_can_sync_start(const snd_pcm_hw_params_t *params)
2385 return !!(params->info & SNDRV_PCM_INFO_SYNC_START);
2389 * \brief Get rate exact info from a configuration space
2390 * \param params Configuration space
2391 * \param rate_num Pointer to returned rate numerator
2392 * \param rate_den Pointer to returned rate denominator
2393 * \return 0 otherwise a negative error code if the info is not available
2395 int snd_pcm_hw_params_get_rate_numden(const snd_pcm_hw_params_t *params,
2396 unsigned int *rate_num, unsigned int *rate_den)
2398 if (params->rate_den == 0)
2400 *rate_num = params->rate_num;
2401 *rate_den = params->rate_den;
2406 * \brief Get sample resolution info from a configuration space
2407 * \param params Configuration space
2408 * \return signification bits in sample otherwise a negative error code if the info is not available
2410 int snd_pcm_hw_params_get_sbits(const snd_pcm_hw_params_t *params)
2412 if (params->msbits == 0)
2414 return params->msbits;
2418 * \brief Get hard are FIFO size info from a configuration space
2419 * \param params Configuration space
2420 * \return FIFO size in frames otherwise a negative error code if the info is not available
2422 int snd_pcm_hw_params_get_fifo_size(const snd_pcm_hw_params_t *params)
2424 if (params->fifo_size == 0)
2426 return params->fifo_size;
2430 * \brief Fill params with a full configuration space for a PCM
2431 * \param pcm PCM handle
2432 * \param params Configuration space
2434 int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
2436 _snd_pcm_hw_params_any(params);
2437 return snd_pcm_hw_refine(pcm, params);
2441 * \brief get size of #snd_pcm_access_mask_t
2442 * \return size in bytes
2444 size_t snd_pcm_access_mask_sizeof()
2446 return sizeof(snd_pcm_access_mask_t);
2450 * \brief allocate an empty #snd_pcm_access_mask_t using standard malloc
2451 * \param ptr returned pointer
2452 * \return 0 on success otherwise negative error code
2454 int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr)
2457 *ptr = calloc(1, sizeof(snd_pcm_access_mask_t));
2464 * \brief frees a previously allocated #snd_pcm_access_mask_t
2465 * \param pointer to object to free
2467 void snd_pcm_access_mask_free(snd_pcm_access_mask_t *obj)
2473 * \brief copy one #snd_pcm_access_mask_t to another
2474 * \param dst pointer to destination
2475 * \param src pointer to source
2477 void snd_pcm_access_mask_copy(snd_pcm_access_mask_t *dst, const snd_pcm_access_mask_t *src)
2484 * \brief reset all bits in a #snd_pcm_access_mask_t
2485 * \param mask pointer to mask
2487 void snd_pcm_access_mask_none(snd_pcm_access_mask_t *mask)
2489 snd_mask_none((snd_mask_t *) mask);
2493 * \brief set all bits in a #snd_pcm_access_mask_t
2494 * \param mask pointer to mask
2496 void snd_pcm_access_mask_any(snd_pcm_access_mask_t *mask)
2498 snd_mask_any((snd_mask_t *) mask);
2502 * \brief test the presence of an access type in a #snd_pcm_access_mask_t
2503 * \param mask pointer to mask
2504 * \param val access type
2506 int snd_pcm_access_mask_test(const snd_pcm_access_mask_t *mask, snd_pcm_access_t val)
2508 return snd_mask_test((const snd_mask_t *) mask, (unsigned long) val);
2512 * \brief test, if given a #snd_pcm_access_mask_t is empty
2513 * \param mask pointer to mask
2514 * \retval 0 not empty
2517 int snd_pcm_access_mask_empty(const snd_pcm_access_mask_t *mask)
2519 return snd_mask_empty((const snd_mask_t *) mask);
2523 * \brief make an access type present in a #snd_pcm_access_mask_t
2524 * \param mask pointer to mask
2525 * \param val access type
2527 void snd_pcm_access_mask_set(snd_pcm_access_mask_t *mask, snd_pcm_access_t val)
2529 snd_mask_set((snd_mask_t *) mask, (unsigned long) val);
2533 * \brief make an access type missing from a #snd_pcm_access_mask_t
2534 * \param mask pointer to mask
2535 * \param val access type
2537 void snd_pcm_access_mask_reset(snd_pcm_access_mask_t *mask, snd_pcm_access_t val)
2539 snd_mask_reset((snd_mask_t *) mask, (unsigned long) val);
2543 * \brief get size of #snd_pcm_format_mask_t
2544 * \return size in bytes
2546 size_t snd_pcm_format_mask_sizeof()
2548 return sizeof(snd_pcm_format_mask_t);
2552 * \brief allocate an empty #snd_pcm_format_mask_t using standard malloc
2553 * \param ptr returned pointer
2554 * \return 0 on success otherwise negative error code
2556 int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr)
2559 *ptr = calloc(1, sizeof(snd_pcm_format_mask_t));
2566 * \brief frees a previously allocated #snd_pcm_format_mask_t
2567 * \param pointer to object to free
2569 void snd_pcm_format_mask_free(snd_pcm_format_mask_t *obj)
2575 * \brief copy one #snd_pcm_format_mask_t to another
2576 * \param dst pointer to destination
2577 * \param src pointer to source
2579 void snd_pcm_format_mask_copy(snd_pcm_format_mask_t *dst, const snd_pcm_format_mask_t *src)
2586 * \brief reset all bits in a #snd_pcm_format_mask_t
2587 * \param mask pointer to mask
2589 void snd_pcm_format_mask_none(snd_pcm_format_mask_t *mask)
2591 snd_mask_none((snd_mask_t *) mask);
2595 * \brief set all bits in a #snd_pcm_format_mask_t
2596 * \param mask pointer to mask
2598 void snd_pcm_format_mask_any(snd_pcm_format_mask_t *mask)
2600 snd_mask_any((snd_mask_t *) mask);
2604 * \brief test the presence of a format in a #snd_pcm_format_mask_t
2605 * \param mask pointer to mask
2608 int snd_pcm_format_mask_test(const snd_pcm_format_mask_t *mask, snd_pcm_format_t val)
2610 return snd_mask_test((const snd_mask_t *) mask, (unsigned long) val);
2614 * \brief test, if given a #snd_pcm_format_mask_t is empty
2615 * \param mask pointer to mask
2616 * \retval 0 not empty
2619 int snd_pcm_format_mask_empty(const snd_pcm_format_mask_t *mask)
2621 return snd_mask_empty((const snd_mask_t *) mask);
2625 * \brief make a format present in a #snd_pcm_format_mask_t
2626 * \param mask pointer to mask
2629 void snd_pcm_format_mask_set(snd_pcm_format_mask_t *mask, snd_pcm_format_t val)
2631 snd_mask_set((snd_mask_t *) mask, (unsigned long) val);
2635 * \brief make a format missing from a #snd_pcm_format_mask_t
2636 * \param mask pointer to mask
2639 void snd_pcm_format_mask_reset(snd_pcm_format_mask_t *mask, snd_pcm_format_t val)
2641 snd_mask_reset((snd_mask_t *) mask, (unsigned long) val);
2646 * \brief get size of #snd_pcm_subformat_mask_t
2647 * \return size in bytes
2649 size_t snd_pcm_subformat_mask_sizeof()
2651 return sizeof(snd_pcm_subformat_mask_t);
2655 * \brief allocate an empty #snd_pcm_subformat_mask_t using standard malloc
2656 * \param ptr returned pointer
2657 * \return 0 on success otherwise negative error code
2659 int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr)
2662 *ptr = calloc(1, sizeof(snd_pcm_subformat_mask_t));
2669 * \brief frees a previously allocated #snd_pcm_subformat_mask_t
2670 * \param pointer to object to free
2672 void snd_pcm_subformat_mask_free(snd_pcm_subformat_mask_t *obj)
2678 * \brief copy one #snd_pcm_subformat_mask_t to another
2679 * \param dst pointer to destination
2680 * \param src pointer to source
2682 void snd_pcm_subformat_mask_copy(snd_pcm_subformat_mask_t *dst, const snd_pcm_subformat_mask_t *src)
2689 * \brief reset all bits in a #snd_pcm_subformat_mask_t
2690 * \param mask pointer to mask
2692 void snd_pcm_subformat_mask_none(snd_pcm_subformat_mask_t *mask)
2694 snd_mask_none((snd_mask_t *) mask);
2698 * \brief set all bits in a #snd_pcm_subformat_mask_t
2699 * \param mask pointer to mask
2701 void snd_pcm_subformat_mask_any(snd_pcm_subformat_mask_t *mask)
2703 snd_mask_any((snd_mask_t *) mask);
2707 * \brief test the presence of a subformat in a #snd_pcm_subformat_mask_t
2708 * \param mask pointer to mask
2709 * \param val subformat
2711 int snd_pcm_subformat_mask_test(const snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val)
2713 return snd_mask_test((const snd_mask_t *) mask, (unsigned long) val);
2717 * \brief test, if given a #snd_pcm_subformat_mask_t is empty
2718 * \param mask pointer to mask
2719 * \retval 0 not empty
2722 int snd_pcm_subformat_mask_empty(const snd_pcm_subformat_mask_t *mask)
2724 return snd_mask_empty((const snd_mask_t *) mask);
2728 * \brief make a subformat present in a #snd_pcm_subformat_mask_t
2729 * \param mask pointer to mask
2730 * \param val subformat
2732 void snd_pcm_subformat_mask_set(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val)
2734 snd_mask_set((snd_mask_t *) mask, (unsigned long) val);
2738 * \brief make a subformat missing from a #snd_pcm_subformat_mask_t
2739 * \param mask pointer to mask
2740 * \param val subformat
2742 void snd_pcm_subformat_mask_reset(snd_pcm_subformat_mask_t *mask, snd_pcm_subformat_t val)
2744 snd_mask_reset((snd_mask_t *) mask, (unsigned long) val);
2749 * \brief get size of #snd_pcm_hw_params_t
2750 * \return size in bytes
2752 size_t snd_pcm_hw_params_sizeof()
2754 return sizeof(snd_pcm_hw_params_t);
2758 * \brief allocate an invalid #snd_pcm_hw_params_t using standard malloc
2759 * \param ptr returned pointer
2760 * \return 0 on success otherwise negative error code
2762 int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr)
2765 *ptr = calloc(1, sizeof(snd_pcm_hw_params_t));
2772 * \brief frees a previously allocated #snd_pcm_hw_params_t
2773 * \param pointer to object to free
2775 void snd_pcm_hw_params_free(snd_pcm_hw_params_t *obj)
2781 * \brief copy one #snd_pcm_hw_params_t to another
2782 * \param dst pointer to destination
2783 * \param src pointer to source
2785 void snd_pcm_hw_params_copy(snd_pcm_hw_params_t *dst, const snd_pcm_hw_params_t *src)
2793 * \brief Extract access type from a configuration space
2794 * \param params Configuration space
2795 * \param access Returned value
2796 * \return access type otherwise a negative error code if not exactly one is present
2798 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
2799 * to enable this new function prototype. Using of older function with same name is deprecated.
2802 int INTERNAL(snd_pcm_hw_params_get_access)(const snd_pcm_hw_params_t *params, snd_pcm_access_t *access)
2804 int snd_pcm_hw_params_get_access(const snd_pcm_hw_params_t *params, snd_pcm_access_t *access)
2808 int err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_ACCESS, &_val, NULL);
2815 * \brief Verify if an access type is available inside a configuration space for a PCM
2816 * \param pcm PCM handle
2817 * \param params Configuration space
2818 * \param access access type
2819 * \return 1 if available 0 otherwise
2821 int snd_pcm_hw_params_test_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access)
2823 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_ACCESS, access, 0);
2827 * \brief Restrict a configuration space to contain only one access type
2828 * \param pcm PCM handle
2829 * \param params Configuration space
2830 * \param access access type
2831 * \return 0 otherwise a negative error code if configuration space would become empty
2833 int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access)
2835 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, access, 0);
2839 * \brief Restrict a configuration space to contain only its first access type
2840 * \param pcm PCM handle
2841 * \param params Configuration space
2842 * \param access Returned first access type
2843 * \return 0 otherwise a negative error code
2845 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
2846 * to enable this new function prototype. Using of older function with same name is deprecated.
2849 int INTERNAL(snd_pcm_hw_params_set_access_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access)
2851 int snd_pcm_hw_params_set_access_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access)
2854 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_ACCESS, access, NULL);
2858 * \brief Restrict a configuration space to contain only its last access type
2859 * \param pcm PCM handle
2860 * \param params Configuration space
2861 * \param val Returned last access type
2862 * \return 0 otherwise a negative error code
2864 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
2865 * to enable this new function prototype. Using of older function with same name is deprecated.
2868 int INTERNAL(snd_pcm_hw_params_set_access_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access)
2870 int snd_pcm_hw_params_set_access_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t *access)
2873 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_ACCESS, access, NULL);
2877 * \brief Restrict a configuration space to contain only a set of access types
2878 * \param pcm PCM handle
2879 * \param params Configuration space
2880 * \param mask Access mask
2881 * \return 0 otherwise a negative error code
2883 int snd_pcm_hw_params_set_access_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask)
2885 return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_ACCESS, (snd_mask_t *) mask);
2889 * \brief Get access mask from a configuration space
2890 * \param params Configuration space
2891 * \param mask Returned Access mask
2893 int snd_pcm_hw_params_get_access_mask(snd_pcm_hw_params_t *params, snd_pcm_access_mask_t *mask)
2895 if (params == NULL || mask == NULL)
2897 snd_pcm_access_mask_copy(mask, snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_ACCESS));
2903 * \brief Extract format from a configuration space
2904 * \param params Configuration space
2905 * \param format returned format
2906 * \return format otherwise a negative error code if not exactly one is present
2908 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
2909 * to enable this new function prototype. Using of older function with same name is deprecated.
2912 int INTERNAL(snd_pcm_hw_params_get_format)(const snd_pcm_hw_params_t *params, snd_pcm_format_t *format)
2914 int snd_pcm_hw_params_get_format(const snd_pcm_hw_params_t *params, snd_pcm_format_t *format)
2917 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, format, NULL);
2921 * \brief Verify if a format is available inside a configuration space for a PCM
2922 * \param pcm PCM handle
2923 * \param params Configuration space
2924 * \param format format
2925 * \return 1 if available 0 otherwise
2927 int snd_pcm_hw_params_test_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t format)
2929 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_FORMAT, format, 0);
2933 * \brief Restrict a configuration space to contain only one format
2934 * \param pcm PCM handle
2935 * \param params Configuration space
2936 * \param format format
2937 * \return 0 otherwise a negative error code
2939 int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t format)
2941 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, format, 0);
2945 * \brief Restrict a configuration space to contain only its first format
2946 * \param pcm PCM handle
2947 * \param params Configuration space
2948 * \param format Returned first format
2949 * \return 0 otherwise a negative error code
2951 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
2952 * to enable this new function prototype. Using of older function with same name is deprecated.
2955 int INTERNAL(snd_pcm_hw_params_set_format_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format)
2957 int snd_pcm_hw_params_set_format_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format)
2960 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_FORMAT, format, NULL);
2964 * \brief Restrict a configuration space to contain only its last format
2965 * \param pcm PCM handle
2966 * \param params Configuration space
2967 * \param format Returned last format
2968 * \return 0 otherwise a negative error code
2970 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
2971 * to enable this new function prototype. Using of older function with same name is deprecated.
2974 int INTERNAL(snd_pcm_hw_params_set_format_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format)
2976 int snd_pcm_hw_params_set_format_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t *format)
2979 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_FORMAT, format, NULL);
2983 * \brief Restrict a configuration space to contain only a set of formats
2984 * \param pcm PCM handle
2985 * \param params Configuration space
2986 * \param mask Format mask
2987 * \return 0 otherwise a negative error code
2989 int snd_pcm_hw_params_set_format_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask)
2991 return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_FORMAT, (snd_mask_t *) mask);
2995 * \brief Get format mask from a configuration space
2996 * \param params Configuration space
2997 * \param mask Returned Format mask
2999 void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t *params, snd_pcm_format_mask_t *mask)
3001 snd_pcm_format_mask_copy(mask, snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_FORMAT));
3006 * \brief Extract subformat from a configuration space
3007 * \param params Configuration space
3008 * \param subformat Returned subformat value
3009 * \return subformat otherwise a negative error code if not exactly one is present
3011 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3012 * to enable this new function prototype. Using of older function with same name is deprecated.
3015 int INTERNAL(snd_pcm_hw_params_get_subformat)(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat)
3017 int snd_pcm_hw_params_get_subformat(const snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat)
3020 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_SUBFORMAT, subformat, NULL);
3024 * \brief Verify if a subformat is available inside a configuration space for a PCM
3025 * \param pcm PCM handle
3026 * \param params Configuration space
3027 * \param subformat subformat value
3028 * \return 1 if available 0 otherwise
3030 int snd_pcm_hw_params_test_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat)
3032 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_SUBFORMAT, subformat, 0);
3036 * \brief Restrict a configuration space to contain only one subformat
3037 * \param pcm PCM handle
3038 * \param params Configuration space
3039 * \param subformat subformat value
3040 * \return 0 otherwise a negative error code if configuration space would become empty
3042 int snd_pcm_hw_params_set_subformat(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t subformat)
3044 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, subformat, 0);
3048 * \brief Restrict a configuration space to contain only its first subformat
3049 * \param pcm PCM handle
3050 * \param params Configuration space
3051 * \param subformat Returned subformat
3052 * \return 0 otherwise a negative error code
3054 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3055 * to enable this new function prototype. Using of older function with same name is deprecated.
3058 int INTERNAL(snd_pcm_hw_params_set_subformat_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat)
3060 int snd_pcm_hw_params_set_subformat_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat)
3063 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, subformat, NULL);
3067 * \brief Restrict a configuration space to contain only its last subformat
3068 * \param pcm PCM handle
3069 * \param params Configuration space
3070 * \param subformat Returned subformat
3071 * \return 0 otherwise a negative error code
3073 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3074 * to enable this new function prototype. Using of older function with same name is deprecated.
3077 int INTERNAL(snd_pcm_hw_params_set_subformat_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat)
3079 int snd_pcm_hw_params_set_subformat_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_t *subformat)
3082 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_SUBFORMAT, subformat, NULL);
3086 * \brief Restrict a configuration space to contain only a set of subformats
3087 * \param pcm PCM handle
3088 * \param params Configuration space
3089 * \param mask Subformat mask
3090 * \return 0 otherwise a negative error code
3092 int snd_pcm_hw_params_set_subformat_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask)
3094 return snd_pcm_hw_param_set_mask(pcm, params, SND_TRY, SND_PCM_HW_PARAM_SUBFORMAT, (snd_mask_t *) mask);
3098 * \brief Get subformat mask from a configuration space
3099 * \param params Configuration space
3100 * \param mask Returned Subformat mask
3102 void snd_pcm_hw_params_get_subformat_mask(snd_pcm_hw_params_t *params, snd_pcm_subformat_mask_t *mask)
3104 snd_pcm_subformat_mask_copy(mask, snd_pcm_hw_param_get_mask(params, SND_PCM_HW_PARAM_SUBFORMAT));
3109 * \brief Extract channels from a configuration space
3110 * \param params Configuration space
3111 * \param val Returned channels count
3112 * \return 0 otherwise a negative error code if not exactly one is present
3114 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3115 * to enable this new function prototype. Using of older function with same name is deprecated.
3118 int INTERNAL(snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *params, unsigned int *val)
3120 int snd_pcm_hw_params_get_channels(const snd_pcm_hw_params_t *params, unsigned int *val)
3123 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3127 * \brief Extract minimum channels count from a configuration space
3128 * \param params Configuration space
3129 * \param val minimum channels count
3130 * \return 0 otherwise a negative error code
3132 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3133 * to enable this new function prototype. Using of older function with same name is deprecated.
3136 int INTERNAL(snd_pcm_hw_params_get_channels_min)(const snd_pcm_hw_params_t *params, unsigned int *val)
3138 int snd_pcm_hw_params_get_channels_min(const snd_pcm_hw_params_t *params, unsigned int *val)
3141 return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3145 * \brief Extract maximum channels count from a configuration space
3146 * \param params Configuration space
3147 * \param val maximum channels count
3148 * \return 0 otherwise a negative error code
3150 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3151 * to enable this new function prototype. Using of older function with same name is deprecated.
3154 int INTERNAL(snd_pcm_hw_params_get_channels_max)(const snd_pcm_hw_params_t *params, unsigned int *val)
3156 int snd_pcm_hw_params_get_channels_max(const snd_pcm_hw_params_t *params, unsigned int *val)
3159 return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3163 * \brief Verify if a channels count is available inside a configuration space for a PCM
3164 * \param pcm PCM handle
3165 * \param params Configuration space
3166 * \param val channels count
3167 * \return 1 if available 0 otherwise
3169 int snd_pcm_hw_params_test_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
3171 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_CHANNELS, val, 0);
3175 * \brief Restrict a configuration space to contain only one channels count
3176 * \param pcm PCM handle
3177 * \param params Configuration space
3178 * \param val channels count
3179 * \return 0 otherwise a negative error code if configuration space would become empty
3181 int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
3183 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, 0);
3187 * \brief Restrict a configuration space with a minimum channels count
3188 * \param pcm PCM handle
3189 * \param params Configuration space
3190 * \param val minimum channels count (on return filled with actual minimum)
3191 * \return 0 otherwise a negative error code if configuration space would become empty
3193 int snd_pcm_hw_params_set_channels_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3195 return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3199 * \brief Restrict a configuration space with a maximum channels count
3200 * \param pcm PCM handle
3201 * \param params Configuration space
3202 * \param val maximum channels count (on return filled with actual maximum)
3203 * \return 0 otherwise a negative error code if configuration space would become empty
3205 int snd_pcm_hw_params_set_channels_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3207 return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3211 * \brief Restrict a configuration space to have channels counts in a given range
3212 * \param pcm PCM handle
3213 * \param params Configuration space
3214 * \param min minimum channels count (on return filled with actual minimum)
3215 * \param max maximum channels count (on return filled with actual maximum)
3216 * \return 0 otherwise a negative error code if configuration space would become empty
3218 int snd_pcm_hw_params_set_channels_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, unsigned int *max)
3220 return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_CHANNELS, min, NULL, max, NULL);
3224 * \brief Restrict a configuration space to have channels count nearest to a target
3225 * \param pcm PCM handle
3226 * \param params Configuration space
3227 * \param val target channels count, returned chosen channels count
3228 * \return chosen channels count
3230 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3231 * to enable this new function prototype. Using of older function with same name is deprecated.
3234 int INTERNAL(snd_pcm_hw_params_set_channels_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3236 int snd_pcm_hw_params_set_channels_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3239 return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3243 * \brief Restrict a configuration space to contain only its minimum channels count
3244 * \param pcm PCM handle
3245 * \param params Configuration space
3246 * \param val minimum channels count
3247 * \return 0 otherwise a negative error code
3249 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3250 * to enable this new function prototype. Using of older function with same name is deprecated.
3253 int INTERNAL(snd_pcm_hw_params_set_channels_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3255 int snd_pcm_hw_params_set_channels_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3258 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3262 * \brief Restrict a configuration space to contain only its maximum channels count
3263 * \param pcm PCM handle
3264 * \param params Configuration space
3265 * \param val maximum channels count
3266 * \return 0 otherwise a negative error code
3268 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3269 * to enable this new function prototype. Using of older function with same name is deprecated.
3272 int INTERNAL(snd_pcm_hw_params_set_channels_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3274 int snd_pcm_hw_params_set_channels_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)
3277 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_CHANNELS, val, NULL);
3282 * \brief Extract rate from a configuration space
3283 * \param params Configuration space
3284 * \param val Returned approximate rate
3285 * \param dir Sub unit direction
3286 * \return 0 otherwise a negative error code if not exactly one is present
3288 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3290 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3291 * to enable this new function prototype. Using of older function with same name is deprecated.
3294 int INTERNAL(snd_pcm_hw_params_get_rate)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3296 int snd_pcm_hw_params_get_rate(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3299 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_RATE, val, dir);
3303 * \brief Extract minimum rate from a configuration space
3304 * \param params Configuration space
3305 * \param val Returned approximate minimum rate
3306 * \param dir Sub unit direction
3307 * \return 0 otherwise a negative error code
3309 * Exact value is <,=,> the returned one following dir (-1,0,1)
3311 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3312 * to enable this new function prototype. Using of older function with same name is deprecated.
3315 int INTERNAL(snd_pcm_hw_params_get_rate_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3317 int snd_pcm_hw_params_get_rate_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3320 return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_RATE, val, dir);
3324 * \brief Extract maximum rate from a configuration space
3325 * \param params Configuration space
3326 * \param val Returned approximate maximum rate
3327 * \param dir Sub unit direction
3328 * \return 0 otherwise a negative error code
3330 * Exact value is <,=,> the returned one following dir (-1,0,1)
3332 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3333 * to enable this new function prototype. Using of older function with same name is deprecated.
3336 int INTERNAL(snd_pcm_hw_params_get_rate_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3338 int snd_pcm_hw_params_get_rate_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3341 return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_RATE, val, dir);
3345 * \brief Verify if a rate is available inside a configuration space for a PCM
3346 * \param pcm PCM handle
3347 * \param params Configuration space
3348 * \param val approximate rate
3349 * \param dir Sub unit direction
3350 * \return 1 if available 0 otherwise
3352 * Wanted exact value is <,=,> val following dir (-1,0,1)
3354 int snd_pcm_hw_params_test_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
3356 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_RATE, val, dir);
3360 * \brief Restrict a configuration space to contain only one rate
3361 * \param pcm PCM handle
3362 * \param params Configuration space
3363 * \param val approximate rate
3364 * \param dir Sub unit direction
3365 * \return 0 otherwise a negative error code if configuration space would become empty
3367 * Wanted exact value is <,=,> val following dir (-1,0,1)
3369 int snd_pcm_hw_params_set_rate(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
3371 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir);
3375 * \brief Restrict a configuration space with a minimum rate
3376 * \param pcm PCM handle
3377 * \param params Configuration space
3378 * \param val approximate minimum rate (on return filled with actual minimum)
3379 * \param dir Sub unit direction (on return filled with actual direction)
3380 * \return 0 otherwise a negative error code if configuration space would become empty
3382 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
3384 int snd_pcm_hw_params_set_rate_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3386 return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir);
3390 * \brief Restrict a configuration space with a maximum rate
3391 * \param pcm PCM handle
3392 * \param params Configuration space
3393 * \param val approximate maximum rate (on return filled with actual maximum)
3394 * \param dir Sub unit direction (on return filled with actual direction)
3395 * \return 0 otherwise a negative error code if configuration space would become empty
3397 * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1)
3399 int snd_pcm_hw_params_set_rate_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3401 return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, val, dir);
3405 * \brief Restrict a configuration space to have rates in a given range
3406 * \param pcm PCM handle
3407 * \param params Configuration space
3408 * \param min approximate minimum rate (on return filled with actual minimum)
3409 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
3410 * \param max approximate maximum rate (on return filled with actual maximum)
3411 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
3412 * \return 0 otherwise a negative error code if configuration space would become empty
3414 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
3416 int snd_pcm_hw_params_set_rate_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir)
3418 return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_RATE, min, mindir, max, maxdir);
3422 * \brief Restrict a configuration space to have rate nearest to a target
3423 * \param pcm PCM handle
3424 * \param params Configuration space
3425 * \param val approximate target rate / returned approximate set rate
3426 * \return approximate chosen rate
3428 * target/chosen exact value is <,=,> val following dir (-1,0,1)
3430 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3431 * to enable this new function prototype. Using of older function with same name is deprecated.
3434 int INTERNAL(snd_pcm_hw_params_set_rate_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3436 int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3439 return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_RATE, val, dir);
3443 * \brief Restrict a configuration space to contain only its minimum rate
3444 * \param pcm PCM handle
3445 * \param params Configuration space
3446 * \param val Returned minimum approximate rate
3447 * \param dir Sub unit direction
3448 * \return 0 otherwise a negative error code
3450 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3452 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3453 * to enable this new function prototype. Using of older function with same name is deprecated.
3456 int INTERNAL(snd_pcm_hw_params_set_rate_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3458 int snd_pcm_hw_params_set_rate_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3461 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_RATE, val, dir);
3465 * \brief Restrict a configuration space to contain only its maximum rate
3466 * \param pcm PCM handle
3467 * \param params Configuration space
3468 * \param val Returned maximum approximate rate
3469 * \param dir Sub unit direction
3470 * \return 0 otherwise a negative error code
3472 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3474 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3475 * to enable this new function prototype. Using of older function with same name is deprecated.
3478 int INTERNAL(snd_pcm_hw_params_set_rate_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3480 int snd_pcm_hw_params_set_rate_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3483 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_RATE, val, dir);
3488 * \brief Extract period time from a configuration space
3489 * \param params Configuration space
3490 * \param val Returned approximate period duration in us
3491 * \param dir Sub unit direction
3492 * \return 0 otherwise a negative error code if not exactly one is present
3494 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3496 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3497 * to enable this new function prototype. Using of older function with same name is deprecated.
3500 int INTERNAL(snd_pcm_hw_params_get_period_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3502 int snd_pcm_hw_params_get_period_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3505 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3509 * \brief Extract minimum period time from a configuration space
3510 * \param params Configuration space
3511 * \param val approximate minimum period duration in us
3512 * \param dir Sub unit direction
3513 * \return 0 otherwise a negative error code
3515 * Exact value is <,=,> the returned one following dir (-1,0,1)
3517 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3518 * to enable this new function prototype. Using of older function with same name is deprecated.
3521 int INTERNAL(snd_pcm_hw_params_get_period_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3523 int snd_pcm_hw_params_get_period_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3526 return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3530 * \brief Extract maximum period time from a configuration space
3531 * \param params Configuration space
3532 * \param val approximate maximum period duration in us
3533 * \param dir Sub unit direction
3534 * \return 0 otherwise a negative error code
3536 * Exact value is <,=,> the returned one following dir (-1,0,1)
3538 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3539 * to enable this new function prototype. Using of older function with same name is deprecated.
3542 int INTERNAL(snd_pcm_hw_params_get_period_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3544 int snd_pcm_hw_params_get_period_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3547 return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3551 * \brief Verify if a period time is available inside a configuration space for a PCM
3552 * \param pcm PCM handle
3553 * \param params Configuration space
3554 * \param val approximate period duration in us
3555 * \param dir Sub unit direction
3556 * \return 1 if available 0 otherwise
3558 * Wanted exact value is <,=,> val following dir (-1,0,1)
3560 int snd_pcm_hw_params_test_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
3562 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3566 * \brief Restrict a configuration space to contain only one period time
3567 * \param pcm PCM handle
3568 * \param params Configuration space
3569 * \param val approximate period duration in us
3570 * \param dir Sub unit direction
3571 * \return 0 otherwise a negative error code if configuration space would become empty
3573 * Wanted exact value is <,=,> val following dir (-1,0,1)
3575 int snd_pcm_hw_params_set_period_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
3577 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3582 * \brief Restrict a configuration space with a minimum period time
3583 * \param pcm PCM handle
3584 * \param params Configuration space
3585 * \param val approximate minimum period duration in us (on return filled with actual minimum)
3586 * \param dir Sub unit direction (on return filled with actual direction)
3587 * \return 0 otherwise a negative error code if configuration space would become empty
3589 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
3591 int snd_pcm_hw_params_set_period_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3593 return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3597 * \brief Restrict a configuration space with a maximum period time
3598 * \param pcm PCM handle
3599 * \param params Configuration space
3600 * \param val approximate maximum period duration in us (on return filled with actual maximum)
3601 * \param dir Sub unit direction (on return filled with actual direction)
3602 * \return 0 otherwise a negative error code if configuration space would become empty
3604 * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1)
3606 int snd_pcm_hw_params_set_period_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3608 return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3612 * \brief Restrict a configuration space to have period times in a given range
3613 * \param pcm PCM handle
3614 * \param params Configuration space
3615 * \param min approximate minimum period duration in us (on return filled with actual minimum)
3616 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
3617 * \param max approximate maximum period duration in us (on return filled with actual maximum)
3618 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
3619 * \return 0 otherwise a negative error code if configuration space would become empty
3621 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
3623 int snd_pcm_hw_params_set_period_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir)
3625 return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_TIME, min, mindir, max, maxdir);
3629 * \brief Restrict a configuration space to have period time nearest to a target
3630 * \param pcm PCM handle
3631 * \param params Configuration space
3632 * \param val approximate target period duration in us / returned chosen approximate target period duration
3633 * \return approximate chosen period duration in us
3635 * target/chosen exact value is <,=,> val following dir (-1,0,1)
3637 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3638 * to enable this new function prototype. Using of older function with same name is deprecated.
3641 int INTERNAL(snd_pcm_hw_params_set_period_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3643 int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3646 return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3650 * \brief Restrict a configuration space to contain only its minimum period time
3651 * \param pcm PCM handle
3652 * \param params Configuration space
3653 * \param val Returned approximate period duration in us
3654 * \param dir Sub unit direction
3655 * \return 0 otherwise a negative error code
3657 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3659 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3660 * to enable this new function prototype. Using of older function with same name is deprecated.
3663 int INTERNAL(snd_pcm_hw_params_set_period_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3665 int snd_pcm_hw_params_set_period_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3668 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3672 * \brief Restrict a configuration space to contain only its maximum period time
3673 * \param pcm PCM handle
3674 * \param params Configuration space
3675 * \param dir Sub unit direction
3676 * \return approximate period duration in us
3678 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3680 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3681 * to enable this new function prototype. Using of older function with same name is deprecated.
3684 int INTERNAL(snd_pcm_hw_params_set_period_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3686 int snd_pcm_hw_params_set_period_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3689 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, val, dir);
3694 * \brief Extract period size from a configuration space
3695 * \param params Configuration space
3696 * \param val Returned approximate period size in frames
3697 * \param dir Sub unit direction
3698 * \return 0 otherwise a negative error code if not exactly one is present
3700 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3702 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3703 * to enable this new function prototype. Using of older function with same name is deprecated.
3706 int INTERNAL(snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3708 int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3712 int err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3719 * \brief Extract minimum period size from a configuration space
3720 * \param params Configuration space
3721 * \param val approximate minimum period size in frames
3722 * \param dir Sub unit direction
3723 * \return 0 otherwise a negative error code
3725 * Exact value is <,=,> the returned one following dir (-1,0,1)
3727 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3728 * to enable this new function prototype. Using of older function with same name is deprecated.
3731 int INTERNAL(snd_pcm_hw_params_get_period_size_min)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3733 int snd_pcm_hw_params_get_period_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3736 unsigned int _val = *val;
3737 int err = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3744 * \brief Extract maximum period size from a configuration space
3745 * \param params Configuration space
3746 * \param val approximate minimum period size in frames
3747 * \param dir Sub unit direction
3748 * \return 0 otherwise a negative error code
3750 * Exact value is <,=,> the returned one following dir (-1,0,1)
3752 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3753 * to enable this new function prototype. Using of older function with same name is deprecated.
3756 int INTERNAL(snd_pcm_hw_params_get_period_size_max)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3758 int snd_pcm_hw_params_get_period_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3761 unsigned int _val = *val;
3762 int err = snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3769 * \brief Verify if a period size is available inside a configuration space for a PCM
3770 * \param pcm PCM handle
3771 * \param params Configuration space
3772 * \param val approximate period size in frames
3773 * \param dir Sub unit direction
3774 * \return 1 if available 0 otherwise
3776 * Wanted exact value is <,=,> val following dir (-1,0,1)
3778 int snd_pcm_hw_params_test_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir)
3780 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir);
3784 * \brief Restrict a configuration space to contain only one period size
3785 * \param pcm PCM handle
3786 * \param params Configuration space
3787 * \param val approximate period size in frames
3788 * \param dir Sub unit direction
3789 * \return 0 otherwise a negative error code if configuration space would become empty
3791 * Wanted exact value is <,=,> val following dir (-1,0,1)
3793 int snd_pcm_hw_params_set_period_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir)
3795 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, val, dir);
3799 * \brief Restrict a configuration space with a minimum period size
3800 * \param pcm PCM handle
3801 * \param params Configuration space
3802 * \param val approximate minimum period size in frames (on return filled with actual minimum)
3803 * \param dir Sub unit direction (on return filled with actual direction)
3804 * \return 0 otherwise a negative error code if configuration space would become empty
3806 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
3808 int snd_pcm_hw_params_set_period_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3810 unsigned int _val = *val;
3811 int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3818 * \brief Restrict a configuration space with a maximum period size
3819 * \param pcm PCM handle
3820 * \param params Configuration space
3821 * \param val approximate maximum period size in frames (on return filled with actual maximum)
3822 * \param dir Sub unit direction (on return filled with actual direction)
3823 * \return 0 otherwise a negative error code if configuration space would become empty
3825 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
3827 int snd_pcm_hw_params_set_period_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3829 unsigned int _val = *val;
3830 int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3837 * \brief Restrict a configuration space to have period sizes in a given range
3838 * \param pcm PCM handle
3839 * \param params Configuration space
3840 * \param min approximate minimum period size in frames (on return filled with actual minimum)
3841 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
3842 * \param max approximate maximum period size in frames (on return filled with actual maximum)
3843 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
3844 * \return 0 otherwise a negative error code if configuration space would become empty
3846 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
3848 int snd_pcm_hw_params_set_period_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *min, int *mindir, snd_pcm_uframes_t *max, int *maxdir)
3850 unsigned int _min = *min;
3851 unsigned int _max = *max;
3852 int err = snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE, &_min, mindir, &_max, maxdir);
3859 * \brief Restrict a configuration space to have period size nearest to a target
3860 * \param pcm PCM handle
3861 * \param params Configuration space
3862 * \param val approximate target period size in frames / returned chosen approximate target period size
3863 * \return 0 otherwise a negative error code
3865 * target/chosen exact value is <,=,> val following dir (-1,0,1)
3867 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3868 * to enable this new function prototype. Using of older function with same name is deprecated.
3871 int INTERNAL(snd_pcm_hw_params_set_period_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3873 int snd_pcm_hw_params_set_period_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3876 unsigned int _val = *val;
3877 int err = snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3884 * \brief Restrict a configuration space to contain only its minimum period size
3885 * \param pcm PCM handle
3886 * \param params Configuration space
3887 * \param val Returned maximum approximate period size in frames
3888 * \param dir Sub unit direction
3889 * \return 0 otherwise a negative error code
3891 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3893 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3894 * to enable this new function prototype. Using of older function with same name is deprecated.
3897 int INTERNAL(snd_pcm_hw_params_set_period_size_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3899 int snd_pcm_hw_params_set_period_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3903 int err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3910 * \brief Restrict a configuration space to contain only its maximum period size
3911 * \param pcm PCM handle
3912 * \param params Configuration space
3913 * \param val Returned maximum approximate period size in frames
3914 * \param dir Sub unit direction
3915 * \return 0 otherwise a negative error code
3917 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3919 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3920 * to enable this new function prototype. Using of older function with same name is deprecated.
3923 int INTERNAL(snd_pcm_hw_params_set_period_size_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3925 int snd_pcm_hw_params_set_period_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir)
3929 int err = snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, &_val, dir);
3936 * \brief Restrict a configuration space to contain only integer period sizes
3937 * \param pcm PCM handle
3938 * \param params Configuration space
3939 * \return 0 otherwise a negative error code if configuration space would become empty
3941 int snd_pcm_hw_params_set_period_size_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
3943 return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIOD_SIZE);
3948 * \brief Extract periods from a configuration space
3949 * \param params Configuration space
3950 * \param val approximate periods per buffer
3951 * \param dir Sub unit direction
3952 * \return 0 otherwise a negative error code if not exactly one is present
3954 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
3956 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3957 * to enable this new function prototype. Using of older function with same name is deprecated.
3960 int INTERNAL(snd_pcm_hw_params_get_periods)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3962 int snd_pcm_hw_params_get_periods(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3965 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_PERIODS, val, dir);
3969 * \brief Extract minimum periods count from a configuration space
3970 * \param params Configuration space
3971 * \param val approximate minimum periods per buffer
3972 * \param dir Sub unit direction
3973 * \return 0 otherwise a negative error code
3975 * Exact value is <,=,> the returned one following dir (-1,0,1)
3977 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3978 * to enable this new function prototype. Using of older function with same name is deprecated.
3981 int INTERNAL(snd_pcm_hw_params_get_periods_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3983 int snd_pcm_hw_params_get_periods_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
3986 return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_PERIODS, val, dir);
3990 * \brief Extract maximum periods count from a configuration space
3991 * \param params Configuration space
3992 * \param val approximate maximum periods per buffer
3993 * \param dir Sub unit direction
3994 * \return 0 otherwise a negative error code
3996 * Exact value is <,=,> the returned one following dir (-1,0,1)
3998 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
3999 * to enable this new function prototype. Using of older function with same name is deprecated.
4002 int INTERNAL(snd_pcm_hw_params_get_periods_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4004 int snd_pcm_hw_params_get_periods_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4007 return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_PERIODS, val, dir);
4011 * \brief Verify if a periods count is available inside a configuration space for a PCM
4012 * \param pcm PCM handle
4013 * \param params Configuration space
4014 * \param val approximate periods per buffer
4015 * \param dir Sub unit direction
4016 * \return 1 if available 0 otherwise
4018 * Wanted exact value is <,=,> val following dir (-1,0,1)
4020 int snd_pcm_hw_params_test_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
4022 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_PERIODS, val, dir);
4026 * \brief Restrict a configuration space to contain only one periods count
4027 * \param pcm PCM handle
4028 * \param params Configuration space
4029 * \param val approximate periods per buffer
4030 * \param dir Sub unit direction
4031 * \return 0 otherwise a negative error code if configuration space would become empty
4033 * Wanted exact value is <,=,> val following dir (-1,0,1)
4035 int snd_pcm_hw_params_set_periods(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
4037 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir);
4041 * \brief Restrict a configuration space with a minimum periods count
4042 * \param pcm PCM handle
4043 * \param params Configuration space
4044 * \param val approximate minimum periods per buffer (on return filled with actual minimum)
4045 * \param dir Sub unit direction (on return filled with actual direction)
4046 * \return 0 otherwise a negative error code if configuration space would become empty
4048 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
4050 int snd_pcm_hw_params_set_periods_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4052 return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir);
4056 * \brief Restrict a configuration space with a maximum periods count
4057 * \param pcm PCM handle
4058 * \param params Configuration space
4059 * \param val approximate maximum periods per buffer (on return filled with actual maximum)
4060 * \param dir Sub unit direction (on return filled with actual direction)
4061 * \return 0 otherwise a negative error code if configuration space would become empty
4063 * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1)
4065 int snd_pcm_hw_params_set_periods_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4067 return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, val, dir);
4071 * \brief Restrict a configuration space to have periods counts in a given range
4072 * \param pcm PCM handle
4073 * \param params Configuration space
4074 * \param min approximate minimum periods per buffer (on return filled with actual minimum)
4075 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
4076 * \param max approximate maximum periods per buffer (on return filled with actual maximum)
4077 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
4078 * \return 0 otherwise a negative error code if configuration space would become empty
4080 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
4082 int snd_pcm_hw_params_set_periods_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir)
4084 return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS, min, mindir, max, maxdir);
4088 * \brief Restrict a configuration space to have periods count nearest to a target
4089 * \param pcm PCM handle
4090 * \param params Configuration space
4091 * \param val approximate target periods per buffer / returned chosen approximate target periods per buffer
4092 * \return approximate chosen periods per buffer
4094 * target/chosen exact value is <,=,> val following dir (-1,0,1)
4096 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4097 * to enable this new function prototype. Using of older function with same name is deprecated.
4100 int INTERNAL(snd_pcm_hw_params_set_periods_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4102 int snd_pcm_hw_params_set_periods_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4105 return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_PERIODS, val, dir);
4109 * \brief Restrict a configuration space to contain only its minimum periods count
4110 * \param pcm PCM handle
4111 * \param params Configuration space
4112 * \param val Returned approximate minimum periods per buffer
4113 * \param dir Sub unit direction
4114 * \return 0 otherwise a negative error code
4116 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4118 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4119 * to enable this new function prototype. Using of older function with same name is deprecated.
4122 int INTERNAL(snd_pcm_hw_params_set_periods_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4124 int snd_pcm_hw_params_set_periods_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4127 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIODS, val, dir);
4131 * \brief Restrict a configuration space to contain only its maximum periods count
4132 * \param pcm PCM handle
4133 * \param params Configuration space
4134 * \param val Returned approximate maximum periods per buffer
4135 * \param dir Sub unit direction
4136 * \return 0 otherwise a negative error code
4138 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4140 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4141 * to enable this new function prototype. Using of older function with same name is deprecated.
4144 int INTERNAL(snd_pcm_hw_params_set_periods_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4146 int snd_pcm_hw_params_set_periods_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4149 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_PERIODS, val, dir);
4153 * \brief Restrict a configuration space to contain only integer periods counts
4154 * \param pcm PCM handle
4155 * \param params Configuration space
4156 * \return 0 otherwise a negative error code if configuration space would become empty
4158 int snd_pcm_hw_params_set_periods_integer(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
4160 return snd_pcm_hw_param_set_integer(pcm, params, SND_TRY, SND_PCM_HW_PARAM_PERIODS);
4165 * \brief Extract buffer time from a configuration space
4166 * \param params Configuration space
4167 * \param approximate buffer duration in us
4168 * \param val Returned buffer time in us
4169 * \param dir Sub unit direction
4170 * \return 0 otherwise a negative error code if not exactly one is present
4172 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4174 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4175 * to enable this new function prototype. Using of older function with same name is deprecated.
4178 int INTERNAL(snd_pcm_hw_params_get_buffer_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4180 int snd_pcm_hw_params_get_buffer_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4183 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4187 * \brief Extract minimum buffer time from a configuration space
4188 * \param params Configuration space
4189 * \param val approximate minimum buffer duration in us
4190 * \param dir Sub unit direction
4191 * \return 0 otherwise a negative error code
4193 * Exact value is <,=,> the returned one following dir (-1,0,1)
4195 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4196 * to enable this new function prototype. Using of older function with same name is deprecated.
4199 int INTERNAL(snd_pcm_hw_params_get_buffer_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4201 int snd_pcm_hw_params_get_buffer_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4204 return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4208 * \brief Extract maximum buffer time from a configuration space
4209 * \param params Configuration space
4210 * \param val approximate maximum buffer duration in us
4211 * \param dir Sub unit direction
4212 * \return 0 otherwise a negative error code
4214 * Exact value is <,=,> the returned one following dir (-1,0,1)
4216 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4217 * to enable this new function prototype. Using of older function with same name is deprecated.
4220 int INTERNAL(snd_pcm_hw_params_get_buffer_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4222 int snd_pcm_hw_params_get_buffer_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4225 return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4229 * \brief Verify if a buffer time is available inside a configuration space for a PCM
4230 * \param pcm PCM handle
4231 * \param params Configuration space
4232 * \param val approximate buffer duration in us
4233 * \param dir Sub unit direction
4234 * \return 1 if available 0 otherwise
4236 * Wanted exact value is <,=,> val following dir (-1,0,1)
4238 int snd_pcm_hw_params_test_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
4240 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4244 * \brief Restrict a configuration space to contain only one buffer time
4245 * \param pcm PCM handle
4246 * \param params Configuration space
4247 * \param val approximate buffer duration in us
4248 * \param dir Sub unit direction
4249 * \return 0 otherwise a negative error code if configuration space would become empty
4251 * Wanted exact value is <,=,> val following dir (-1,0,1)
4253 int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
4255 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4259 * \brief Restrict a configuration space with a minimum buffer time
4260 * \param pcm PCM handle
4261 * \param params Configuration space
4262 * \param val approximate minimum buffer duration in us (on return filled with actual minimum)
4263 * \param dir Sub unit direction (on return filled with actual direction)
4264 * \return 0 otherwise a negative error code if configuration space would become empty
4266 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
4268 int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4270 return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4274 * \brief Restrict a configuration space with a maximum buffer time
4275 * \param pcm PCM handle
4276 * \param params Configuration space
4277 * \param val approximate maximum buffer duration in us (on return filled with actual maximum)
4278 * \param dir Sub unit direction (on return filled with actual direction)
4279 * \return 0 otherwise a negative error code if configuration space would become empty
4281 * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1)
4283 int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4285 return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4289 * \brief Restrict a configuration space to have buffer times in a given range
4290 * \param pcm PCM handle
4291 * \param params Configuration space
4292 * \param min approximate minimum buffer duration in us (on return filled with actual minimum)
4293 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
4294 * \param max approximate maximum buffer duration in us (on return filled with actual maximum)
4295 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
4296 * \return 0 otherwise a negative error code if configuration space would become empty
4298 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
4300 int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir)
4302 return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_TIME, min, mindir, max, maxdir);
4306 * \brief Restrict a configuration space to have buffer time nearest to a target
4307 * \param pcm PCM handle
4308 * \param params Configuration space
4309 * \param val approximate target buffer duration in us / returned chosen approximate target buffer duration
4310 * \return approximate chosen buffer duration in us
4312 * target/chosen exact value is <,=,> val following dir (-1,0,1)
4314 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4315 * to enable this new function prototype. Using of older function with same name is deprecated.
4318 int INTERNAL(snd_pcm_hw_params_set_buffer_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4320 int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4323 return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4327 * \brief Restrict a configuration space to contain only its minimum buffer time
4328 * \param pcm PCM handle
4329 * \param params Configuration space
4330 * \param val Returned approximate minimum buffer duration in us
4331 * \param dir Sub unit direction
4332 * \return 0 otherwise a negative error code
4334 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4336 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4337 * to enable this new function prototype. Using of older function with same name is deprecated.
4340 int INTERNAL(snd_pcm_hw_params_set_buffer_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4342 int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4345 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4349 * \brief Restrict a configuration space to contain only its maximum buffered time
4350 * \param pcm PCM handle
4351 * \param params Configuration space
4352 * \param val Returned approximate maximum buffer duration in us
4353 * \param dir Sub unit direction
4354 * \return 0 otherwise a negative error code
4356 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4358 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4359 * to enable this new function prototype. Using of older function with same name is deprecated.
4362 int INTERNAL(snd_pcm_hw_params_set_buffer_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4364 int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4367 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_TIME, val, dir);
4372 * \brief Extract buffer size from a configuration space
4373 * \param params Configuration space
4374 * \param val Returned buffer size in frames
4375 * \return 0 otherwise a negative error code if not exactly one is present
4377 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4378 * to enable this new function prototype. Using of older function with same name is deprecated.
4381 int INTERNAL(snd_pcm_hw_params_get_buffer_size)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4383 int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4387 int err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4394 * \brief Extract minimum buffer size from a configuration space
4395 * \param params Configuration space
4396 * \param val Returned approximate minimum buffer size in frames
4397 * \param dir Sub unit direction
4398 * \return 0 otherwise a negative error code
4400 * Exact value is <,=,> the returned one following dir (-1,0,1)
4402 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4403 * to enable this new function prototype. Using of older function with same name is deprecated.
4406 int INTERNAL(snd_pcm_hw_params_get_buffer_size_min)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4408 int snd_pcm_hw_params_get_buffer_size_min(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4412 int err = snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4419 * \brief Extract maximum buffer size from a configuration space
4420 * \param params Configuration space
4421 * \param val Returned approximate maximum buffer size in frames
4422 * \param dir Sub unit direction
4423 * \return 0 otherwise a negative error code
4425 * Exact value is <,=,> the returned one following dir (-1,0,1)
4427 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4428 * to enable this new function prototype. Using of older function with same name is deprecated.
4431 int INTERNAL(snd_pcm_hw_params_get_buffer_size_max)(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4433 int snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4437 int err = snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4444 * \brief Verify if a buffer size is available inside a configuration space for a PCM
4445 * \param pcm PCM handle
4446 * \param params Configuration space
4447 * \param val buffer size in frames
4448 * \param dir Sub unit direction
4449 * \return 1 if available 0 otherwise
4451 * Wanted exact value is <,=,> val following dir (-1,0,1)
4453 int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val)
4455 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0);
4459 * \brief Restrict a configuration space to contain only one buffer size
4460 * \param pcm PCM handle
4461 * \param params Configuration space
4462 * \param val buffer size in frames
4463 * \return 0 otherwise a negative error code if configuration space would become empty
4465 * Wanted exact value is <,=,> val following dir (-1,0,1)
4467 int snd_pcm_hw_params_set_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val)
4469 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, val, 0);
4473 * \brief Restrict a configuration space with a minimum buffer size
4474 * \param pcm PCM handle
4475 * \param params Configuration space
4476 * \param val approximate minimum buffer size in frames (on return filled with actual minimum)
4477 * \param dir Sub unit direction (on return filled with actual direction)
4478 * \return 0 otherwise a negative error code if configuration space would become empty
4480 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
4482 int snd_pcm_hw_params_set_buffer_size_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4484 unsigned int _val = *val;
4485 int err = snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4492 * \brief Restrict a configuration space with a maximum buffer size
4493 * \param pcm PCM handle
4494 * \param params Configuration space
4495 * \param val approximate maximum buffer size in frames (on return filled with actual maximum)
4496 * \param dir Sub unit direction (on return filled with actual direction)
4497 * \return 0 otherwise a negative error code if configuration space would become empty
4499 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
4501 int snd_pcm_hw_params_set_buffer_size_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4503 unsigned int _val = *val;
4504 int err = snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4511 * \brief Restrict a configuration space to have buffer sizes in a given range
4512 * \param pcm PCM handle
4513 * \param params Configuration space
4514 * \param min approximate minimum buffer size in frames (on return filled with actual minimum)
4515 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
4516 * \param max approximate maximum buffer size in frames (on return filled with actual maximum)
4517 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
4518 * \return 0 otherwise a negative error code if configuration space would become empty
4520 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
4522 int snd_pcm_hw_params_set_buffer_size_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *min, snd_pcm_uframes_t *max)
4524 unsigned int _min = *min;
4525 unsigned int _max = *max;
4526 int err = snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_BUFFER_SIZE, &_min, NULL, &_max, NULL);
4533 * \brief Restrict a configuration space to have buffer size nearest to a target
4534 * \param pcm PCM handle
4535 * \param params Configuration space
4536 * \param val approximate target buffer size in frames / returned chosen approximate target buffer size in frames
4537 * \return approximate chosen buffer size in frames
4539 * target/chosen exact value is <,=,> val following dir (-1,0,1)
4541 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4542 * to enable this new function prototype. Using of older function with same name is deprecated.
4545 int INTERNAL(snd_pcm_hw_params_set_buffer_size_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4547 int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4550 unsigned int _val = *val;
4551 int err = snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4558 * \brief Restrict a configuration space to contain only its minimum buffer size
4559 * \param pcm PCM handle
4560 * \param params Configuration space
4561 * \param val Returned minimum buffer size in frames
4562 * \return buffer size in frames
4564 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4565 * to enable this new function prototype. Using of older function with same name is deprecated.
4568 int INTERNAL(snd_pcm_hw_params_set_buffer_size_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4570 int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4574 int err = snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4581 * \brief Restrict a configuration space to contain only its maximum buffer size
4582 * \param pcm PCM handle
4583 * \param params Configuration space
4584 * \param val Returned maximum buffer size in frames
4585 * \return 0 otherwise a negative error code
4587 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4588 * to enable this new function prototype. Using of older function with same name is deprecated.
4591 int INTERNAL(snd_pcm_hw_params_set_buffer_size_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4593 int snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4597 int err = snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, &_val, NULL);
4605 * \brief Extract tick time from a configuration space
4606 * \param params Configuration space
4607 * \param val Returned approximate tick duration in us
4608 * \param dir Sub unit direction
4609 * \return 0 otherwise a negative error code if not exactly one is present
4611 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4613 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4614 * to enable this new function prototype. Using of older function with same name is deprecated.
4617 int INTERNAL(snd_pcm_hw_params_get_tick_time)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4619 int snd_pcm_hw_params_get_tick_time(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4622 return snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4626 * \brief Extract minimum tick time from a configuration space
4627 * \param params Configuration space
4628 * \param val Returned approximate minimum tick duration in us
4629 * \param dir Sub unit direction
4630 * \return 0 otherwise a negative error code
4632 * Exact value is <,=,> the returned one following dir (-1,0,1)
4634 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4635 * to enable this new function prototype. Using of older function with same name is deprecated.
4638 int INTERNAL(snd_pcm_hw_params_get_tick_time_min)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4640 int snd_pcm_hw_params_get_tick_time_min(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4643 return snd_pcm_hw_param_get_min(params, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4647 * \brief Extract maximum tick time from a configuration space
4648 * \param params Configuration space
4649 * \param val Returned approximate maximum tick duration in us
4650 * \param dir Sub unit direction
4651 * \return 0 otherwise a negative error code
4653 * Exact value is <,=,> the returned one following dir (-1,0,1)
4655 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4656 * to enable this new function prototype. Using of older function with same name is deprecated.
4659 int INTERNAL(snd_pcm_hw_params_get_tick_time_max)(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4661 int snd_pcm_hw_params_get_tick_time_max(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4664 return snd_pcm_hw_param_get_max(params, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4668 * \brief Verify if a tick time is available inside a configuration space for a PCM
4669 * \param pcm PCM handle
4670 * \param params Configuration space
4671 * \param val approximate tick duration in us
4672 * \param dir Sub unit direction
4673 * \return 1 if available 0 otherwise
4675 * Wanted exact value is <,=,> val following dir (-1,0,1)
4677 int snd_pcm_hw_params_test_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
4679 return snd_pcm_hw_param_set(pcm, params, SND_TEST, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4683 * \brief Restrict a configuration space to contain only one tick time
4684 * \param pcm PCM handle
4685 * \param params Configuration space
4686 * \param val approximate tick duration in us
4687 * \param dir Sub unit direction
4688 * \return 0 otherwise a negative error code if configuration space would become empty
4690 * Wanted exact value is <,=,> val following dir (-1,0,1)
4692 int snd_pcm_hw_params_set_tick_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val, int dir)
4694 return snd_pcm_hw_param_set(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4698 * \brief Restrict a configuration space with a minimum tick time
4699 * \param pcm PCM handle
4700 * \param params Configuration space
4701 * \param val approximate minimum tick duration in us (on return filled with actual minimum)
4702 * \param dir Sub unit direction (on return filled with actual direction)
4703 * \return 0 otherwise a negative error code if configuration space would become empty
4705 * Wanted/actual exact minimum is <,=,> val following dir (-1,0,1)
4707 int snd_pcm_hw_params_set_tick_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4709 return snd_pcm_hw_param_set_min(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4713 * \brief Restrict a configuration space with a maximum tick time
4714 * \param pcm PCM handle
4715 * \param params Configuration space
4716 * \param val approximate maximum tick duration in us (on return filled with actual maximum)
4717 * \param dir Sub unit direction (on return filled with actual direction)
4718 * \return 0 otherwise a negative error code if configuration space would become empty
4720 * Wanted/actual exact maximum is <,=,> val following dir (-1,0,1)
4722 int snd_pcm_hw_params_set_tick_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4724 return snd_pcm_hw_param_set_max(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4728 * \brief Restrict a configuration space to have tick times in a given range
4729 * \param pcm PCM handle
4730 * \param params Configuration space
4731 * \param min approximate minimum tick duration in us (on return filled with actual minimum)
4732 * \param mindir Sub unit direction for minimum (on return filled with actual direction)
4733 * \param max approximate maximum tick duration in us (on return filled with actual maximum)
4734 * \param maxdir Sub unit direction for maximum (on return filled with actual direction)
4735 * \return 0 otherwise a negative error code if configuration space would become empty
4737 * Wanted/actual exact min/max is <,=,> val following dir (-1,0,1)
4739 int snd_pcm_hw_params_set_tick_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir)
4741 return snd_pcm_hw_param_set_minmax(pcm, params, SND_TRY, SND_PCM_HW_PARAM_TICK_TIME, min, mindir, max, maxdir);
4745 * \brief Restrict a configuration space to have tick time nearest to a target
4746 * \param pcm PCM handle
4747 * \param params Configuration space
4748 * \param val approximate target tick duration in us / returned chosen approximate target tick duration in us
4749 * \return approximate chosen tick duration in us
4751 * target/chosen exact value is <,=,> val following dir (-1,0,1)
4753 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4754 * to enable this new function prototype. Using of older function with same name is deprecated.
4757 int INTERNAL(snd_pcm_hw_params_set_tick_time_near)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4759 int snd_pcm_hw_params_set_tick_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4762 return snd_pcm_hw_param_set_near(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4766 * \brief Restrict a configuration space to contain only its minimum tick time
4767 * \param pcm PCM handle
4768 * \param params Configuration space
4769 * \param val Returned approximate minimum tick duration in us
4770 * \param dir Sub unit direction
4771 * \return 0 otherwise a negative error code
4773 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4775 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4776 * to enable this new function prototype. Using of older function with same name is deprecated.
4779 int INTERNAL(snd_pcm_hw_params_set_tick_time_first)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4781 int snd_pcm_hw_params_set_tick_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4784 return snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4788 * \brief Restrict a configuration space to contain only its maximum tick time
4789 * \param pcm PCM handle
4790 * \param params Configuration space
4791 * \param val Returned approximate maximum tick duration in us
4792 * \param dir Sub unit direction
4793 * \return 0 otherwise a negative error code
4795 * Actual exact value is <,=,> the approximate one following dir (-1, 0, 1)
4797 * Note: To use this function add '#define ALSA_PCM_NEW_HW_PARAMS_API' before '#include <alsa/asoundlib.h>'
4798 * to enable this new function prototype. Using of older function with same name is deprecated.
4801 int INTERNAL(snd_pcm_hw_params_set_tick_time_last)(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4803 int snd_pcm_hw_params_set_tick_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
4806 return snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, val, dir);
4810 * \brief Get the minimum transfer align value in samples
4811 * \param params Configuration space
4812 * \param val Returned minimum align value
4813 * \return 0 otherwise a negative error code if not exactly one is present
4815 int snd_pcm_hw_params_get_min_align(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
4817 unsigned int format, channels, fb, min_align;
4820 err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_FORMAT, &format, NULL);
4823 err = snd_pcm_hw_param_get(params, SND_PCM_HW_PARAM_CHANNELS, &channels, NULL);
4826 // compute frame bits
4827 fb = snd_pcm_format_physical_width((snd_pcm_format_t)format) * channels;
4839 * \brief Return current software configuration for a PCM
4840 * \param pcm PCM handle
4841 * \param params Software configuration container
4842 * \return 0 on success otherwise a negative error code
4844 int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
4846 assert(pcm && params);
4848 params->tstamp_mode = pcm->tstamp_mode;
4849 params->period_step = pcm->period_step;
4850 params->sleep_min = pcm->sleep_min;
4851 params->avail_min = pcm->avail_min;
4852 params->xfer_align = pcm->xfer_align;
4853 params->start_threshold = pcm->start_threshold;
4854 params->stop_threshold = pcm->stop_threshold;
4855 params->silence_threshold = pcm->silence_threshold;
4856 params->silence_size = pcm->silence_size;
4857 params->boundary = pcm->boundary;
4862 * \brief Dump a software configuration
4863 * \param params Software configuration container
4864 * \param out Output handle
4865 * \return 0 on success otherwise a negative error code
4867 int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out)
4869 snd_output_printf(out, "start_mode: %s\n", snd_pcm_start_mode_name(snd_pcm_sw_params_get_start_mode(params)));
4870 snd_output_printf(out, "xrun_mode: %s\n", snd_pcm_xrun_mode_name(snd_pcm_sw_params_get_xrun_mode(params)));
4871 snd_output_printf(out, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(snd_pcm_sw_params_get_tstamp_mode(params)));
4872 snd_output_printf(out, "period_step: %u\n", params->period_step);
4873 snd_output_printf(out, "sleep_min: %u\n", params->sleep_min);
4874 snd_output_printf(out, "avail_min: %lu\n", params->avail_min);
4875 snd_output_printf(out, "xfer_align: %lu\n", params->xfer_align);
4876 snd_output_printf(out, "silence_threshold: %lu\n", params->silence_threshold);
4877 snd_output_printf(out, "silence_size: %lu\n", params->silence_size);
4878 snd_output_printf(out, "boundary: %lu\n", params->boundary);
4883 * \brief get size of #snd_pcm_sw_params_t
4884 * \return size in bytes
4886 size_t snd_pcm_sw_params_sizeof()
4888 return sizeof(snd_pcm_sw_params_t);
4892 * \brief allocate an invalid #snd_pcm_sw_params_t using standard malloc
4893 * \param ptr returned pointer
4894 * \return 0 on success otherwise negative error code
4896 int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr)
4899 *ptr = calloc(1, sizeof(snd_pcm_sw_params_t));
4906 * \brief frees a previously allocated #snd_pcm_sw_params_t
4907 * \param pointer to object to free
4909 void snd_pcm_sw_params_free(snd_pcm_sw_params_t *obj)
4915 * \brief copy one #snd_pcm_sw_params_t to another
4916 * \param dst pointer to destination
4917 * \param src pointer to source
4919 void snd_pcm_sw_params_copy(snd_pcm_sw_params_t *dst, const snd_pcm_sw_params_t *src)
4926 * \brief (DEPRECATED) Set start mode inside a software configuration container
4927 * \param pcm PCM handle
4928 * \param params Software configuration container
4929 * \param val Start mode
4930 * \return 0 otherwise a negative error code
4932 int snd_pcm_sw_params_set_start_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_start_t val)
4934 assert(pcm && params);
4936 case SND_PCM_START_DATA:
4937 params->start_threshold = 1;
4939 case SND_PCM_START_EXPLICIT:
4940 params->start_threshold = pcm->boundary;
4950 link_warning(snd_pcm_sw_params_set_start_mode, "Warning: start_mode is deprecated, consider to use start_threshold");
4954 * \brief (DEPRECATED) Get start mode from a software configuration container
4955 * \param params Software configuration container
4956 * \return start mode
4958 snd_pcm_start_t snd_pcm_sw_params_get_start_mode(const snd_pcm_sw_params_t *params)
4962 return params->start_threshold > 1024 * 1024 ? SND_PCM_START_EXPLICIT : SND_PCM_START_DATA;
4966 link_warning(snd_pcm_sw_params_get_start_mode, "Warning: start_mode is deprecated, consider to use start_threshold");
4970 * \brief (DEPRECATED) Set xrun mode inside a software configuration container
4971 * \param pcm PCM handle
4972 * \param params Software configuration container
4973 * \param val Xrun mode
4974 * \return 0 otherwise a negative error code
4977 int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val)
4979 int snd_pcm_sw_params_set_xrun_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_xrun_t val)
4982 assert(pcm && params);
4984 case SND_PCM_XRUN_STOP:
4985 params->stop_threshold = pcm->buffer_size;
4987 case SND_PCM_XRUN_NONE:
4988 params->stop_threshold = pcm->boundary;
4998 link_warning(snd_pcm_sw_params_set_xrun_mode, "Warning: xrun_mode is deprecated, consider to use stop_threshold");
5002 * \brief (DEPRECATED) Get xrun mode from a software configuration container
5003 * \param params Software configuration container
5006 snd_pcm_xrun_t snd_pcm_sw_params_get_xrun_mode(const snd_pcm_sw_params_t *params)
5010 return params->stop_threshold > 1024 * 1024 ? SND_PCM_XRUN_NONE : SND_PCM_XRUN_STOP;
5014 link_warning(snd_pcm_sw_params_get_xrun_mode, "Warning: xrun_mode is deprecated, consider to use stop_threshold");
5018 * \brief Set timestamp mode inside a software configuration container
5019 * \param pcm PCM handle
5020 * \param params Software configuration container
5021 * \param val Timestamp mode
5022 * \return 0 otherwise a negative error code
5025 int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val)
5027 int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val)
5030 assert(pcm && params);
5031 assert(val <= SND_PCM_TSTAMP_LAST);
5032 params->tstamp_mode = val;
5037 * \brief Get timestamp mode from a software configuration container
5038 * \param params Software configuration container
5039 * \return timestamp mode
5041 snd_pcm_tstamp_t snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params)
5044 return params->tstamp_mode;
5049 int snd_pcm_sw_params_set_period_step(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, unsigned int val)
5051 assert(pcm && params);
5052 params->period_step = val;
5056 unsigned int snd_pcm_sw_params_get_period_step(const snd_pcm_sw_params_t *params)
5059 return params->period_step;
5065 * \brief Set minimum number of ticks to sleep inside a software configuration container
5066 * \param pcm PCM handle
5067 * \param params Software configuration container
5068 * \param val Minimum ticks to sleep or 0 to disable the use of tick timer
5069 * \return 0 otherwise a negative error code
5072 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, unsigned int val)
5074 int snd_pcm_sw_params_set_sleep_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, unsigned int val)
5077 assert(pcm && params);
5078 params->sleep_min = val;
5083 * \brief Get minimum numbers of ticks to sleep from a software configuration container
5084 * \param params Software configuration container
5085 * \return minimum number of ticks to sleep or 0 if tick timer is disabled
5087 unsigned int snd_pcm_sw_params_get_sleep_min(const snd_pcm_sw_params_t *params)
5090 return params->sleep_min;
5094 * \brief Set avail min inside a software configuration container
5095 * \param pcm PCM handle
5096 * \param params Software configuration container
5097 * \param val Minimum avail frames to consider PCM ready
5098 * \return 0 otherwise a negative error code
5101 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5103 int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5106 assert(pcm && params);
5107 params->avail_min = val;
5112 * \brief Get avail min from a software configuration container
5113 * \param params Software configuration container
5114 * \return minimum available frames to consider PCM ready
5116 snd_pcm_uframes_t snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params)
5119 return params->avail_min;
5124 * \brief Set xfer align inside a software configuration container
5125 * \param pcm PCM handle
5126 * \param params Software configuration container
5127 * \param val Chunk size (frames are attempted to be transferred in chunks)
5128 * \return 0 otherwise a negative error code
5131 int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5133 int snd_pcm_sw_params_set_xfer_align(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5136 assert(pcm && params);
5137 assert(val % pcm->min_align == 0);
5138 params->xfer_align = val;
5143 * \brief Get xfer align from a software configuration container
5144 * \param params Software configuration container
5145 * \return Chunk size (frames are attempted to be transferred in chunks)
5147 snd_pcm_uframes_t snd_pcm_sw_params_get_xfer_align(const snd_pcm_sw_params_t *params)
5150 return params->xfer_align;
5155 * \brief Set start threshold inside a software configuration container
5156 * \param pcm PCM handle
5157 * \param params Software configuration container
5158 * \param val Start threshold in frames
5159 * \return 0 otherwise a negative error code
5161 * PCM is automatically started when playback frames available to PCM
5162 * are >= threshold or when requested capture frames are >= threshold
5165 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5167 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5170 assert(pcm && params);
5171 params->start_threshold = val;
5176 * \brief Get start threshold from a software configuration container
5177 * \param params Software configuration container
5178 * \return Start threshold in frames
5180 * PCM is automatically started when playback frames available to PCM
5181 * are >= threshold or when requested capture frames are >= threshold
5183 snd_pcm_uframes_t snd_pcm_sw_params_get_start_threshold(const snd_pcm_sw_params_t *params)
5186 return params->start_threshold;
5190 * \brief Set stop threshold inside a software configuration container
5191 * \param pcm PCM handle
5192 * \param params Software configuration container
5193 * \param val Stop threshold in frames
5194 * \return 0 otherwise a negative error code
5196 * PCM is automatically stopped in #SND_PCM_STATE_XRUN state when available
5197 * frames is >= threshold
5200 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5202 int snd_pcm_sw_params_set_stop_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5205 assert(pcm && params);
5206 params->stop_threshold = val;
5211 * \brief Get stop threshold from a software configuration container
5212 * \param params Software configuration container
5213 * \return Stop threshold in frames
5215 * PCM is automatically stopped in #SND_PCM_STATE_XRUN state when available
5216 * frames is >= threshold
5218 snd_pcm_uframes_t snd_pcm_sw_params_get_stop_threshold(const snd_pcm_sw_params_t *params)
5221 return params->stop_threshold;
5225 * \brief Set silence threshold inside a software configuration container
5226 * \param pcm PCM handle
5227 * \param params Software configuration container
5228 * \param val Silence threshold in frames
5229 * \return 0 otherwise a negative error code
5231 * A portion of playback buffer is overwritten with silence (see
5232 * #snd_pcm_sw_params_set_silence_size) when playback underrun is nearer
5233 * than silence threshold
5236 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5238 int snd_pcm_sw_params_set_silence_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5241 assert(pcm && params);
5242 assert(val + params->silence_size <= pcm->buffer_size);
5243 params->silence_threshold = val;
5248 * \brief Get silence threshold from a software configuration container
5249 * \param params Software configuration container
5250 * \return Silence threshold in frames
5252 * A portion of playback buffer is overwritten with silence (see
5253 * #snd_pcm_sw_params_get_silence_size) when playback underrun is nearer
5254 * than silence threshold
5256 snd_pcm_uframes_t snd_pcm_sw_params_get_silence_threshold(const snd_pcm_sw_params_t *params)
5259 return params->silence_threshold;
5264 * \brief Set silence size inside a software configuration container
5265 * \param pcm PCM handle
5266 * \param params Software configuration container
5267 * \param val Silence size in frames (0 for disabled)
5268 * \return 0 otherwise a negative error code
5270 * A portion of playback buffer is overwritten with silence when playback
5271 * underrun is nearer than silence threshold (see
5272 * #snd_pcm_sw_params_set_silence_threshold)
5275 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5277 int snd_pcm_sw_params_set_silence_size(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
5280 assert(pcm && params);
5281 assert(val + params->silence_threshold <= pcm->buffer_size);
5282 params->silence_size = val;
5287 * \brief Get silence size from a software configuration container
5288 * \param params Software configuration container
5289 * \return Silence size in frames (0 for disabled)
5291 * A portion of playback buffer is overwritten with silence when playback
5292 * underrun is nearer than silence threshold (see
5293 * #snd_pcm_sw_params_set_silence_threshold)
5295 snd_pcm_uframes_t snd_pcm_sw_params_get_silence_size(const snd_pcm_sw_params_t *params)
5298 return params->silence_size;
5303 * \brief get size of #snd_pcm_status_t
5304 * \return size in bytes
5306 size_t snd_pcm_status_sizeof()
5308 return sizeof(snd_pcm_status_t);
5312 * \brief allocate an invalid #snd_pcm_status_t using standard malloc
5313 * \param ptr returned pointer
5314 * \return 0 on success otherwise negative error code
5316 int snd_pcm_status_malloc(snd_pcm_status_t **ptr)
5319 *ptr = calloc(1, sizeof(snd_pcm_status_t));
5326 * \brief frees a previously allocated #snd_pcm_status_t
5327 * \param pointer to object to free
5329 void snd_pcm_status_free(snd_pcm_status_t *obj)
5335 * \brief copy one #snd_pcm_status_t to another
5336 * \param dst pointer to destination
5337 * \param src pointer to source
5339 void snd_pcm_status_copy(snd_pcm_status_t *dst, const snd_pcm_status_t *src)
5346 * \brief Get state from a PCM status container (see #snd_pcm_state)
5349 snd_pcm_state_t snd_pcm_status_get_state(const snd_pcm_status_t *obj)
5356 * \brief Get trigger timestamp from a PCM status container
5357 * \param ptr Pointer to returned timestamp
5359 void snd_pcm_status_get_trigger_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr)
5362 *ptr = obj->trigger_tstamp;
5366 * \brief Get "now" timestamp from a PCM status container
5367 * \param ptr Pointer to returned timestamp
5369 void snd_pcm_status_get_tstamp(const snd_pcm_status_t *obj, snd_timestamp_t *ptr)
5376 * \brief Get delay from a PCM status container (see #snd_pcm_delay)
5377 * \return Delay in frames
5379 * Delay is distance between current application frame position and
5380 * sound frame position.
5381 * It's positive and less than buffer size in normal situation,
5382 * negative on playback underrun and greater than buffer size on
5385 snd_pcm_sframes_t snd_pcm_status_get_delay(const snd_pcm_status_t *obj)
5392 * \brief Get number of frames available from a PCM status container (see #snd_pcm_avail_update)
5393 * \return Number of frames ready to be read/written
5395 snd_pcm_uframes_t snd_pcm_status_get_avail(const snd_pcm_status_t *obj)
5402 * \brief Get maximum number of frames available from a PCM status container after last #snd_pcm_status call
5403 * \return Maximum number of frames ready to be read/written
5405 snd_pcm_uframes_t snd_pcm_status_get_avail_max(const snd_pcm_status_t *obj)
5408 return obj->avail_max;
5412 * \brief Get count of ADC overrange detections since last call
5413 * \return Count of ADC overrange detections
5415 snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj)
5418 return obj->overrange;
5422 * \brief get size of #snd_pcm_info_t
5423 * \return size in bytes
5425 size_t snd_pcm_info_sizeof()
5427 return sizeof(snd_pcm_info_t);
5431 * \brief allocate an invalid #snd_pcm_info_t using standard malloc
5432 * \param ptr returned pointer
5433 * \return 0 on success otherwise negative error code
5435 int snd_pcm_info_malloc(snd_pcm_info_t **ptr)
5438 *ptr = calloc(1, sizeof(snd_pcm_info_t));
5445 * \brief frees a previously allocated #snd_pcm_info_t
5446 * \param pointer to object to free
5448 void snd_pcm_info_free(snd_pcm_info_t *obj)
5454 * \brief copy one #snd_pcm_info_t to another
5455 * \param dst pointer to destination
5456 * \param src pointer to source
5458 void snd_pcm_info_copy(snd_pcm_info_t *dst, const snd_pcm_info_t *src)
5465 * \brief Get device from a PCM info container
5466 * \param obj PCM info container
5467 * \return device number
5469 unsigned int snd_pcm_info_get_device(const snd_pcm_info_t *obj)
5476 * \brief Get subdevice from a PCM info container
5477 * \param obj PCM info container
5478 * \return subdevice number
5480 unsigned int snd_pcm_info_get_subdevice(const snd_pcm_info_t *obj)
5483 return obj->subdevice;
5487 * \brief Get stream (direction) from a PCM info container
5488 * \param obj PCM info container
5491 snd_pcm_stream_t snd_pcm_info_get_stream(const snd_pcm_info_t *obj)
5498 * \brief Get card from a PCM info container
5499 * \param obj PCM info container
5500 * \return card number otherwise a negative error code if not associable to a card
5502 int snd_pcm_info_get_card(const snd_pcm_info_t *obj)
5509 * \brief Get id from a PCM info container
5510 * \param obj PCM info container
5511 * \return short id of PCM
5513 const char *snd_pcm_info_get_id(const snd_pcm_info_t *obj)
5520 * \brief Get name from a PCM info container
5521 * \param obj PCM info container
5522 * \return name of PCM
5524 const char *snd_pcm_info_get_name(const snd_pcm_info_t *obj)
5531 * \brief Get subdevice name from a PCM info container
5532 * \param obj PCM info container
5533 * \return name of used PCM subdevice
5535 const char *snd_pcm_info_get_subdevice_name(const snd_pcm_info_t *obj)
5538 return obj->subname;
5542 * \brief Get class from a PCM info container
5543 * \param obj PCM info container
5544 * \return class of PCM
5546 snd_pcm_class_t snd_pcm_info_get_class(const snd_pcm_info_t *obj)
5549 return obj->dev_class;
5553 * \brief Get subclass from a PCM info container
5554 * \param obj PCM info container
5555 * \return subclass of PCM
5557 snd_pcm_subclass_t snd_pcm_info_get_subclass(const snd_pcm_info_t *obj)
5560 return obj->dev_subclass;
5564 * \brief Get subdevices count from a PCM info container
5565 * \param obj PCM info container
5566 * \return subdevices total count of PCM
5568 unsigned int snd_pcm_info_get_subdevices_count(const snd_pcm_info_t *obj)
5571 return obj->subdevices_count;
5575 * \brief Get available subdevices count from a PCM info container
5576 * \param obj PCM info container
5577 * \return available subdevices count of PCM
5579 unsigned int snd_pcm_info_get_subdevices_avail(const snd_pcm_info_t *obj)
5582 return obj->subdevices_avail;
5586 * \brief Get hardware synchronization ID from a PCM info container
5587 * \param obj PCM info container
5588 * \return hardware synchronization ID
5590 snd_pcm_sync_id_t snd_pcm_info_get_sync(const snd_pcm_info_t *obj)
5592 snd_pcm_sync_id_t res;
5594 memcpy(&res, &obj->sync, sizeof(res));
5599 * \brief Set wanted device inside a PCM info container (see #snd_ctl_pcm_info)
5600 * \param obj PCM info container
5601 * \param val Device number
5603 void snd_pcm_info_set_device(snd_pcm_info_t *obj, unsigned int val)
5610 * \brief Set wanted subdevice inside a PCM info container (see #snd_ctl_pcm_info)
5611 * \param obj PCM info container
5612 * \param val Subdevice number
5614 void snd_pcm_info_set_subdevice(snd_pcm_info_t *obj, unsigned int val)
5617 obj->subdevice = val;
5621 * \brief Set wanted stream inside a PCM info container (see #snd_ctl_pcm_info)
5622 * \param obj PCM info container
5625 void snd_pcm_info_set_stream(snd_pcm_info_t *obj, snd_pcm_stream_t val)
5632 * \brief Application request to access a portion of direct (mmap) area
5633 * \param pcm PCM handle
5634 * \param areas Returned mmap channel areas
5635 * \param offset Returned mmap area offset in area steps (== frames)
5636 * \param frames mmap area portion size in frames (wanted on entry, contiguous available on exit)
5637 * \return 0 on success otherwise a negative error code
5639 * It is necessary to call the snd_pcm_avail_update() function directly before
5640 * this call. Otherwise, this function can return a wrong count of available frames.
5642 * The function should be called before a sample-direct area can be accessed.
5643 * The resulting size parameter is always less or equal to the input count of frames
5644 * and can be zero, if no frames can be processed (the ring buffer is full).
5646 * See the snd_pcm_mmap_commit() function to finish the frame processing in
5650 int snd_pcm_mmap_begin(snd_pcm_t *pcm,
5651 const snd_pcm_channel_area_t **areas,
5652 snd_pcm_uframes_t *offset,
5653 snd_pcm_uframes_t *frames)
5655 snd_pcm_uframes_t cont;
5656 snd_pcm_uframes_t f;
5657 snd_pcm_uframes_t avail;
5658 assert(pcm && areas && offset && frames);
5659 if (pcm->stopped_areas &&
5660 snd_pcm_state(pcm) != SND_PCM_STATE_RUNNING)
5661 *areas = pcm->stopped_areas;
5663 *areas = pcm->running_areas;
5664 *offset = *pcm->appl.ptr % pcm->buffer_size;
5665 cont = pcm->buffer_size - *offset;
5667 avail = snd_pcm_mmap_avail(pcm);
5668 if (avail > pcm->buffer_size)
5669 avail = pcm->buffer_size;
5679 * \brief Application has completed the access to area requested with #snd_pcm_mmap_begin
5680 * \param pcm PCM handle
5681 * \param offset area offset in area steps (== frames)
5682 * \param size area portion size in frames
5683 * \return count of transferred frames otherwise a negative error code
5685 * You should pass this function the offset value that
5686 * snd_pcm_mmap_begin() returned. The frames parameter should hold the
5687 * number of frames you have written or read to/from the audio
5688 * buffer. The frames parameter must never exceed the contiguous frames
5689 * count that snd_pcm_mmap_begin() returned. Each call to snd_pcm_mmap_begin()
5690 * must be followed by a call to snd_pcm_mmap_commit().
5695 const snd_pcm_area_t *areas;
5696 snd_pcm_sframes_t avail, size, commitres;
5697 snd_pcm_uframes_t offset, frames;
5700 avail = snd_pcm_avail_update(pcm);
5703 // at this point, we can transfer at least 'avail' frames
5705 // we want to process frames in chunks (period_size)
5706 if (avail < period_size)
5709 // it is possible that contiguous areas are smaller, thus we use a loop
5713 err = snd_pcm_mmap_begin(pcm_handle, &areas, &offset, &frames);
5716 // this function fills the areas from offset with count of frames
5717 generate_sine(areas, offset, frames, &phase);
5718 commitres = snd_pcm_mmap_commit(pcm_handle, offset, frames);
5719 if (commitres < 0 || commitres != frames)
5720 error(commitres >= 0 ? -EPIPE : commitres);
5727 * Look to the \ref example_test_pcm "Sine-wave generator" example
5728 * for more details about the generate_sine function.
5730 snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
5731 snd_pcm_uframes_t offset,
5732 snd_pcm_uframes_t frames)
5735 assert(offset == *pcm->appl.ptr % pcm->buffer_size);
5736 assert(frames <= snd_pcm_mmap_avail(pcm));
5737 return pcm->fast_ops->mmap_commit(pcm->fast_op_arg, offset, frames);
5742 int _snd_pcm_poll_descriptor(snd_pcm_t *pcm)
5745 return pcm->poll_fd;
5748 void snd_pcm_areas_from_buf(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas,
5751 unsigned int channel;
5752 unsigned int channels = pcm->channels;
5753 for (channel = 0; channel < channels; ++channel, ++areas) {
5755 areas->first = channel * pcm->sample_bits;
5756 areas->step = pcm->frame_bits;
5760 void snd_pcm_areas_from_bufs(snd_pcm_t *pcm, snd_pcm_channel_area_t *areas,
5763 unsigned int channel;
5764 unsigned int channels = pcm->channels;
5765 for (channel = 0; channel < channels; ++channel, ++areas, ++bufs) {
5766 areas->addr = *bufs;
5768 areas->step = pcm->sample_bits;
5772 snd_pcm_sframes_t snd_pcm_read_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
5773 snd_pcm_uframes_t offset, snd_pcm_uframes_t size,
5774 snd_pcm_xfer_areas_func_t func)
5776 snd_pcm_uframes_t xfer = 0;
5777 snd_pcm_sframes_t err = 0;
5778 snd_pcm_state_t state = snd_pcm_state(pcm);
5782 if (size > pcm->xfer_align)
5783 size -= size % pcm->xfer_align;
5786 case SND_PCM_STATE_PREPARED:
5787 if (size >= pcm->start_threshold) {
5788 err = snd_pcm_start(pcm);
5793 case SND_PCM_STATE_DRAINING:
5794 case SND_PCM_STATE_RUNNING:
5796 case SND_PCM_STATE_XRUN:
5798 case SND_PCM_STATE_SUSPENDED:
5805 snd_pcm_uframes_t frames;
5806 snd_pcm_sframes_t avail;
5808 if (pcm->sleep_min == 0 && state == SND_PCM_STATE_RUNNING) {
5809 snd_pcm_sframes_t delay;
5811 err = snd_pcm_delay(pcm, &delay);
5815 avail = snd_pcm_avail_update(pcm);
5820 if (((snd_pcm_uframes_t)avail < pcm->avail_min && size > (snd_pcm_uframes_t)avail) ||
5821 (size >= pcm->xfer_align && (snd_pcm_uframes_t)avail < pcm->xfer_align)) {
5823 if (pcm->mode & SND_PCM_NONBLOCK) {
5828 err = snd_pcm_wait(pcm, -1);
5831 state = snd_pcm_state(pcm);
5835 if ((snd_pcm_uframes_t) avail > pcm->xfer_align)
5836 avail -= avail % pcm->xfer_align;
5838 if (frames > (snd_pcm_uframes_t) avail)
5840 assert(frames != 0);
5841 err = func(pcm, areas, offset, frames);
5850 return xfer > 0 ? (snd_pcm_sframes_t) xfer : err;
5853 snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area_t *areas,
5854 snd_pcm_uframes_t offset, snd_pcm_uframes_t size,
5855 snd_pcm_xfer_areas_func_t func)
5857 snd_pcm_uframes_t xfer = 0;
5858 snd_pcm_sframes_t err = 0;
5859 snd_pcm_state_t state = snd_pcm_state(pcm);
5863 if (size > pcm->xfer_align)
5864 size -= size % pcm->xfer_align;
5867 case SND_PCM_STATE_PREPARED:
5868 case SND_PCM_STATE_RUNNING:
5870 case SND_PCM_STATE_XRUN:
5872 case SND_PCM_STATE_SUSPENDED:
5879 snd_pcm_uframes_t frames;
5880 snd_pcm_sframes_t avail;
5882 if (pcm->sleep_min == 0 && state == SND_PCM_STATE_RUNNING) {
5883 snd_pcm_sframes_t delay;
5885 err = snd_pcm_delay(pcm, &delay);
5889 avail = snd_pcm_avail_update(pcm);
5893 } else if (((snd_pcm_uframes_t)avail < pcm->avail_min && size > (snd_pcm_uframes_t)avail) ||
5894 (size >= pcm->xfer_align && (snd_pcm_uframes_t)avail < pcm->xfer_align)) {
5896 if (pcm->mode & SND_PCM_NONBLOCK) {
5901 err = snd_pcm_wait(pcm, -1);
5904 state = snd_pcm_state(pcm);
5908 if ((snd_pcm_uframes_t) avail > pcm->xfer_align)
5909 avail -= avail % pcm->xfer_align;
5911 if (frames > (snd_pcm_uframes_t) avail)
5913 assert(frames != 0);
5914 err = func(pcm, areas, offset, frames);
5921 if (state == SND_PCM_STATE_PREPARED) {
5922 snd_pcm_sframes_t hw_avail = pcm->buffer_size - avail;
5924 /* some plugins might automatically start the stream */
5925 state = snd_pcm_state(pcm);
5926 if (state == SND_PCM_STATE_PREPARED &&
5927 hw_avail >= (snd_pcm_sframes_t) pcm->start_threshold) {
5928 err = snd_pcm_start(pcm);
5935 return xfer > 0 ? (snd_pcm_sframes_t) xfer : err;
5938 snd_pcm_uframes_t _snd_pcm_mmap_hw_ptr(snd_pcm_t *pcm)
5940 return *pcm->hw.ptr;
5943 snd_pcm_uframes_t _snd_pcm_boundary(snd_pcm_t *pcm)
5945 return pcm->boundary;
5948 static const char *names[SND_PCM_HW_PARAM_LAST_INTERVAL + 1] = {
5949 [SND_PCM_HW_PARAM_FORMAT] = "format",
5950 [SND_PCM_HW_PARAM_CHANNELS] = "channels",
5951 [SND_PCM_HW_PARAM_RATE] = "rate",
5952 [SND_PCM_HW_PARAM_PERIOD_TIME] = "period_time",
5953 [SND_PCM_HW_PARAM_BUFFER_TIME] = "buffer_time"
5956 int snd_pcm_slave_conf(snd_config_t *root, snd_config_t *conf,
5957 snd_config_t **_pcm_conf, unsigned int count, ...)
5959 snd_config_iterator_t i, next;
5968 snd_config_t *pcm_conf = NULL;
5975 if (snd_config_get_string(conf, &str) >= 0) {
5976 err = snd_config_search_definition(root, "pcm_slave", str, &conf);
5978 SNDERR("Invalid slave definition");
5983 if (snd_config_get_type(conf) != SND_CONFIG_TYPE_COMPOUND) {
5984 SNDERR("Invalid slave definition");
5988 va_start(args, count);
5989 for (k = 0; k < count; ++k) {
5990 fields[k].index = va_arg(args, int);
5991 fields[k].flags = va_arg(args, int);
5992 fields[k].ptr = va_arg(args, void *);
5993 fields[k].present = 0;
5996 snd_config_for_each(i, next, conf) {
5997 snd_config_t *n = snd_config_iterator_entry(i);
5999 if (snd_config_get_id(n, &id) < 0)
6001 if (strcmp(id, "comment") == 0)
6003 if (strcmp(id, "pcm") == 0) {
6004 if (pcm_conf != NULL)
6005 snd_config_delete(pcm_conf);
6006 if ((err = snd_config_copy(&pcm_conf, n)) < 0)
6010 for (k = 0; k < count; ++k) {
6011 unsigned int idx = fields[k].index;
6013 assert(idx < SND_PCM_HW_PARAM_LAST_INTERVAL);
6015 if (strcmp(id, names[idx]) != 0)
6018 case SND_PCM_HW_PARAM_FORMAT:
6021 err = snd_config_get_string(n, &str);
6024 SNDERR("invalid type for %s", id);
6027 if ((fields[k].flags & SCONF_UNCHANGED) &&
6028 strcasecmp(str, "unchanged") == 0) {
6029 *(snd_pcm_format_t*)fields[k].ptr = (snd_pcm_format_t) -2;
6032 f = snd_pcm_format_value(str);
6033 if (f == SND_PCM_FORMAT_UNKNOWN) {
6034 SNDERR("unknown format %s", str);
6038 *(snd_pcm_format_t*)fields[k].ptr = f;
6042 if ((fields[k].flags & SCONF_UNCHANGED)) {
6043 err = snd_config_get_string(n, &str);
6045 strcasecmp(str, "unchanged") == 0) {
6046 *(int*)fields[k].ptr = -2;
6050 err = snd_config_get_integer(n, &v);
6053 *(int*)fields[k].ptr = v;
6056 fields[k].present = 1;
6061 SNDERR("Unknown field %s", id);
6066 SNDERR("missing field pcm");
6070 for (k = 0; k < count; ++k) {
6071 if ((fields[k].flags & SCONF_MANDATORY) && !fields[k].present) {
6072 SNDERR("missing field %s", names[fields[k].index]);
6077 *_pcm_conf = pcm_conf;
6082 snd_config_delete(pcm_conf);
6084 snd_config_delete(conf);
6089 int snd_pcm_conf_generic_id(const char *id)
6091 static const char *ids[] = { "comment", "type" };
6093 for (k = 0; k < sizeof(ids) / sizeof(ids[0]); ++k) {
6094 if (strcmp(id, ids[k]) == 0)
6100 static void snd_pcm_set_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *rbptr,
6101 volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset)
6103 rbptr->master = NULL; /* I'm master */
6104 rbptr->ptr = hw_ptr;
6106 rbptr->offset = offset;
6108 rbptr->changed(pcm, NULL);
6111 void snd_pcm_set_hw_ptr(snd_pcm_t *pcm, volatile snd_pcm_uframes_t *hw_ptr, int fd, off_t offset)
6115 snd_pcm_set_ptr(pcm, &pcm->hw, hw_ptr, fd, offset);
6118 void snd_pcm_set_appl_ptr(snd_pcm_t *pcm, volatile snd_pcm_uframes_t *appl_ptr, int fd, off_t offset)
6122 snd_pcm_set_ptr(pcm, &pcm->appl, appl_ptr, fd, offset);
6125 static void snd_pcm_link_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *pcm_rbptr,
6126 snd_pcm_t *slave, snd_pcm_rbptr_t *slave_rbptr)
6131 a = slave_rbptr->link_dst;
6132 for (idx = 0; idx < slave_rbptr->link_dst_count; idx++)
6133 if (a[idx] == NULL) {
6135 goto __found_free_place;
6137 a = realloc(a, sizeof(snd_pcm_t *) * (slave_rbptr->link_dst_count + 1));
6139 pcm_rbptr->ptr = NULL;
6141 pcm_rbptr->offset = 0UL;
6144 a[slave_rbptr->link_dst_count++] = pcm;
6146 pcm_rbptr->master = slave_rbptr->master ? slave_rbptr->master : slave;
6147 pcm_rbptr->ptr = slave_rbptr->ptr;
6148 pcm_rbptr->fd = slave_rbptr->fd;
6149 pcm_rbptr->offset = slave_rbptr->offset;
6150 slave_rbptr->link_dst = a;
6151 if (pcm_rbptr->changed)
6152 pcm_rbptr->changed(pcm, slave);
6155 static void snd_pcm_unlink_ptr(snd_pcm_t *pcm, snd_pcm_rbptr_t *pcm_rbptr,
6156 snd_pcm_t *slave, snd_pcm_rbptr_t *slave_rbptr)
6161 a = slave_rbptr->link_dst;
6162 for (idx = 0; idx < slave_rbptr->link_dst_count; idx++)
6163 if (a[idx] == pcm) {
6171 pcm_rbptr->master = NULL;
6172 pcm_rbptr->ptr = NULL;
6174 pcm_rbptr->offset = 0UL;
6175 if (pcm_rbptr->changed)
6176 pcm_rbptr->changed(pcm, slave);
6179 void snd_pcm_link_hw_ptr(snd_pcm_t *pcm, snd_pcm_t *slave)
6183 snd_pcm_link_ptr(pcm, &pcm->hw, slave, &slave->hw);
6186 void snd_pcm_link_appl_ptr(snd_pcm_t *pcm, snd_pcm_t *slave)
6190 snd_pcm_link_ptr(pcm, &pcm->appl, slave, &slave->appl);
6193 void snd_pcm_unlink_hw_ptr(snd_pcm_t *pcm, snd_pcm_t *slave)
6197 snd_pcm_unlink_ptr(pcm, &pcm->hw, slave, &slave->hw);
6200 void snd_pcm_unlink_appl_ptr(snd_pcm_t *pcm, snd_pcm_t *slave)
6204 snd_pcm_unlink_ptr(pcm, &pcm->appl, slave, &slave->appl);
6207 #endif /* DOC_HIDDEN */
6215 #ifdef USE_VERSIONED_SYMBOLS
6218 /* it's really not so nice: obsolete, but default */
6219 /* forced by developers on alsa-devel */
6220 #define OBSOLETE1(name, what, new) \
6221 symbol_version(__##name, name, new); \
6222 default_symbol_version(__old_##name, name, what);
6224 #define OBSOLETE1(name, what, new) \
6225 default_symbol_version(__##name, name, new); \
6226 symbol_version(__old_##name, name, what);
6231 #define OBSOLETE1(name, what, new) /**/
6233 #endif /* USE_VERSIONED_SYMBOLS */
6235 #define __P_OLD_GET(pfx, name, val_type, ret_type) \
6236 ret_type pfx##name(const snd_pcm_hw_params_t *params) \
6239 if (INTERNAL(name)(params, &val) < 0) \
6241 return (ret_type)val; \
6244 #define __P_OLD_GET1(pfx, name, val_type, ret_type) \
6245 ret_type pfx##name(const snd_pcm_hw_params_t *params, int *dir) \
6248 if (INTERNAL(name)(params, &val, dir) < 0) \
6250 return (ret_type)val; \
6253 #ifdef USE_VERSIONED_SYMBOLS
6254 #define __OLD_GET(name, val_type, ret_type) __P_OLD_GET(__old_, name, val_type, ret_type)
6255 #define __OLD_GET1(name, val_type, ret_type) __P_OLD_GET1(__old_, name, val_type, ret_type)
6257 #define __OLD_GET(name, val_type, ret_type) __P_OLD_GET(, name, val_type, ret_type)
6258 #define __OLD_GET1(name, val_type, ret_type) __P_OLD_GET1(, name, val_type, ret_type)
6261 __OLD_GET(snd_pcm_hw_params_get_access, snd_pcm_access_t, int);
6262 __OLD_GET(snd_pcm_hw_params_get_format, snd_pcm_format_t, int);
6263 __OLD_GET(snd_pcm_hw_params_get_subformat, snd_pcm_subformat_t, int);
6264 __OLD_GET(snd_pcm_hw_params_get_channels, unsigned int, int);
6265 __OLD_GET1(snd_pcm_hw_params_get_rate, unsigned int, int);
6266 __OLD_GET1(snd_pcm_hw_params_get_period_time, unsigned int, int);
6267 __OLD_GET1(snd_pcm_hw_params_get_period_size, snd_pcm_uframes_t, snd_pcm_sframes_t);
6268 __OLD_GET1(snd_pcm_hw_params_get_periods, unsigned int, int);
6269 __OLD_GET1(snd_pcm_hw_params_get_buffer_time, unsigned int, int);
6270 __OLD_GET(snd_pcm_hw_params_get_buffer_size, snd_pcm_uframes_t, snd_pcm_sframes_t);
6271 __OLD_GET1(snd_pcm_hw_params_get_tick_time, unsigned int, int);
6273 __OLD_GET(snd_pcm_hw_params_get_channels_min, unsigned int, unsigned int);
6274 __OLD_GET1(snd_pcm_hw_params_get_rate_min, unsigned int, unsigned int);
6275 __OLD_GET1(snd_pcm_hw_params_get_period_time_min, unsigned int, unsigned int);
6276 __OLD_GET1(snd_pcm_hw_params_get_period_size_min, snd_pcm_uframes_t, snd_pcm_uframes_t);
6277 __OLD_GET1(snd_pcm_hw_params_get_periods_min, unsigned int, unsigned int);
6278 __OLD_GET1(snd_pcm_hw_params_get_buffer_time_min, unsigned int, unsigned int);
6279 __OLD_GET(snd_pcm_hw_params_get_buffer_size_min, snd_pcm_uframes_t, snd_pcm_uframes_t);
6280 __OLD_GET1(snd_pcm_hw_params_get_tick_time_min, unsigned int, unsigned int);
6282 __OLD_GET(snd_pcm_hw_params_get_channels_max, unsigned int, unsigned int);
6283 __OLD_GET1(snd_pcm_hw_params_get_rate_max, unsigned int, unsigned int);
6284 __OLD_GET1(snd_pcm_hw_params_get_period_time_max, unsigned int, unsigned int);
6285 __OLD_GET1(snd_pcm_hw_params_get_period_size_max, snd_pcm_uframes_t, snd_pcm_uframes_t);
6286 __OLD_GET1(snd_pcm_hw_params_get_periods_max, unsigned int, unsigned int);
6287 __OLD_GET1(snd_pcm_hw_params_get_buffer_time_max, unsigned int, unsigned int);
6288 __OLD_GET(snd_pcm_hw_params_get_buffer_size_max, snd_pcm_uframes_t, snd_pcm_uframes_t);
6289 __OLD_GET1(snd_pcm_hw_params_get_tick_time_max, unsigned int, unsigned int);
6291 #define __P_OLD_NEAR(pfx, name, ret_type) \
6292 ret_type pfx##name(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, ret_type val) \
6294 if (INTERNAL(name)(pcm, params, &val) < 0) \
6296 return (ret_type)val; \
6299 #define __P_OLD_NEAR1(pfx, name, ret_type) \
6300 ret_type pfx##name(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, ret_type val, int *dir) \
6302 if (INTERNAL(name)(pcm, params, &val, dir) < 0) \
6304 return (ret_type)val; \
6307 #ifdef USE_VERSIONED_SYMBOLS
6308 #define __OLD_NEAR(name, ret_type) __P_OLD_NEAR(__old_, name, ret_type)
6309 #define __OLD_NEAR1(name, ret_type) __P_OLD_NEAR1(__old_, name, ret_type)
6311 #define __OLD_NEAR(name, ret_type) __P_OLD_NEAR(, name, ret_type)
6312 #define __OLD_NEAR1(name, ret_type) __P_OLD_NEAR1(, name, ret_type)
6315 __OLD_NEAR(snd_pcm_hw_params_set_channels_near, unsigned int);
6316 __OLD_NEAR1(snd_pcm_hw_params_set_rate_near, unsigned int);
6317 __OLD_NEAR1(snd_pcm_hw_params_set_period_time_near, unsigned int);
6318 __OLD_NEAR1(snd_pcm_hw_params_set_period_size_near, snd_pcm_uframes_t);
6319 __OLD_NEAR1(snd_pcm_hw_params_set_periods_near, unsigned int);
6320 __OLD_NEAR1(snd_pcm_hw_params_set_buffer_time_near, unsigned int);
6321 __OLD_NEAR(snd_pcm_hw_params_set_buffer_size_near, snd_pcm_uframes_t);
6322 __OLD_NEAR1(snd_pcm_hw_params_set_tick_time_near, unsigned int);
6324 #define __P_OLD_SET_FL(pfx, name, ret_type) \
6325 ret_type pfx##name(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) \
6328 if (INTERNAL(name)(pcm, params, &val) < 0) \
6330 return (ret_type)val; \
6333 #define __P_OLD_SET_FL1(pfx, name, ret_type) \
6334 ret_type pfx##name(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, int *dir) \
6337 if (INTERNAL(name)(pcm, params, &val, dir) < 0) \
6339 return (ret_type)val; \
6342 #ifdef USE_VERSIONED_SYMBOLS
6343 #define __OLD_SET_FL(name, ret_type) __P_OLD_SET_FL(__old_, name, ret_type)
6344 #define __OLD_SET_FL1(name, ret_type) __P_OLD_SET_FL1(__old_, name, ret_type)
6346 #define __OLD_SET_FL(name, ret_type) __P_OLD_SET_FL(, name, ret_type)
6347 #define __OLD_SET_FL1(name, ret_type) __P_OLD_SET_FL1(, name, ret_type)
6350 __OLD_SET_FL(snd_pcm_hw_params_set_access_first, snd_pcm_access_t);
6351 __OLD_SET_FL(snd_pcm_hw_params_set_format_first, snd_pcm_format_t);
6352 __OLD_SET_FL(snd_pcm_hw_params_set_subformat_first, snd_pcm_subformat_t);
6353 __OLD_SET_FL(snd_pcm_hw_params_set_channels_first, unsigned int);
6354 __OLD_SET_FL1(snd_pcm_hw_params_set_rate_first, unsigned int);
6355 __OLD_SET_FL1(snd_pcm_hw_params_set_period_time_first, unsigned int);
6356 __OLD_SET_FL1(snd_pcm_hw_params_set_period_size_first, snd_pcm_uframes_t);
6357 __OLD_SET_FL1(snd_pcm_hw_params_set_periods_first, unsigned int);
6358 __OLD_SET_FL1(snd_pcm_hw_params_set_buffer_time_first, unsigned int);
6359 __OLD_SET_FL(snd_pcm_hw_params_set_buffer_size_first, snd_pcm_uframes_t);
6360 __OLD_SET_FL1(snd_pcm_hw_params_set_tick_time_first, unsigned int);
6362 __OLD_SET_FL(snd_pcm_hw_params_set_access_last, snd_pcm_access_t);
6363 __OLD_SET_FL(snd_pcm_hw_params_set_format_last, snd_pcm_format_t);
6364 __OLD_SET_FL(snd_pcm_hw_params_set_subformat_last, snd_pcm_subformat_t);
6365 __OLD_SET_FL(snd_pcm_hw_params_set_channels_last, unsigned int);
6366 __OLD_SET_FL1(snd_pcm_hw_params_set_rate_last, unsigned int);
6367 __OLD_SET_FL1(snd_pcm_hw_params_set_period_time_last, unsigned int);
6368 __OLD_SET_FL1(snd_pcm_hw_params_set_period_size_last, snd_pcm_uframes_t);
6369 __OLD_SET_FL1(snd_pcm_hw_params_set_periods_last, unsigned int);
6370 __OLD_SET_FL1(snd_pcm_hw_params_set_buffer_time_last, unsigned int);
6371 __OLD_SET_FL(snd_pcm_hw_params_set_buffer_size_last, snd_pcm_uframes_t);
6372 __OLD_SET_FL1(snd_pcm_hw_params_set_tick_time_last, unsigned int);
6374 OBSOLETE1(snd_pcm_hw_params_get_access, ALSA_0.9, ALSA_0.9.0rc4);
6375 OBSOLETE1(snd_pcm_hw_params_set_access_first, ALSA_0.9, ALSA_0.9.0rc4);
6376 OBSOLETE1(snd_pcm_hw_params_set_access_last, ALSA_0.9, ALSA_0.9.0rc4);
6378 OBSOLETE1(snd_pcm_hw_params_get_format, ALSA_0.9, ALSA_0.9.0rc4);
6379 OBSOLETE1(snd_pcm_hw_params_set_format_first, ALSA_0.9, ALSA_0.9.0rc4);
6380 OBSOLETE1(snd_pcm_hw_params_set_format_last, ALSA_0.9, ALSA_0.9.0rc4);
6382 OBSOLETE1(snd_pcm_hw_params_get_subformat, ALSA_0.9, ALSA_0.9.0rc4);
6383 OBSOLETE1(snd_pcm_hw_params_set_subformat_first, ALSA_0.9, ALSA_0.9.0rc4);
6384 OBSOLETE1(snd_pcm_hw_params_set_subformat_last, ALSA_0.9, ALSA_0.9.0rc4);
6386 OBSOLETE1(snd_pcm_hw_params_get_channels, ALSA_0.9, ALSA_0.9.0rc4);
6387 OBSOLETE1(snd_pcm_hw_params_get_channels_min, ALSA_0.9, ALSA_0.9.0rc4);
6388 OBSOLETE1(snd_pcm_hw_params_get_channels_max, ALSA_0.9, ALSA_0.9.0rc4);
6389 OBSOLETE1(snd_pcm_hw_params_set_channels_near, ALSA_0.9, ALSA_0.9.0rc4);
6390 OBSOLETE1(snd_pcm_hw_params_set_channels_first, ALSA_0.9, ALSA_0.9.0rc4);
6391 OBSOLETE1(snd_pcm_hw_params_set_channels_last, ALSA_0.9, ALSA_0.9.0rc4);
6393 OBSOLETE1(snd_pcm_hw_params_get_rate, ALSA_0.9, ALSA_0.9.0rc4);
6394 OBSOLETE1(snd_pcm_hw_params_get_rate_min, ALSA_0.9, ALSA_0.9.0rc4);
6395 OBSOLETE1(snd_pcm_hw_params_get_rate_max, ALSA_0.9, ALSA_0.9.0rc4);
6396 OBSOLETE1(snd_pcm_hw_params_set_rate_near, ALSA_0.9, ALSA_0.9.0rc4);
6397 OBSOLETE1(snd_pcm_hw_params_set_rate_first, ALSA_0.9, ALSA_0.9.0rc4);
6398 OBSOLETE1(snd_pcm_hw_params_set_rate_last, ALSA_0.9, ALSA_0.9.0rc4);
6400 OBSOLETE1(snd_pcm_hw_params_get_period_time, ALSA_0.9, ALSA_0.9.0rc4);
6401 OBSOLETE1(snd_pcm_hw_params_get_period_time_min, ALSA_0.9, ALSA_0.9.0rc4);
6402 OBSOLETE1(snd_pcm_hw_params_get_period_time_max, ALSA_0.9, ALSA_0.9.0rc4);
6403 OBSOLETE1(snd_pcm_hw_params_set_period_time_near, ALSA_0.9, ALSA_0.9.0rc4);
6404 OBSOLETE1(snd_pcm_hw_params_set_period_time_first, ALSA_0.9, ALSA_0.9.0rc4);
6405 OBSOLETE1(snd_pcm_hw_params_set_period_time_last, ALSA_0.9, ALSA_0.9.0rc4);
6407 OBSOLETE1(snd_pcm_hw_params_get_period_size, ALSA_0.9, ALSA_0.9.0rc4);
6408 OBSOLETE1(snd_pcm_hw_params_get_period_size_min, ALSA_0.9, ALSA_0.9.0rc4);
6409 OBSOLETE1(snd_pcm_hw_params_get_period_size_max, ALSA_0.9, ALSA_0.9.0rc4);
6410 OBSOLETE1(snd_pcm_hw_params_set_period_size_near, ALSA_0.9, ALSA_0.9.0rc4);
6411 OBSOLETE1(snd_pcm_hw_params_set_period_size_first, ALSA_0.9, ALSA_0.9.0rc4);
6412 OBSOLETE1(snd_pcm_hw_params_set_period_size_last, ALSA_0.9, ALSA_0.9.0rc4);
6414 OBSOLETE1(snd_pcm_hw_params_get_periods, ALSA_0.9, ALSA_0.9.0rc4);
6415 OBSOLETE1(snd_pcm_hw_params_get_periods_min, ALSA_0.9, ALSA_0.9.0rc4);
6416 OBSOLETE1(snd_pcm_hw_params_get_periods_max, ALSA_0.9, ALSA_0.9.0rc4);
6417 OBSOLETE1(snd_pcm_hw_params_set_periods_near, ALSA_0.9, ALSA_0.9.0rc4);
6418 OBSOLETE1(snd_pcm_hw_params_set_periods_first, ALSA_0.9, ALSA_0.9.0rc4);
6419 OBSOLETE1(snd_pcm_hw_params_set_periods_last, ALSA_0.9, ALSA_0.9.0rc4);
6421 OBSOLETE1(snd_pcm_hw_params_get_buffer_time, ALSA_0.9, ALSA_0.9.0rc4);
6422 OBSOLETE1(snd_pcm_hw_params_get_buffer_time_min, ALSA_0.9, ALSA_0.9.0rc4);
6423 OBSOLETE1(snd_pcm_hw_params_get_buffer_time_max, ALSA_0.9, ALSA_0.9.0rc4);
6424 OBSOLETE1(snd_pcm_hw_params_set_buffer_time_near, ALSA_0.9, ALSA_0.9.0rc4);
6425 OBSOLETE1(snd_pcm_hw_params_set_buffer_time_first, ALSA_0.9, ALSA_0.9.0rc4);
6426 OBSOLETE1(snd_pcm_hw_params_set_buffer_time_last, ALSA_0.9, ALSA_0.9.0rc4);
6428 OBSOLETE1(snd_pcm_hw_params_get_buffer_size, ALSA_0.9, ALSA_0.9.0rc4);
6429 OBSOLETE1(snd_pcm_hw_params_get_buffer_size_min, ALSA_0.9, ALSA_0.9.0rc4);
6430 OBSOLETE1(snd_pcm_hw_params_get_buffer_size_max, ALSA_0.9, ALSA_0.9.0rc4);
6431 OBSOLETE1(snd_pcm_hw_params_set_buffer_size_near, ALSA_0.9, ALSA_0.9.0rc4);
6432 OBSOLETE1(snd_pcm_hw_params_set_buffer_size_first, ALSA_0.9, ALSA_0.9.0rc4);
6433 OBSOLETE1(snd_pcm_hw_params_set_buffer_size_last, ALSA_0.9, ALSA_0.9.0rc4);
6435 OBSOLETE1(snd_pcm_hw_params_get_tick_time, ALSA_0.9, ALSA_0.9.0rc4);
6436 OBSOLETE1(snd_pcm_hw_params_get_tick_time_min, ALSA_0.9, ALSA_0.9.0rc4);
6437 OBSOLETE1(snd_pcm_hw_params_get_tick_time_max, ALSA_0.9, ALSA_0.9.0rc4);
6438 OBSOLETE1(snd_pcm_hw_params_set_tick_time_near, ALSA_0.9, ALSA_0.9.0rc4);
6439 OBSOLETE1(snd_pcm_hw_params_set_tick_time_first, ALSA_0.9, ALSA_0.9.0rc4);
6440 OBSOLETE1(snd_pcm_hw_params_set_tick_time_last, ALSA_0.9, ALSA_0.9.0rc4);
6442 #endif /* DOC_HIDDEN */