Commit graph

256 commits

Author SHA1 Message Date
Cezary Rojewski
d8000f57fc pcm: Add MSBITS subformat options
Improve granularity of format selection for S32/U32 formats by adding
masks representing 20, 24 and 32 most significant bits.

Closes: https://github.com/alsa-project/alsa-lib/pull/342
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-08 20:03:46 +01:00
Cezary Rojewski
f33284e85e pcm: Introduce snd_pcm_subformat_value()
Allow userspace applications to select subformats easily just like in
snd_pcm_format_t case - by string conversion.

Closes: https://github.com/alsa-project/alsa-lib/pull/342
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-12-08 20:03:28 +01:00
borine
23931800da doxygen: pcm: silence 'not documented' warnings
From: borine@github
Link: https://github.com/alsa-project/alsa-lib/pull/340
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-09-01 16:11:30 +02:00
Jaroslav Kysela
d6d5982d3a pcm: add SND_PCM_EINTR open mode
Add possibility to return -EINTR instead waiting for the event. The
applications may want to handle -EINTR condition themselves.

BugLink: https://github.com/alsa-project/alsa-lib/issues/228
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 15:59:15 +02:00
Jaroslav Kysela
e2d9e41174 pcm: improve handling for snd_pcm_wait()
The snd_pcm_wait() function is called also internally from
the various plugins to wait for the drain with -1 and from i/o
routines in pcm.c.

Define two special negative timeout values to distinguish the
drain and i/o wait and calculate the maximal timeout according
the wait place.

Fixes: https://github.com/alsa-project/alsa-lib/issues/228
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 15:59:15 +02:00
Jaroslav Kysela
264d6c43ee pcm: hw: introduce SNDRV_PCM_HW_PARAMS_DRAIN_SILENCE
The application may not require to touch the playback
sample stream for the drain operation at all. In this case,
the application is responsible to setup a silencing mechanism
for the playback or another graceful stop (like using the
rewind operation).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 15:58:56 +02:00
Jaroslav Kysela
90e25887d2 pcm: hw: introduce SNDRV_PCM_INFO_PERFECT_DRAIN
Handle the driver informing us that it is not necessary to set up
silencing upon playback draining. This will be the case for drivers
which are guaranteed to not read any samples beyond the application
pointer.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2023-05-03 14:00:57 +02:00
Takashi Iwai
a5e11f9a81 pcm: Move snd_pcm_channel_area_addr() and _step() to public header
Used in the rate plugins commonly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-06-21 14:22:36 +02:00
Takashi Iwai
a9cbfecd87 pcm: Fix a typo in SND_PCM_AUDIO_TSTAMP_TYPE_LAST definition
It was wrongly defined with SNDRV_ prefix.  Fix it.

Fixes: ea02dbd20a ("pcm: Add snd_pcm_audio_tstamp_type_t constants")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-22 16:11:05 +01:00
David Henningsson
ea02dbd20a pcm: Add snd_pcm_audio_tstamp_type_t constants
These are mostly a copy-paste from the kernel headers. But since functions
snd_pcm_audio_tstamp_config make use of these they should be added to the
public API as well.

Reported-by: Alex Moon <alex.r.moon@gmail.com>
Signed-off-by: David Henningsson <diwic@ubuntu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-12-17 11:25:57 +01:00
Jaroslav Kysela
7f084af4e4 a set of fixes to reduce gcc warnings
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-03-27 15:16:41 +02:00
Timo Wischer
22618077e7 pcm: Provide areas_copy function which handles buffer wrap around
The already existing areas_copy functions do not care about the end of
the source and destination buffer.
Therefore the caller has to take care that the requested offset+size
is not exceeding any buffer limit.

This additional function will take care about the end of an buffer
and will continue at the beginning of the buffer.
For example this is required when copying between buffers with
different sizes (not multiple of).
This is often the case in IO plugins like the JACK plugin.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-03-13 22:13:15 +01:00
Maciej S. Szmigiero
d67e42c139 pcm: add and describe SND_PCM_FORMAT_{S, U}20
This patch adds and describes in various functions that query format
properties SND_PCM_FORMAT_{S,U}20 formats that were recently added to the
kernel as SNDRV_PCM_FORMAT_{S,U}20.

These formats are similar to existing 20-bit PCM formats
SND_PCM_FORMAT_{S,U}20_3, however they occupy 4 bytes instead of 3.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-12-18 15:40:36 +01:00
Jaroslav Kysela
5b9041bced Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:29:26 +01:00
Natanael Copa
adab355f35 cleanup: Use uint*_t instead of u_int*_t everythwere
Use the standard uint{8,16,32,64}_t everywhere instead of the
non-standard u_int{8,16,32,64}_t.

This changes the types in the public headers and removes the u_int*_t
defines. This may break things. However, indentifiers ending with _t are
reserved by POSIX[1]; defining those can lead to undefined behavior.

So if you rely on alsa-lib defining those for you, then you want the
compiler to error so things can be fixed properly.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_02

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-07-15 09:50:17 +02:00
David Henningsson
3313f8740d pcm: Fix doxygen for two enums
The doxygen comments were wrong, making doxygen output weird.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-24 22:26:11 +02:00
Pierre-Louis Bossart
6ec2464f39 pcm: add support for get/set_audio_htstamp_config
Enable kernel-side functionality by letting user select what sort of
timestamp it desires

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-02 17:02:03 +02:00
Pierre-Louis Bossart
6cb31b4444 pcm: add helper functions to query timestamping capabilities
extend support to link, link_estimated and link_synchronized
timestamp. wall-clock is deprecated

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-02 17:02:03 +02:00
Jussi Laako
b14c49ab3d pcm: Fix DSD sample format endianess and add big-endian format
This patch adds big-endian DSD sample format and fixes return value of DSD
formats for snd_pcm_format_little_endian().

Signed-off-by: Jussi Laako <jussi@sonarnerd.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-21 15:11:05 +01:00
Jurgen Kramer
e59ffbf30e pcm: add new 32-bit DSD sample format
Add the new DSD_U32_LE sample format to alsa-lib.

NB include/pcm.h and include/sound/asound.h are updated so a new sync with the
kernel headers is not needed

Signed-off-by: Jurgen Kramer <gtmkramer@xs4all.nl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-09-10 09:10:50 +02:00
Takashi Iwai
0d393c29a2 pcm: Add sw_params API functions to get/set timestamp type
For obtaining / changing the timestamp type, add the corresponding
sw_params accessor API functions together with the public definitions
of timestamp types.

This patch only adds the functions and defines but doesn't bring the
functional changes yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-07-14 18:12:21 +02:00
Takashi Iwai
30122df4fa Use __inline__ for exported headers
Some programs are still using C90.

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=817077
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-25 09:52:33 +02:00
Daniel Mack
886f0cc3c2 bring pcm.h and pcm.c in sync with the kernel list
In particular, this adds definitions and descriptions for G.723 and
DSD types.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-18 11:45:11 +02:00
Jaroslav Kysela
b6eb0f9bfd all places: doxygen cleanups
I see no errors with these changes using doxygen 1.8.1.1 .

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 16:42:24 +02:00
Jaroslav Kysela
e23fb2c4de control, pcm: implement snd_ctl_abort() and snd_pcm_abort() functions
Upon an interrupt, it is necessary to abort the wait loops with the EINTR
error code. Introduce snd_*_abort() functions to handle this case.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-08 13:28:03 +02:00
Takashi Iwai
67d692af48 PCM: Add more chmap definitions for UAC2
The new PCM chmap positions have been added in (to be) 3.8-rc1 kernel,
and now updated alsa-lib, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26 18:10:26 +01:00
Pierre-Louis Bossart
cf40ea169a pcm: support for audio timestamps
add new snd_pcm_status_get_audio_htstamp() routine to
query the audio timestamps provided by the kernel.

This change provides applications with better ways
to track elapsed time. Before this patch, applications
would subtract queued samples (delay) from written samples,
resulting in a 1-2 sample error.

Also add snd_pcm_hw_params_supports_audio_wallclock_ts()
to query what the hardware supports.

TODO: check protocol compatibility?

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-25 00:13:51 +02:00
Takashi Iwai
63f6f4a610 PCM: A few doxygen fixes for chmap stuff
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:38:59 +02:00
Takashi Iwai
f7300682dc PCM: Define MONO and other channel map positions
Follow the new definitions in the kernel side.  MONO and others have
been added, and the order of position table was changed again.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:59 +02:00
Takashi Iwai
25f3259b48 PCM: Add snd_pcm_chmap_long_name()
Just return a more verbose name than snd_pcm_chmap_name(), but
including white spaces.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
fe81684745 PCM: Add SND_CHMAP_API_VERSION definition
Just to make it easier for apps to support chmap conditionally via
simple ifdefs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
b4c64e815a PCM: Add string conversion helper functions for chmap
Added a few helper functions between chmap and string.
  snd_pcm_chmap_type_name() -- a string of the given chmap type
  snd_pcm_chmap_name() -- a string of the given channel position
  snd_pcm_chmap_print() -- print channel map on the given buffer
  snd_pcm_chmap_from_string() -- get a channel position from string
  snd_pcm_parse_string() -- parse the whole channel map from string

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
6950a1030c PCM: Fix prefix for snd_pcm_chmap_type enum members
Add _TYPE prefix to distinguish from the channel position.
Also add SND_CHMAP_TYPE_LAST entry pointing the last one like other
enums.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
01dc0e6825 PCM: Implement snd_pcm_query_chmaps_from_hw()
This is a function similar like snd_pcm_query_chmaps() but performs
the query without a PCM handle.  The card, device and substream
numbers are passed as well as stream direction.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
9c1a0ce72d PCM: Introduce snd_pcm_chmap_t and snd_pcm_chmap_query_t
Instead of passing ambiguous integer array, define snd_pcm_chmap_t and
snd_pcm_chmap_query_t so that user can understand more easily which
element is for what.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
48c2c90f19 Add SND_CHMAP_NA and bit flag definitions
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:58 +02:00
Takashi Iwai
0f36270dd3 Follow channel position definitions to mixer channel in mixer.h
mixer.h already contains some channel position definitions.
To be more consistent over all systems, better to follow the same
order for the new channel map, too.  But since UNKNOWN channel must be
zero but the definition in mixer.h contains -1 as UNKNOWN, simply
shift the value with 1.

If the conversion is required between SND_CHMAP and SND_MIXER_SCHN,
just increment/decrement 1.  Eventually I'll provide helper functions
for that...

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-13 08:24:47 +02:00
Takashi Iwai
915b26bfe8 Define channel map position enum in pcm.h
The original definition is in sound/asound.h, but we need to export to
alsa-lib users, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-11 11:34:50 +02:00
Takashi Iwai
3c4a22ea49 Implement the channel mapping API
Added new channel-mapping API functions.
Not all plugins are covered, especially the route, multi and external
plugins don't work yet.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-11 11:34:50 +02:00
Andrew Eikum
43956de710 Improve hw_params documentation
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-01-19 12:36:39 +01:00
Takashi Iwai
acb423d937 Add snd_{ctl|pcm}_open_fallback() functions
This patch adds new API functions, snd_ctl_open_fallback() and
snd_pcm_open_fallback().  These are just like snd_*_open_lconf() but
used to open a fallback PCM/control.  The difference is that it replaces
the name string with the given original name, so that hctl and other
upper-layers will recognize it as an alias.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-07-27 15:24:13 +02:00
Clemens Ladisch
7c99bd24bc support for period wakeup disabling
Add API to disable period wakeups.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2010-11-15 10:43:13 +01:00
Clemens Ladisch
2905af225f snd_pcm_scope_set_ops: make ops parameter const
The contents of the snd_pcm_scope_ops structure are not going to be
changed, so we might as well declare is as constant.  This change is
backwards compatible, and avoids warnings if some ops structure is
actually defined as const.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-08-10 10:08:25 +02:00
Clemens Ladisch
fa30246096 remove unimplemented functions from headers
Remove some function declarations that are not (no longer) implemented.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2009-08-04 09:11:47 +02:00
Jaroslav Kysela
cc7fec138e Add snd_pcm_avail() and snd_pcm_avail_delay() prototypes
Prototypes for new functions from commit
	fe5391c9da
were lost somehow.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-10-23 09:57:11 +02:00
Jaroslav Kysela
8aaccc9484 Implemented snd_pcm_sw_params_(set|get)_period_event for interrupt wakeup like behaviour
Actually, PCM timer is used as source for poll(). It might be optimized
in the kernel code later.
2008-05-09 16:02:02 +02:00
Jaroslav Kysela
c88672d86f implemented snd_pcm_rewindable() and snd_pcm_forwardable(), removed can_rewind and can_forward 2008-04-21 12:46:50 +02:00
Jaroslav Kysela
82af1df465 added snd_pcm_hw_params_is_monotonic/can_forward/can_rewind functions 2008-04-11 14:11:04 +02:00
Takashi Iwai
c96984f181 Fix conflict of obsoleted snd_pcm_hw_* definitions
When only SND_PCM_OLD_HW_PARAMS_API is defined but no
SND_PCM_OLD_SW_PARAMS_API, the declerations of some obsoleted functions
conflict.  Although the apps should define both at the same time, it's
not good to break.  Fixed the ifdef now.
2008-02-11 14:19:32 +01:00
Takashi Iwai
bf004f1c52 Add SND_PCM_TSTAMP_MMAP back
SND_PCM_TSTAMP_MMAP is used (blidnly) by portaudio, unfortunately.
Re-added it not to break API.
2008-01-14 17:15:13 +01:00