comparison src/OSS/OSS.c @ 2691:1d2596522075

Combine about.c and init.c to OSS.c
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Jun 2008 14:41:31 +0300
parents 4c937c5a03d2
children c1913516022a
comparison
equal deleted inserted replaced
2690:a8328c40a5c1 2691:1d2596522075
23 23
24 #include <glib.h> 24 #include <glib.h>
25 #include <audacious/i18n.h> 25 #include <audacious/i18n.h>
26 #include <stdlib.h> 26 #include <stdlib.h>
27 27
28 OSSConfig oss_cfg;
29
30 void oss_about(void)
31 {
32 static GtkWidget *dialog;
33
34 if (dialog != NULL)
35 return;
36
37 dialog = audacious_info_dialog(_("About OSS Driver"),
38 _("Audacious OSS Driver\n\n "
39 "This program is free software; you can redistribute it and/or modify\n"
40 "it under the terms of the GNU General Public License as published by\n"
41 "the Free Software Foundation; either version 2 of the License, or\n"
42 "(at your option) any later version.\n"
43 "\n"
44 "This program is distributed in the hope that it will be useful,\n"
45 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
46 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
47 "GNU General Public License for more details.\n"
48 "\n"
49 "You should have received a copy of the GNU General Public License\n"
50 "along with this program; if not, write to the Free Software\n"
51 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n"
52 "USA."), _("Ok"), FALSE, NULL, NULL);
53 g_signal_connect(G_OBJECT(dialog), "destroy",
54 G_CALLBACK(gtk_widget_destroyed), &dialog);
55 }
56
57
58 void oss_init(void)
59 {
60 mcs_handle_t *db;
61
62 memset(&oss_cfg, 0, sizeof(OSSConfig));
63
64 oss_cfg.audio_device = 0;
65 oss_cfg.mixer_device = 0;
66 oss_cfg.buffer_size = 3000;
67 oss_cfg.prebuffer = 25;
68 oss_cfg.use_alt_audio_device = FALSE;
69 oss_cfg.alt_audio_device = NULL;
70 oss_cfg.use_master = 0;
71
72 if ((db = aud_cfg_db_open())) {
73 aud_cfg_db_get_int(db, "OSS", "audio_device", &oss_cfg.audio_device);
74 aud_cfg_db_get_int(db, "OSS", "mixer_device", &oss_cfg.mixer_device);
75 aud_cfg_db_get_int(db, "OSS", "buffer_size", &oss_cfg.buffer_size);
76 aud_cfg_db_get_int(db, "OSS", "prebuffer", &oss_cfg.prebuffer);
77 aud_cfg_db_get_bool(db, "OSS", "use_master", &oss_cfg.use_master);
78 aud_cfg_db_get_bool(db, "OSS", "use_alt_audio_device",
79 &oss_cfg.use_alt_audio_device);
80 aud_cfg_db_get_string(db, "OSS", "alt_audio_device",
81 &oss_cfg.alt_audio_device);
82 aud_cfg_db_get_bool(db, "OSS", "use_alt_mixer_device",
83 &oss_cfg.use_alt_mixer_device);
84 aud_cfg_db_get_string(db, "OSS", "alt_mixer_device",
85 &oss_cfg.alt_mixer_device);
86 aud_cfg_db_close(db);
87 }
88 }
89
90 void oss_cleanup(void)
91 {
92 if (oss_cfg.alt_audio_device) {
93 free(oss_cfg.alt_audio_device);
94 oss_cfg.alt_audio_device = NULL;
95 }
96
97 if (oss_cfg.alt_mixer_device) {
98 free(oss_cfg.alt_mixer_device);
99 oss_cfg.alt_mixer_device = NULL;
100 }
101 }
102
28 OutputPlugin oss_op = { 103 OutputPlugin oss_op = {
29 .description = "OSS Output Plugin", /* Description */ 104 .description = "OSS Output Plugin", /* Description */
30 .init = oss_init, 105 .init = oss_init,
31 .cleanup = oss_cleanup, 106 .cleanup = oss_cleanup,
32 .about = oss_about, 107 .about = oss_about,
46 }; 121 };
47 122
48 OutputPlugin *oss_oplist[] = { &oss_op, NULL }; 123 OutputPlugin *oss_oplist[] = { &oss_op, NULL };
49 124
50 DECLARE_PLUGIN(OSS, NULL, NULL, NULL, oss_oplist, NULL, NULL, NULL, NULL); 125 DECLARE_PLUGIN(OSS, NULL, NULL, NULL, oss_oplist, NULL, NULL, NULL, NULL);
51
52 void oss_cleanup(void)
53 {
54 if (oss_cfg.alt_audio_device) {
55 free(oss_cfg.alt_audio_device);
56 oss_cfg.alt_audio_device = NULL;
57 }
58
59 if (oss_cfg.alt_mixer_device) {
60 free(oss_cfg.alt_mixer_device);
61 oss_cfg.alt_mixer_device = NULL;
62 }
63 }