1 #ifndef fooalsautilhfoo
2 #define fooalsautilhfoo
5 This file is part of PulseAudio.
7 Copyright 2004-2006 Lennart Poettering
8 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
10 PulseAudio is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published
12 by the Free Software Foundation; either version 2.1 of the License,
13 or (at your option) any later version.
15 PulseAudio is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with PulseAudio; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 #include <asoundlib.h>
28 #include <pulse/sample.h>
29 #include <pulse/channelmap.h>
30 #include <pulse/proplist.h>
32 #include <pulsecore/rtpoll.h>
33 #include <pulsecore/core.h>
34 #include <pulsecore/log.h>
36 #include "alsa-mixer.h"
38 int pa_alsa_set_hw_params(
39 snd_pcm_t *pcm_handle,
40 pa_sample_spec *ss, /* modified at return */
41 snd_pcm_uframes_t *period_size, /* modified at return */
42 snd_pcm_uframes_t *buffer_size, /* modified at return */
43 snd_pcm_uframes_t tsched_size,
44 bool *use_mmap, /* modified at return */
45 bool *use_tsched, /* modified at return */
46 bool require_exact_channel_number);
49 int pa_alsa_set_sw_params(
51 snd_pcm_uframes_t avail_min,
56 int pa_alsa_set_sw_params(
58 snd_pcm_uframes_t avail_min,
62 /* Picks a working mapping from the profile set based on the specified ss/map */
63 snd_pcm_t *pa_alsa_open_by_device_id_auto(
68 char **dev, /* modified at return */
69 pa_sample_spec *ss, /* modified at return */
70 pa_channel_map* map, /* modified at return */
72 snd_pcm_uframes_t *period_size, /* modified at return */
73 snd_pcm_uframes_t *buffer_size, /* modified at return */
74 snd_pcm_uframes_t tsched_size,
75 bool *use_mmap, /* modified at return */
76 bool *use_tsched, /* modified at return */
77 pa_alsa_profile_set *ps,
78 pa_alsa_mapping **mapping); /* modified at return */
80 /* Uses the specified mapping */
81 snd_pcm_t *pa_alsa_open_by_device_id_mapping(
86 char **dev, /* modified at return */
87 pa_sample_spec *ss, /* modified at return */
88 pa_channel_map* map, /* modified at return */
90 snd_pcm_uframes_t *period_size, /* modified at return */
91 snd_pcm_uframes_t *buffer_size, /* modified at return */
92 snd_pcm_uframes_t tsched_size,
93 bool *use_mmap, /* modified at return */
94 bool *use_tsched, /* modified at return */
95 pa_alsa_mapping *mapping);
97 /* Opens the explicit ALSA device */
98 snd_pcm_t *pa_alsa_open_by_device_string(
103 char **dev, /* modified at return */
104 pa_sample_spec *ss, /* modified at return */
105 pa_channel_map* map, /* modified at return */
107 snd_pcm_uframes_t *period_size, /* modified at return */
108 snd_pcm_uframes_t *buffer_size, /* modified at return */
109 snd_pcm_uframes_t tsched_size,
110 bool *use_mmap, /* modified at return */
111 bool *use_tsched, /* modified at return */
112 bool require_exact_channel_number);
114 /* Opens the explicit ALSA device with a fallback list */
115 snd_pcm_t *pa_alsa_open_by_template(
121 char **dev, /* modified at return */
122 pa_sample_spec *ss, /* modified at return */
123 pa_channel_map* map, /* modified at return */
125 snd_pcm_uframes_t *period_size, /* modified at return */
126 snd_pcm_uframes_t *buffer_size, /* modified at return */
127 snd_pcm_uframes_t tsched_size,
128 bool *use_mmap, /* modified at return */
129 bool *use_tsched, /* modified at return */
130 bool require_exact_channel_number);
132 void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
133 void pa_alsa_dump_status(snd_pcm_t *pcm);
135 void pa_alsa_refcnt_inc(void);
136 void pa_alsa_refcnt_dec(void);
138 void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
139 void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
140 void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
141 void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
142 bool pa_alsa_init_description(pa_proplist *p);
144 int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
146 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
148 snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
149 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);
150 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);
152 char *pa_alsa_get_driver_name(int card);
153 char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
155 char *pa_alsa_get_reserve_name(const char *device);
157 unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate);
159 bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
160 bool pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
162 bool pa_alsa_pcm_is_voip(snd_pcm_t *pcm);
165 const char* pa_alsa_strerror(int errnum);
167 bool pa_alsa_may_tsched(bool want);
169 snd_hctl_elem_t* pa_alsa_find_jack(snd_hctl_t *hctl, const char* jack_name);
170 snd_hctl_elem_t* pa_alsa_find_eld_ctl(snd_hctl_t *hctl, int device);
172 snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl_t **hctl);
174 typedef struct pa_hdmi_eld pa_hdmi_eld;
176 char monitor_name[17];
179 int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld);
182 int pa_alsa_set_mixer_control(const char *ctl_name, int val);