pulseaudio  14.2
About: PulseAudio is a networked sound server (for POSIX OSes), a proxy for your sound applications.
  Fossies Dox: pulseaudio-14.2.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

alsa-util.c File Reference
#include <sys/types.h>
#include <alsa/asoundlib.h>
#include <pulse/sample.h>
#include <pulse/xmalloc.h>
#include <pulse/timeval.h>
#include <pulse/util.h>
#include <pulse/utf8.h>
#include <pulsecore/i18n.h>
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-util.h>
#include <pulsecore/atomic.h>
#include <pulsecore/core-error.h>
#include <pulsecore/thread.h>
#include <pulsecore/conf-parser.h>
#include <pulsecore/core-rtclock.h>
#include "alsa-util.h"
#include "alsa-mixer.h"
Include dependency graph for alsa-util.c:

Go to the source code of this file.

Macros

#define SND_MIXER_ELEM_PULSEAUDIO   (SND_MIXER_ELEM_LAST + 10)
 

Functions

static int set_format (snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_sample_format_t *f)
 This file is part of PulseAudio. More...
 
static int set_period_size (snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, snd_pcm_uframes_t size)
 
static int set_buffer_size (snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, snd_pcm_uframes_t size)
 
static void check_access (snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, bool use_mmap)
 
int pa_alsa_set_hw_params (snd_pcm_t *pcm_handle, pa_sample_spec *ss, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size, snd_pcm_uframes_t tsched_size, bool *use_mmap, bool *use_tsched, bool require_exact_channel_number)
 
int pa_alsa_set_sw_params (snd_pcm_t *pcm, snd_pcm_uframes_t avail_min, bool period_event)
 
snd_pcm_t * pa_alsa_open_by_device_id_auto (const char *dev_id, char **dev, pa_sample_spec *ss, pa_channel_map *map, int mode, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size, snd_pcm_uframes_t tsched_size, bool *use_mmap, bool *use_tsched, pa_alsa_profile_set *ps, pa_alsa_mapping **mapping)
 
snd_pcm_t * pa_alsa_open_by_device_id_mapping (const char *dev_id, char **dev, pa_sample_spec *ss, pa_channel_map *map, int mode, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size, snd_pcm_uframes_t tsched_size, bool *use_mmap, bool *use_tsched, pa_alsa_mapping *m)
 
snd_pcm_t * pa_alsa_open_by_device_string (const char *device, char **dev, pa_sample_spec *ss, pa_channel_map *map, int mode, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size, snd_pcm_uframes_t tsched_size, bool *use_mmap, bool *use_tsched, bool require_exact_channel_number)
 
snd_pcm_t * pa_alsa_open_by_template (char **template, const char *dev_id, char **dev, pa_sample_spec *ss, pa_channel_map *map, int mode, snd_pcm_uframes_t *period_size, snd_pcm_uframes_t *buffer_size, snd_pcm_uframes_t tsched_size, bool *use_mmap, bool *use_tsched, bool require_exact_channel_number)
 
void pa_alsa_dump (pa_log_level_t level, snd_pcm_t *pcm)
 
void pa_alsa_dump_status (snd_pcm_t *pcm)
 
static void alsa_error_handler (const char *file, int line, const char *function, int err, const char *fmt,...)
 
void pa_alsa_refcnt_inc (void)
 
void pa_alsa_refcnt_dec (void)
 
bool pa_alsa_init_description (pa_proplist *p, pa_card *card)
 
void pa_alsa_init_proplist_card (pa_core *c, pa_proplist *p, int card)
 
void pa_alsa_init_proplist_pcm_info (pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info)
 
void pa_alsa_init_proplist_pcm (pa_core *c, pa_proplist *p, snd_pcm_t *pcm)
 
void pa_alsa_init_proplist_ctl (pa_proplist *p, const char *name)
 
int pa_alsa_recover_from_poll (snd_pcm_t *pcm, int revents)
 
pa_rtpoll_itempa_alsa_build_pollfd (snd_pcm_t *pcm, pa_rtpoll *rtpoll)
 
snd_pcm_sframes_t pa_alsa_safe_avail (snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss)
 
int pa_alsa_safe_delay (snd_pcm_t *pcm, snd_pcm_status_t *status, snd_pcm_sframes_t *delay, size_t hwbuf_size, const pa_sample_spec *ss, bool capture)
 
int pa_alsa_safe_mmap_begin (snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss)
 
char * pa_alsa_get_driver_name (int card)
 
char * pa_alsa_get_driver_name_by_pcm (snd_pcm_t *pcm)
 
char * pa_alsa_get_reserve_name (const char *device)
 
unsigned int * pa_alsa_get_supported_rates (snd_pcm_t *pcm, unsigned int fallback_rate)
 
pa_sample_format_tpa_alsa_get_supported_formats (snd_pcm_t *pcm, pa_sample_format_t fallback_format)
 
bool pa_alsa_pcm_is_hw (snd_pcm_t *pcm)
 
bool pa_alsa_pcm_is_modem (snd_pcm_t *pcm)
 
 PA_STATIC_TLS_DECLARE (cstrerror, pa_xfree)
 
const char * pa_alsa_strerror (int errnum)
 
bool pa_alsa_may_tsched (bool want)
 
static snd_mixer_elem_t * pa_alsa_mixer_find (snd_mixer_t *mixer, snd_ctl_elem_iface_t iface, const char *name, unsigned int index, unsigned int device)
 
snd_mixer_elem_t * pa_alsa_mixer_find_card (snd_mixer_t *mixer, struct pa_alsa_mixer_id *alsa_id, unsigned int device)
 
snd_mixer_elem_t * pa_alsa_mixer_find_pcm (snd_mixer_t *mixer, const char *name, unsigned int device)
 
static int mixer_class_compare (const snd_mixer_elem_t *c1, const snd_mixer_elem_t *c2)
 
static int mixer_class_event (snd_mixer_class_t *class, unsigned int mask, snd_hctl_elem_t *helem, snd_mixer_elem_t *melem)
 
static int prepare_mixer (snd_mixer_t *mixer, const char *dev)
 
snd_mixer_t * pa_alsa_open_mixer (pa_hashmap *mixers, int alsa_card_index, bool probe)
 
snd_mixer_t * pa_alsa_open_mixer_by_name (pa_hashmap *mixers, const char *dev, bool probe)
 
snd_mixer_t * pa_alsa_open_mixer_for_pcm (pa_hashmap *mixers, snd_pcm_t *pcm, bool probe)
 
void pa_alsa_mixer_set_fdlist (pa_hashmap *mixers, snd_mixer_t *mixer_handle, pa_mainloop_api *ml)
 
void pa_alsa_mixer_free (pa_alsa_mixer *mixer)
 
int pa_alsa_get_hdmi_eld (snd_hctl_elem_t *elem, pa_hdmi_eld *eld)
 

Variables

static pa_atomic_t n_error_handler_installed = PA_ATOMIC_INIT(0)
 

Macro Definition Documentation

◆ SND_MIXER_ELEM_PULSEAUDIO

#define SND_MIXER_ELEM_PULSEAUDIO   (SND_MIXER_ELEM_LAST + 10)

Definition at line 1611 of file alsa-util.c.

Function Documentation

◆ alsa_error_handler()

static void alsa_error_handler ( const char *  file,
int  line,
const char *  function,
int  err,
const char *  fmt,
  ... 
)
static

Definition at line 870 of file alsa-util.c.

References PA_LOG_INFO, pa_log_levelv_meta(), pa_sprintf_malloc(), and pa_xfree().

Referenced by pa_alsa_refcnt_inc().

◆ check_access()

static void check_access ( snd_pcm_t *  pcm_handle,
snd_pcm_hw_params_t *  hwparams,
bool  use_mmap 
)
static

Definition at line 184 of file alsa-util.c.

References pa_log_debug(), and pa_log_error().

Referenced by pa_alsa_set_hw_params().

◆ mixer_class_compare()

static int mixer_class_compare ( const snd_mixer_elem_t *  c1,
const snd_mixer_elem_t *  c2 
)
static

Definition at line 1646 of file alsa-util.c.

Referenced by prepare_mixer().

◆ mixer_class_event()

static int mixer_class_event ( snd_mixer_class_t *  class,
unsigned int  mask,
snd_hctl_elem_t *  helem,
snd_mixer_elem_t *  melem 
)
static

Definition at line 1652 of file alsa-util.c.

References pa_alsa_strerror(), pa_log_info(), pa_log_warn(), and SND_MIXER_ELEM_PULSEAUDIO.

Referenced by prepare_mixer().

◆ pa_alsa_build_pollfd()

pa_rtpoll_item* pa_alsa_build_pollfd ( snd_pcm_t *  pcm,
pa_rtpoll rtpoll 
)

◆ pa_alsa_dump()

void pa_alsa_dump ( pa_log_level_t  level,
snd_pcm_t *  pcm 
)

◆ pa_alsa_dump_status()

void pa_alsa_dump_status ( snd_pcm_t *  pcm)

Definition at line 837 of file alsa-util.c.

References pa_alsa_strerror(), pa_assert, pa_cstrerror(), pa_log_debug(), and pa_strnull().

◆ pa_alsa_get_driver_name()

char* pa_alsa_get_driver_name ( int  card)

◆ pa_alsa_get_driver_name_by_pcm()

char* pa_alsa_get_driver_name_by_pcm ( snd_pcm_t *  pcm)

◆ pa_alsa_get_hdmi_eld()

int pa_alsa_get_hdmi_eld ( snd_hctl_elem_t *  elem,
pa_hdmi_eld eld 
)

Definition at line 1844 of file alsa-util.c.

References device, pa_hdmi_eld::monitor_name, pa_assert, pa_log_debug(), pa_log_warn(), and value.

Referenced by hdmi_eld_changed().

◆ pa_alsa_get_reserve_name()

char* pa_alsa_get_reserve_name ( const char *  device)

Definition at line 1388 of file alsa-util.c.

References depmod::k, pa_assert, pa_atoi(), and pa_sprintf_malloc().

Referenced by pa__init(), reserve_init(), and reserve_monitor_init().

◆ pa_alsa_get_supported_formats()

◆ pa_alsa_get_supported_rates()

unsigned int* pa_alsa_get_supported_rates ( snd_pcm_t *  pcm,
unsigned int  fallback_rate 
)

Definition at line 1409 of file alsa-util.c.

References pa_alsa_strerror(), PA_ELEMENTSOF, pa_log_debug(), pa_xfree(), and pa_xnew.

Referenced by pa_alsa_sink_new(), and pa_alsa_source_new().

◆ pa_alsa_init_description()

◆ pa_alsa_init_proplist_card()

void pa_alsa_init_proplist_card ( pa_core c,
pa_proplist p,
int  card 
)

◆ pa_alsa_init_proplist_ctl()

void pa_alsa_init_proplist_ctl ( pa_proplist p,
const char *  name 
)

Definition at line 1037 of file alsa-util.c.

References pa_assert, pa_log_warn(), and pa_proplist_sets().

Referenced by pa_alsa_sink_new(), and pa_alsa_source_new().

◆ pa_alsa_init_proplist_pcm()

void pa_alsa_init_proplist_pcm ( pa_core c,
pa_proplist p,
snd_pcm_t *  pcm 
)

◆ pa_alsa_init_proplist_pcm_info()

void pa_alsa_init_proplist_pcm_info ( pa_core c,
pa_proplist p,
snd_pcm_info_t *  pcm_info 
)

◆ pa_alsa_may_tsched()

bool pa_alsa_may_tsched ( bool  want)

Definition at line 1589 of file alsa-util.c.

References pa_log_notice(), pa_rtclock_hrtimer(), and pa_running_in_vm().

Referenced by pa_alsa_sink_new(), and pa_alsa_source_new().

◆ pa_alsa_mixer_find()

static snd_mixer_elem_t* pa_alsa_mixer_find ( snd_mixer_t *  mixer,
snd_ctl_elem_iface_t  iface,
const char *  name,
unsigned int  index,
unsigned int  device 
)
static

Definition at line 1613 of file alsa-util.c.

References pa_streq, and SND_MIXER_ELEM_PULSEAUDIO.

Referenced by pa_alsa_mixer_find_card(), and pa_alsa_mixer_find_pcm().

◆ pa_alsa_mixer_find_card()

snd_mixer_elem_t* pa_alsa_mixer_find_card ( snd_mixer_t *  mixer,
struct pa_alsa_mixer_id alsa_id,
unsigned int  device 
)

Definition at line 1638 of file alsa-util.c.

References pa_alsa_mixer_id::index, pa_alsa_mixer_id::name, and pa_alsa_mixer_find().

Referenced by init_jacks(), and jack_probe().

◆ pa_alsa_mixer_find_pcm()

snd_mixer_elem_t* pa_alsa_mixer_find_pcm ( snd_mixer_t *  mixer,
const char *  name,
unsigned int  device 
)

Definition at line 1642 of file alsa-util.c.

References pa_alsa_mixer_find().

Referenced by init_eld_ctls().

◆ pa_alsa_mixer_free()

void pa_alsa_mixer_free ( pa_alsa_mixer mixer)

Definition at line 1835 of file alsa-util.c.

References pa_alsa_mixer::fdl, pa_alsa_mixer::mixer_handle, pa_alsa_fdlist_free(), and pa_xfree().

Referenced by find_mixer(), and pa__init().

◆ pa_alsa_mixer_set_fdlist()

void pa_alsa_mixer_set_fdlist ( pa_hashmap mixers,
snd_mixer_t *  mixer_handle,
pa_mainloop_api ml 
)

◆ pa_alsa_open_by_device_id_auto()

snd_pcm_t* pa_alsa_open_by_device_id_auto ( const char *  dev_id,
char **  dev,
pa_sample_spec ss,
pa_channel_map map,
int  mode,
snd_pcm_uframes_t *  period_size,
snd_pcm_uframes_t *  buffer_size,
snd_pcm_uframes_t  tsched_size,
bool *  use_mmap,
bool *  use_tsched,
pa_alsa_profile_set ps,
pa_alsa_mapping **  mapping 
)

◆ pa_alsa_open_by_device_id_mapping()

snd_pcm_t* pa_alsa_open_by_device_id_mapping ( const char *  dev_id,
char **  dev,
pa_sample_spec ss,
pa_channel_map map,
int  mode,
snd_pcm_uframes_t *  period_size,
snd_pcm_uframes_t *  buffer_size,
snd_pcm_uframes_t  tsched_size,
bool *  use_mmap,
bool *  use_tsched,
pa_alsa_mapping m 
)

◆ pa_alsa_open_by_device_string()

snd_pcm_t* pa_alsa_open_by_device_string ( const char *  device,
char **  dev,
pa_sample_spec ss,
pa_channel_map map,
int  mode,
snd_pcm_uframes_t *  period_size,
snd_pcm_uframes_t *  buffer_size,
snd_pcm_uframes_t  tsched_size,
bool *  use_mmap,
bool *  use_tsched,
bool  require_exact_channel_number 
)

◆ pa_alsa_open_by_template()

snd_pcm_t* pa_alsa_open_by_template ( char **  template,
const char *  dev_id,
char **  dev,
pa_sample_spec ss,
pa_channel_map map,
int  mode,
snd_pcm_uframes_t *  period_size,
snd_pcm_uframes_t *  buffer_size,
snd_pcm_uframes_t  tsched_size,
bool *  use_mmap,
bool *  use_tsched,
bool  require_exact_channel_number 
)

◆ pa_alsa_open_mixer()

snd_mixer_t* pa_alsa_open_mixer ( pa_hashmap mixers,
int  alsa_card_index,
bool  probe 
)

◆ pa_alsa_open_mixer_by_name()

◆ pa_alsa_open_mixer_for_pcm()

snd_mixer_t* pa_alsa_open_mixer_for_pcm ( pa_hashmap mixers,
snd_pcm_t *  pcm,
bool  probe 
)

Definition at line 1803 of file alsa-util.c.

References pa_alsa_open_mixer(), and pa_assert.

Referenced by find_mixer(), and mapping_paths_probe().

◆ pa_alsa_pcm_is_hw()

bool pa_alsa_pcm_is_hw ( snd_pcm_t *  pcm)

Definition at line 1538 of file alsa-util.c.

References pa_assert.

Referenced by pa_alsa_set_hw_params(), pa_alsa_sink_new(), and update_sw_params().

◆ pa_alsa_pcm_is_modem()

bool pa_alsa_pcm_is_modem ( snd_pcm_t *  pcm)

Definition at line 1550 of file alsa-util.c.

References pa_assert.

Referenced by pa_alsa_sink_new(), and pa_alsa_source_new().

◆ pa_alsa_recover_from_poll()

int pa_alsa_recover_from_poll ( snd_pcm_t *  pcm,
int  revents 
)

◆ pa_alsa_refcnt_dec()

void pa_alsa_refcnt_dec ( void  )

Definition at line 894 of file alsa-util.c.

References n_error_handler_installed, pa_assert_se, and pa_atomic_dec().

Referenced by pa__done().

◆ pa_alsa_refcnt_inc()

void pa_alsa_refcnt_inc ( void  )

Definition at line 887 of file alsa-util.c.

References alsa_error_handler(), n_error_handler_installed, and pa_atomic_inc().

Referenced by pa__init().

◆ pa_alsa_safe_avail()

◆ pa_alsa_safe_delay()

int pa_alsa_safe_delay ( snd_pcm_t *  pcm,
snd_pcm_status_t *  status,
snd_pcm_sframes_t *  delay,
size_t  hwbuf_size,
const pa_sample_spec ss,
bool  capture 
)

◆ pa_alsa_safe_mmap_begin()

int pa_alsa_safe_mmap_begin ( snd_pcm_t *  pcm,
const snd_pcm_channel_area_t **  areas,
snd_pcm_uframes_t *  offset,
snd_pcm_uframes_t *  frames,
size_t  hwbuf_size,
const pa_sample_spec ss 
)

◆ pa_alsa_set_hw_params()

int pa_alsa_set_hw_params ( snd_pcm_t *  pcm_handle,
pa_sample_spec ss,
snd_pcm_uframes_t *  period_size,
snd_pcm_uframes_t *  buffer_size,
snd_pcm_uframes_t  tsched_size,
bool *  use_mmap,
bool *  use_tsched,
bool  require_exact_channel_number 
)

◆ pa_alsa_set_sw_params()

int pa_alsa_set_sw_params ( snd_pcm_t *  pcm,
snd_pcm_uframes_t  avail_min,
bool  period_event 
)

Definition at line 462 of file alsa-util.c.

References pa_alsa_strerror(), pa_assert, pa_log_error(), and pa_log_warn().

Referenced by update_sw_params().

◆ pa_alsa_strerror()

◆ PA_STATIC_TLS_DECLARE()

PA_STATIC_TLS_DECLARE ( cstrerror  ,
pa_xfree   
)

◆ prepare_mixer()

static int prepare_mixer ( snd_mixer_t *  mixer,
const char *  dev 
)
static

◆ set_buffer_size()

static int set_buffer_size ( snd_pcm_t *  pcm_handle,
snd_pcm_hw_params_t *  hwparams,
snd_pcm_uframes_t  size 
)
static

Definition at line 170 of file alsa-util.c.

References pa_alsa_strerror(), pa_assert, and pa_log_info().

Referenced by pa_alsa_set_hw_params().

◆ set_format()

static int set_format ( snd_pcm_t *  pcm_handle,
snd_pcm_hw_params_t *  hwparams,
pa_sample_format_t f 
)
static

This file is part of PulseAudio.

Copyright 2004-2009 Lennart Poettering Copyright 2006 Pierre Ossman ossma.nosp@m.n@ce.nosp@m.ndio..nosp@m.se for Cendio AB

PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

PulseAudio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, see http://www.gnu.org/licenses/.

Definition at line 51 of file alsa-util.c.

References depmod::f, pa_alsa_strerror(), pa_assert, PA_ELEMENTSOF, pa_log_debug(), PA_SAMPLE_ALAW, PA_SAMPLE_FLOAT32BE, PA_SAMPLE_FLOAT32LE, PA_SAMPLE_FLOAT32NE, PA_SAMPLE_FLOAT32RE, PA_SAMPLE_S16BE, PA_SAMPLE_S16LE, PA_SAMPLE_S16NE, PA_SAMPLE_S16RE, PA_SAMPLE_S24_32BE, PA_SAMPLE_S24_32LE, PA_SAMPLE_S24_32NE, PA_SAMPLE_S24_32RE, PA_SAMPLE_S24BE, PA_SAMPLE_S24LE, PA_SAMPLE_S24NE, PA_SAMPLE_S24RE, PA_SAMPLE_S32BE, PA_SAMPLE_S32LE, PA_SAMPLE_S32NE, PA_SAMPLE_S32RE, PA_SAMPLE_U8, and PA_SAMPLE_ULAW.

Referenced by pa_alsa_set_hw_params(), and pa_format_info_from_sample_spec2().

◆ set_period_size()

static int set_period_size ( snd_pcm_t *  pcm_handle,
snd_pcm_hw_params_t *  hwparams,
snd_pcm_uframes_t  size 
)
static

Definition at line 145 of file alsa-util.c.

References pa_alsa_strerror(), pa_assert, and pa_log_info().

Referenced by pa_alsa_set_hw_params().

Variable Documentation

◆ n_error_handler_installed

pa_atomic_t n_error_handler_installed = PA_ATOMIC_INIT(0)
static

Definition at line 885 of file alsa-util.c.

Referenced by pa_alsa_refcnt_dec(), and pa_alsa_refcnt_inc().