]> code.delx.au - pulseaudio/blob - src/modules/alsa/alsa-util.h
alsa: Use card description in default sink/source prefix when available
[pulseaudio] / src / modules / alsa / alsa-util.h
1 #ifndef fooalsautilhfoo
2 #define fooalsautilhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9
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.
14
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.
19
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
23 USA.
24 ***/
25
26 #include <asoundlib.h>
27
28 #include <pulse/sample.h>
29 #include <pulse/channelmap.h>
30 #include <pulse/proplist.h>
31
32 #include <pulsecore/rtpoll.h>
33 #include <pulsecore/core.h>
34 #include <pulsecore/log.h>
35
36 #include "alsa-mixer.h"
37
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);
47
48 int pa_alsa_set_sw_params(
49 snd_pcm_t *pcm,
50 snd_pcm_uframes_t avail_min,
51 bool period_event);
52
53 /* Picks a working mapping from the profile set based on the specified ss/map */
54 snd_pcm_t *pa_alsa_open_by_device_id_auto(
55 const char *dev_id,
56 char **dev, /* modified at return */
57 pa_sample_spec *ss, /* modified at return */
58 pa_channel_map* map, /* modified at return */
59 int mode,
60 snd_pcm_uframes_t *period_size, /* modified at return */
61 snd_pcm_uframes_t *buffer_size, /* modified at return */
62 snd_pcm_uframes_t tsched_size,
63 bool *use_mmap, /* modified at return */
64 bool *use_tsched, /* modified at return */
65 pa_alsa_profile_set *ps,
66 pa_alsa_mapping **mapping); /* modified at return */
67
68 /* Uses the specified mapping */
69 snd_pcm_t *pa_alsa_open_by_device_id_mapping(
70 const char *dev_id,
71 char **dev, /* modified at return */
72 pa_sample_spec *ss, /* modified at return */
73 pa_channel_map* map, /* modified at return */
74 int mode,
75 snd_pcm_uframes_t *period_size, /* modified at return */
76 snd_pcm_uframes_t *buffer_size, /* modified at return */
77 snd_pcm_uframes_t tsched_size,
78 bool *use_mmap, /* modified at return */
79 bool *use_tsched, /* modified at return */
80 pa_alsa_mapping *mapping);
81
82 /* Opens the explicit ALSA device */
83 snd_pcm_t *pa_alsa_open_by_device_string(
84 const char *dir,
85 char **dev, /* modified at return */
86 pa_sample_spec *ss, /* modified at return */
87 pa_channel_map* map, /* modified at return */
88 int mode,
89 snd_pcm_uframes_t *period_size, /* modified at return */
90 snd_pcm_uframes_t *buffer_size, /* modified at return */
91 snd_pcm_uframes_t tsched_size,
92 bool *use_mmap, /* modified at return */
93 bool *use_tsched, /* modified at return */
94 bool require_exact_channel_number);
95
96 /* Opens the explicit ALSA device with a fallback list */
97 snd_pcm_t *pa_alsa_open_by_template(
98 char **template,
99 const char *dev_id,
100 char **dev, /* modified at return */
101 pa_sample_spec *ss, /* modified at return */
102 pa_channel_map* map, /* modified at return */
103 int mode,
104 snd_pcm_uframes_t *period_size, /* modified at return */
105 snd_pcm_uframes_t *buffer_size, /* modified at return */
106 snd_pcm_uframes_t tsched_size,
107 bool *use_mmap, /* modified at return */
108 bool *use_tsched, /* modified at return */
109 bool require_exact_channel_number);
110
111 void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
112 void pa_alsa_dump_status(snd_pcm_t *pcm);
113
114 void pa_alsa_refcnt_inc(void);
115 void pa_alsa_refcnt_dec(void);
116
117 void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
118 void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
119 void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
120 void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name);
121 bool pa_alsa_init_description(pa_proplist *p, pa_card *card);
122
123 int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
124
125 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
126
127 snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
128 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);
129 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);
130
131 char *pa_alsa_get_driver_name(int card);
132 char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
133
134 char *pa_alsa_get_reserve_name(const char *device);
135
136 unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm, unsigned int fallback_rate);
137
138 bool pa_alsa_pcm_is_hw(snd_pcm_t *pcm);
139 bool pa_alsa_pcm_is_modem(snd_pcm_t *pcm);
140
141 const char* pa_alsa_strerror(int errnum);
142
143 bool pa_alsa_may_tsched(bool want);
144
145 snd_hctl_elem_t* pa_alsa_find_jack(snd_hctl_t *hctl, const char* jack_name);
146 snd_hctl_elem_t* pa_alsa_find_eld_ctl(snd_hctl_t *hctl, int device);
147
148 snd_mixer_t *pa_alsa_open_mixer(int alsa_card_index, char **ctl_device, snd_hctl_t **hctl);
149
150 typedef struct pa_hdmi_eld pa_hdmi_eld;
151 struct pa_hdmi_eld {
152 char monitor_name[17];
153 };
154
155 int pa_alsa_get_hdmi_eld(snd_hctl_t *hctl, int device, pa_hdmi_eld *eld);
156
157 #endif