]> code.delx.au - pulseaudio/blob - src/pulsecore/core-format.h
core-format: Add pa_format_info_from_sample_spec2()
[pulseaudio] / src / pulsecore / core-format.h
1 #ifndef foocoreformathfoo
2 #define foocoreformathfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 PulseAudio is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 2.1 of the License,
10 or (at your option) any later version.
11
12 PulseAudio is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with PulseAudio; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA.
21 ***/
22
23 #include <pulse/format.h>
24
25 #include <stdbool.h>
26
27 /* Gets the sample format stored in the format info. Returns a negative error
28 * code on failure. If the sample format property is not set at all, returns
29 * -PA_ERR_NOENTITY. */
30 int pa_format_info_get_sample_format(pa_format_info *f, pa_sample_format_t *sf);
31
32 /* Gets the sample rate stored in the format info. Returns a negative error
33 * code on failure. If the sample rate property is not set at all, returns
34 * -PA_ERR_NOENTITY. */
35 int pa_format_info_get_rate(pa_format_info *f, uint32_t *rate);
36
37 /* Gets the channel count stored in the format info. Returns a negative error
38 * code on failure. If the channels property is not set at all, returns
39 * -PA_ERR_NOENTITY. */
40 int pa_format_info_get_channels(pa_format_info *f, uint8_t *channels);
41
42 /* Gets the channel map stored in the format info. Returns a negative error
43 * code on failure. If the channel map property is not set at all, returns
44 * -PA_ERR_NOENTITY. */
45 int pa_format_info_get_channel_map(pa_format_info *f, pa_channel_map *map);
46
47 /* Convert a sample spec and an optional channel map to a new PCM format info
48 * object (remember to free it). If map is NULL, then the channel map will be
49 * left unspecified. If some fields of the sample spec should be ignored, pass
50 * false for set_format, set_rate and set_channels as appropriate, then those
51 * fields will be left unspecified. This function returns NULL if the input is
52 * invalid (for example, setting the sample rate was requested, but the rate
53 * in ss is invalid).
54 *
55 * pa_format_info_from_sample_spec() exists too. This "version 2" was created,
56 * because the original function doesn't provide the possibility of ignoring
57 * some of the sample spec fields. That functionality can't be added to the
58 * original function, because the function is a part of the public API and
59 * adding parameters to it would break the API. */
60 pa_format_info *pa_format_info_from_sample_spec2(const pa_sample_spec *ss, const pa_channel_map *map, bool set_format,
61 bool set_rate, bool set_channels);
62
63 /* Convert the format info into a sample spec and a channel map. If the format
64 * info doesn't contain some information, the fallback sample spec and channel
65 * map are used to populate the output.
66 *
67 * pa_format_info_to_sample_spec() exists too. This "version 2" was created,
68 * because the original function doesn't provide the possibility of specifying
69 * a fallback sample spec and channel map. That functionality can't be added to
70 * the original function, because the function is part of the public API and
71 * adding parameters to it would break the API. */
72 int pa_format_info_to_sample_spec2(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map, pa_sample_spec *fallback_ss,
73 pa_channel_map *fallback_map);
74
75 /* For compressed formats. Converts the format info into a sample spec and a
76 * channel map that an ALSA device can use as its configuration parameters when
77 * playing back the compressed data. That is, the returned sample spec doesn't
78 * describe the audio content, but the device parameters. */
79 int pa_format_info_to_sample_spec_fake(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map);
80
81 #endif