61
|
1 /* XMMS - ALSA output plugin
|
|
2 * Copyright (C) 2001-2003 Matthieu Sozeau <mattam@altern.org>
|
|
3 * Copyright (C) 2003-2004 Haavard Kvaalen
|
|
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
|
|
20 #include "libaudacious/configdb.h"
|
|
21 #include "alsa.h"
|
|
22 #include <dlfcn.h>
|
|
23 #include <ctype.h>
|
|
24 #include <glib/gi18n.h>
|
|
25
|
|
26 struct alsa_config alsa_cfg;
|
|
27
|
|
28 void
|
|
29 alsa_init(void)
|
|
30 {
|
|
31 ConfigDb *configdb;
|
|
32
|
|
33 memset(&alsa_cfg, 0, sizeof(alsa_cfg));
|
|
34 alsa_cfg.buffer_time = 500;
|
|
35 alsa_cfg.period_time = 50;
|
|
36 alsa_cfg.thread_buffer_time = 3000;
|
|
37 alsa_cfg.debug = 0;
|
|
38 alsa_cfg.multi_thread = 1;
|
|
39 alsa_cfg.mmap = 0;
|
|
40 alsa_cfg.vol.left = 100;
|
|
41 alsa_cfg.vol.right = 100;
|
|
42
|
|
43 configdb = bmp_cfg_db_open();
|
|
44 if (!bmp_cfg_db_get_string(configdb, "ALSA", "pcm_device",
|
|
45 &alsa_cfg.pcm_device))
|
|
46 alsa_cfg.pcm_device = g_strdup("default");
|
|
47 if (!bmp_cfg_db_get_string(configdb, "ALSA", "mixer_device",
|
|
48 &alsa_cfg.mixer_device))
|
|
49 alsa_cfg.mixer_device = g_strdup("PCM");
|
|
50 bmp_cfg_db_get_int(configdb, "ALSA", "mixer_card", &alsa_cfg.mixer_card);
|
|
51 bmp_cfg_db_get_int(configdb, "ALSA", "buffer_time",
|
|
52 &alsa_cfg.buffer_time);
|
|
53 bmp_cfg_db_get_int(configdb, "ALSA", "thread_buffer_time",
|
|
54 &alsa_cfg.thread_buffer_time);
|
|
55 bmp_cfg_db_get_int(configdb, "ALSA", "period_time",
|
|
56 &alsa_cfg.period_time);
|
|
57 bmp_cfg_db_get_bool(configdb, "ALSA", "mmap", &alsa_cfg.mmap);
|
|
58 bmp_cfg_db_get_bool(configdb, "ALSA", "multi_thread", &alsa_cfg.multi_thread);
|
|
59 bmp_cfg_db_get_bool(configdb, "ALSA", "soft_volume",
|
|
60 &alsa_cfg.soft_volume);
|
|
61 bmp_cfg_db_get_int(configdb, "ALSA", "volume_left", &alsa_cfg.vol.left);
|
|
62 bmp_cfg_db_get_int(configdb, "ALSA", "volume_right", &alsa_cfg.vol.right);
|
|
63
|
|
64 bmp_cfg_db_get_bool(configdb, "ALSA", "debug", &alsa_cfg.debug);
|
|
65
|
|
66 bmp_cfg_db_close(configdb);
|
|
67
|
|
68 if (dlopen("libasound.so.2", RTLD_NOW | RTLD_GLOBAL) == NULL) {
|
|
69 g_message("Cannot load alsa library: %s", dlerror());
|
|
70 /* FIXME, this plugin wont work... */
|
|
71 }
|
|
72 }
|