Mercurial > audlegacy
annotate Plugins/Output/alsa/init.c @ 395:0923a41170bb trunk
[svn] Add S3M support back after receiving a convincing testcase.
author | chainsaw |
---|---|
date | Sat, 07 Jan 2006 06:18:13 -0800 |
parents | 0b48662886e9 |
children | c8cf439179b8 |
rev | line source |
---|---|
61 | 1 /* XMMS - ALSA output plugin |
2 * Copyright (C) 2001-2003 Matthieu Sozeau <mattam@altern.org> | |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
3 * Copyright (C) 2003-2005 Haavard Kvaalen |
61 | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 */ | |
19 #include "alsa.h" | |
20 #include <dlfcn.h> | |
21 #include <ctype.h> | |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
22 |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
23 #define THREAD_BUFFER_TIME_MIN 1000 |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
24 #define THREAD_BUFFER_TIME_MAX 10000 |
61 | 25 |
26 struct alsa_config alsa_cfg; | |
27 | |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
28 void alsa_init(void) |
61 | 29 { |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
30 ConfigDb *cfgfile; |
61 | 31 |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
32 memset(&alsa_cfg, 0, sizeof (alsa_cfg)); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
33 alsa_cfg.buffer_time = 500; |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
34 alsa_cfg.period_time = 50; |
61 | 35 alsa_cfg.thread_buffer_time = 3000; |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
36 alsa_cfg.debug = 0; |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
37 alsa_cfg.vol.left = 100; |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
38 alsa_cfg.vol.right = 100; |
61 | 39 |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
40 cfgfile = bmp_cfg_db_open(); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
41 if (!bmp_cfg_db_get_string(cfgfile, "ALSA", "pcm_device", |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
42 &alsa_cfg.pcm_device)) |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
43 alsa_cfg.pcm_device = g_strdup("default"); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
44 g_message("device: %s", alsa_cfg.pcm_device); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
45 if (!bmp_cfg_db_get_string(cfgfile, "ALSA", "mixer_device", |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
46 &alsa_cfg.mixer_device)) |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
47 alsa_cfg.mixer_device = g_strdup("PCM"); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
48 bmp_cfg_db_get_int(cfgfile, "ALSA", "mixer_card", &alsa_cfg.mixer_card); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
49 bmp_cfg_db_get_int(cfgfile, "ALSA", "buffer_time", &alsa_cfg.buffer_time); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
50 bmp_cfg_db_get_int(cfgfile, "ALSA", "period_time", &alsa_cfg.period_time); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
51 bmp_cfg_db_get_int(cfgfile, "ALSA", "thread_buffer_time", |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
52 &alsa_cfg.thread_buffer_time); |
61 | 53 |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
54 alsa_cfg.thread_buffer_time = CLAMP(alsa_cfg.thread_buffer_time, |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
55 THREAD_BUFFER_TIME_MIN, |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
56 THREAD_BUFFER_TIME_MAX); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
57 |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
58 bmp_cfg_db_get_bool(cfgfile, "ALSA", "soft_volume", |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
59 &alsa_cfg.soft_volume); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
60 bmp_cfg_db_get_int(cfgfile, "ALSA", "volume_left", &alsa_cfg.vol.left); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
61 bmp_cfg_db_get_int(cfgfile, "ALSA", "volume_right", &alsa_cfg.vol.right); |
61 | 62 |
211
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
63 bmp_cfg_db_get_bool(cfgfile, "ALSA", "debug", &alsa_cfg.debug); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
64 bmp_cfg_db_close(cfgfile); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
65 |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
66 if (dlopen("libasound.so.2", RTLD_NOW | RTLD_GLOBAL) == NULL) |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
67 { |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
68 g_message("Cannot load alsa library: %s", dlerror()); |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
69 /* FIXME, this plugin wont work... */ |
0b48662886e9
[svn] Sync ALSA plugin with enhancements/patches from Fatal (XMMS cvs)
nenolod
parents:
61
diff
changeset
|
70 } |
61 | 71 } |