comparison src/alsa-ng/alsa-util.c @ 3162:e387614b9be9

alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback. This driver uses the "safe" ALSA API subset, including use of blocking I/O. Right now, it is hardcoded to use "default". Do not complain about bugs in this plugin.
author William Pitcock <nenolod@atheme.org>
date Thu, 14 May 2009 21:05:11 -0500
parents
children d3cf6d14c960
comparison
equal deleted inserted replaced
3161:6dd886b5c72b 3162:e387614b9be9
1 /*
2 * Audacious ALSA Plugin (-ng)
3 * Copyright (c) 2009 William Pitcock <nenolod@dereferenced.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "alsa-stdinc.h"
21
22 static alsaplug_format_mapping_t alsaplug_format_conv_tbl[] = {
23 {FMT_S24_LE, SND_PCM_FORMAT_S24_LE},
24 {FMT_S24_BE, SND_PCM_FORMAT_S24_BE},
25 {FMT_S24_NE, SND_PCM_FORMAT_S24},
26 {FMT_U24_LE, SND_PCM_FORMAT_U24_LE},
27 {FMT_U24_BE, SND_PCM_FORMAT_U24_BE},
28 {FMT_U24_NE, SND_PCM_FORMAT_U24},
29 {FMT_S16_LE, SND_PCM_FORMAT_S16_LE},
30 {FMT_S16_BE, SND_PCM_FORMAT_S16_BE},
31 {FMT_S16_NE, SND_PCM_FORMAT_S16},
32 {FMT_U16_LE, SND_PCM_FORMAT_U16_LE},
33 {FMT_U16_BE, SND_PCM_FORMAT_U16_BE},
34 {FMT_U16_NE, SND_PCM_FORMAT_U16},
35 {FMT_U8, SND_PCM_FORMAT_U8},
36 {FMT_S8, SND_PCM_FORMAT_S8},
37 };
38
39 snd_pcm_format_t
40 alsaplug_format_convert(AFormat fmt)
41 {
42 gint i;
43
44 for (i = 0; i < G_N_ELEMENTS(alsaplug_format_conv_tbl); i++)
45 {
46 if (alsaplug_format_conv_tbl[i].aud_fmt == fmt)
47 return alsaplug_format_conv_tbl[i].alsa_fmt;
48 }
49
50 return SND_PCM_FORMAT_UNKNOWN;
51 }