annotate Plugins/Output/alsa/init.c @ 130:7dc049844b73 trunk

[svn] Fix libmikmod test.
author nenolod
date Wed, 09 Nov 2005 19:57:44 -0800
parents fa848bd484d8
children 0b48662886e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
1 /* XMMS - ALSA output plugin
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
2 * Copyright (C) 2001-2003 Matthieu Sozeau <mattam@altern.org>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
3 * Copyright (C) 2003-2004 Haavard Kvaalen
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
4 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
8 * (at your option) any later version.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
9 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
13 * GNU General Public License for more details.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
14 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
18 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
19
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
20 #include "libaudacious/configdb.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
21 #include "alsa.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
22 #include <dlfcn.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
23 #include <ctype.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
24 #include <glib/gi18n.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
25
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
26 struct alsa_config alsa_cfg;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
27
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
28 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
29 alsa_init(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
30 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
31 ConfigDb *configdb;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
32
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
33 memset(&alsa_cfg, 0, sizeof(alsa_cfg));
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
34 alsa_cfg.buffer_time = 500;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
35 alsa_cfg.period_time = 50;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
36 alsa_cfg.thread_buffer_time = 3000;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
37 alsa_cfg.debug = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
38 alsa_cfg.multi_thread = 1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
39 alsa_cfg.mmap = 0;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
40 alsa_cfg.vol.left = 100;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
41 alsa_cfg.vol.right = 100;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
42
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
43 configdb = bmp_cfg_db_open();
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
44 if (!bmp_cfg_db_get_string(configdb, "ALSA", "pcm_device",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
45 &alsa_cfg.pcm_device))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
46 alsa_cfg.pcm_device = g_strdup("default");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
47 if (!bmp_cfg_db_get_string(configdb, "ALSA", "mixer_device",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
48 &alsa_cfg.mixer_device))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
49 alsa_cfg.mixer_device = g_strdup("PCM");
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
50 bmp_cfg_db_get_int(configdb, "ALSA", "mixer_card", &alsa_cfg.mixer_card);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
51 bmp_cfg_db_get_int(configdb, "ALSA", "buffer_time",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
52 &alsa_cfg.buffer_time);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
53 bmp_cfg_db_get_int(configdb, "ALSA", "thread_buffer_time",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
54 &alsa_cfg.thread_buffer_time);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
55 bmp_cfg_db_get_int(configdb, "ALSA", "period_time",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
56 &alsa_cfg.period_time);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
57 bmp_cfg_db_get_bool(configdb, "ALSA", "mmap", &alsa_cfg.mmap);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
58 bmp_cfg_db_get_bool(configdb, "ALSA", "multi_thread", &alsa_cfg.multi_thread);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
59 bmp_cfg_db_get_bool(configdb, "ALSA", "soft_volume",
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
60 &alsa_cfg.soft_volume);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
61 bmp_cfg_db_get_int(configdb, "ALSA", "volume_left", &alsa_cfg.vol.left);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
62 bmp_cfg_db_get_int(configdb, "ALSA", "volume_right", &alsa_cfg.vol.right);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
63
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
64 bmp_cfg_db_get_bool(configdb, "ALSA", "debug", &alsa_cfg.debug);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
65
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
66 bmp_cfg_db_close(configdb);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
67
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
68 if (dlopen("libasound.so.2", RTLD_NOW | RTLD_GLOBAL) == NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
69 g_message("Cannot load alsa library: %s", dlerror());
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
70 /* FIXME, this plugin wont work... */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
71 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
72 }