Mercurial > audlegacy-plugins
annotate src/alsa-ng/alsa-util.c @ 3187:360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
The FMT_*24_* constants are misleading.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 19 Jun 2009 08:38:14 -0500 |
parents | d3cf6d14c960 |
children | 68bb898b8ae0 |
rev | line source |
---|---|
3162
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 * Audacious ALSA Plugin (-ng) |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 * Copyright (c) 2009 William Pitcock <nenolod@dereferenced.org> |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 * |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 * (at your option) any later version. |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 * |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 * |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 */ |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 #include "alsa-stdinc.h" |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 static alsaplug_format_mapping_t alsaplug_format_conv_tbl[] = { |
3185
d3cf6d14c960
alsa-ng: Add support for SND_FLOAT (SND_PCM_FORMAT_FLOAT).
William Pitcock <nenolod@atheme.org>
parents:
3162
diff
changeset
|
23 {FMT_FLOAT, SND_PCM_FORMAT_FLOAT}, |
3187
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
24 {FMT_S32_LE, SND_PCM_FORMAT_S32_LE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
25 {FMT_S32_BE, SND_PCM_FORMAT_S32_BE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
26 {FMT_S32_NE, SND_PCM_FORMAT_S32}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
27 {FMT_S24_LE, SND_PCM_FORMAT_S24_3LE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
28 {FMT_S24_BE, SND_PCM_FORMAT_S24_3BE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
29 #if G_BYTE_ORDER == G_LITTLE_ENDIAN |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
30 {FMT_S24_NE, SND_PCM_FORMAT_S24_3LE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
31 #else |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
32 {FMT_S24_NE, SND_PCM_FORMAT_S24_3BE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
33 #endif |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
34 {FMT_U24_LE, SND_PCM_FORMAT_U24_3LE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
35 {FMT_U24_BE, SND_PCM_FORMAT_U24_3BE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
36 #if G_BYTE_ORDER == G_LITTLE_ENDIAN |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
37 {FMT_U24_NE, SND_PCM_FORMAT_U24_3LE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
38 #else |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
39 {FMT_U24_NE, SND_PCM_FORMAT_U24_3BE}, |
360e92f3211d
alsa-ng: Apparently 24bit values are padded to 32bit, so we need to tell ALSA that.
William Pitcock <nenolod@atheme.org>
parents:
3185
diff
changeset
|
40 #endif |
3162
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 {FMT_S16_LE, SND_PCM_FORMAT_S16_LE}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 {FMT_S16_BE, SND_PCM_FORMAT_S16_BE}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 {FMT_S16_NE, SND_PCM_FORMAT_S16}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 {FMT_U16_LE, SND_PCM_FORMAT_U16_LE}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 {FMT_U16_BE, SND_PCM_FORMAT_U16_BE}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
46 {FMT_U16_NE, SND_PCM_FORMAT_U16}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
47 {FMT_U8, SND_PCM_FORMAT_U8}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 {FMT_S8, SND_PCM_FORMAT_S8}, |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
49 }; |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
50 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
51 snd_pcm_format_t |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
52 alsaplug_format_convert(AFormat fmt) |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
53 { |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
54 gint i; |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
55 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
56 for (i = 0; i < G_N_ELEMENTS(alsaplug_format_conv_tbl); i++) |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
57 { |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
58 if (alsaplug_format_conv_tbl[i].aud_fmt == fmt) |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
59 return alsaplug_format_conv_tbl[i].alsa_fmt; |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
60 } |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
61 |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
62 return SND_PCM_FORMAT_UNKNOWN; |
e387614b9be9
alsa-ng: Import rewritten ALSA plugin. This is still woefully incomplete, but supports basic playback.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
63 } |