]> code.delx.au - pulseaudio/blob - src/pulsecore/core-format.c
6e7c1fb5bc97f2123df80c57bb12cb12a3ab0c3c
[pulseaudio] / src / pulsecore / core-format.c
1 /***
2 This file is part of PulseAudio.
3
4 PulseAudio is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License,
7 or (at your option) any later version.
8
9 PulseAudio is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with PulseAudio; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 USA.
18 ***/
19
20 #ifdef HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23
24 #include "core-format.h"
25
26 #include <pulse/def.h>
27
28 #include <pulsecore/macro.h>
29
30 int pa_format_info_to_sample_spec_fake(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
31 int rate;
32
33 pa_assert(f);
34 pa_assert(ss);
35
36 /* Note: When we add support for non-IEC61937 encapsulated compressed
37 * formats, this function should return a non-zero values for these. */
38
39 ss->format = PA_SAMPLE_S16LE;
40 ss->channels = 2;
41
42 if (map)
43 pa_channel_map_init_stereo(map);
44
45 pa_return_val_if_fail(pa_format_info_get_prop_int(f, PA_PROP_FORMAT_RATE, &rate) == 0, -PA_ERR_INVALID);
46 ss->rate = (uint32_t) rate;
47
48 if (f->encoding == PA_ENCODING_EAC3_IEC61937)
49 ss->rate *= 4;
50
51 return 0;
52 }