[3418] | 1 | //channelmap.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010 |
---|
| 5 | * The code (may) include prototypes and comments (and maybe |
---|
| 6 | * other code fragements) from libpulse*. They are mostly copyrighted by: |
---|
| 7 | * Lennart Poettering <poettering@users.sourceforge.net> and |
---|
| 8 | * Pierre Ossman <drzeus@drzeus.cx> |
---|
| 9 | * |
---|
| 10 | * This file is part of libroarpulse a part of RoarAudio, |
---|
| 11 | * a cross-platform sound system for both, home and professional use. |
---|
| 12 | * See README for details. |
---|
| 13 | * |
---|
| 14 | * This file is free software; you can redistribute it and/or modify |
---|
| 15 | * it under the terms of the GNU General Public License version 3 |
---|
| 16 | * as published by the Free Software Foundation. |
---|
| 17 | * |
---|
| 18 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | * GNU General Public License for more details. |
---|
| 22 | * |
---|
| 23 | * You should have received a copy of the GNU General Public License |
---|
| 24 | * along with this software; see the file COPYING. If not, write to |
---|
| 25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 26 | * |
---|
| 27 | * NOTE for everyone want's to change something and send patches: |
---|
| 28 | * read README and HACKING! There a addition information on |
---|
| 29 | * the license of this document you need to read before you send |
---|
| 30 | * any patches. |
---|
| 31 | * |
---|
| 32 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 33 | * or libpulse*: |
---|
| 34 | * The libs libroaresd, libroararts and libroarpulse link this libroar |
---|
| 35 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 36 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 37 | */ |
---|
| 38 | |
---|
| 39 | #include <libroarpulse/libroarpulse.h> |
---|
| 40 | |
---|
[3419] | 41 | /** Initialize the specified channel map and return a pointer to it */ |
---|
| 42 | pa_channel_map* pa_channel_map_init(pa_channel_map *m); |
---|
| 43 | |
---|
| 44 | /** Initialize the specified channel map for monoaural audio and return a pointer to it */ |
---|
[3420] | 45 | pa_channel_map* pa_channel_map_init_mono(pa_channel_map *m) { |
---|
| 46 | m->channels = 1; |
---|
| 47 | m->map[0] = PA_CHANNEL_POSITION_MONO; |
---|
| 48 | |
---|
| 49 | return m; |
---|
| 50 | } |
---|
[3419] | 51 | |
---|
| 52 | /** Initialize the specified channel map for stereophonic audio and return a pointer to it */ |
---|
[3420] | 53 | pa_channel_map* pa_channel_map_init_stereo(pa_channel_map *m) { |
---|
| 54 | m->channels = 2; |
---|
| 55 | m->map[0] = PA_CHANNEL_POSITION_LEFT; |
---|
| 56 | m->map[1] = PA_CHANNEL_POSITION_RIGHT; |
---|
| 57 | |
---|
| 58 | return m; |
---|
| 59 | } |
---|
[3419] | 60 | |
---|
| 61 | /** Initialize the specified channel map for the specified number |
---|
| 62 | * of channels using default labels and return a pointer to it. */ |
---|
[3420] | 63 | pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, pa_channel_map_def_t def) { |
---|
| 64 | if ( m == NULL || channels == 0 ) |
---|
| 65 | return NULL; |
---|
| 66 | |
---|
| 67 | switch (channels) { |
---|
| 68 | case 1: return pa_channel_map_init_mono(m); break; |
---|
| 69 | case 2: return pa_channel_map_init_stereo(m); break; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | switch (def) { |
---|
| 73 | default: |
---|
| 74 | return NULL; |
---|
| 75 | } |
---|
| 76 | } |
---|
[3419] | 77 | |
---|
| 78 | /** Return a text label for the specified channel position */ |
---|
| 79 | const char* pa_channel_position_to_string(pa_channel_position_t pos); |
---|
| 80 | |
---|
| 81 | /** The maximum length of strings returned by pa_channel_map_snprint() */ |
---|
| 82 | #define PA_CHANNEL_MAP_SNPRINT_MAX 336 |
---|
| 83 | |
---|
| 84 | /** Make a humand readable string from the specified channel map */ |
---|
| 85 | char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map); |
---|
| 86 | |
---|
| 87 | /** Parse a channel position list into a channel map structure. \since 0.8.1 */ |
---|
| 88 | pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s); |
---|
| 89 | |
---|
| 90 | /** Compare two channel maps. Return 1 if both match. */ |
---|
| 91 | int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b); |
---|
| 92 | |
---|
| 93 | /** Return non-zero of the specified channel map is considered valid */ |
---|
| 94 | int pa_channel_map_valid(const pa_channel_map *map); |
---|
| 95 | |
---|
[3418] | 96 | //ll |
---|