annotate src/OSS4/OSS4.c @ 2896:35773e919dba

removed unsed mutex - and a dupplicate function call
author Paula Stanciu <paula.stanciu@gmail.com>
date Wed, 13 Aug 2008 09:35:56 +0300
parents c2861c84f850
children 3134a0987162
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1214
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
3 *
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
4 * Based on XMMS:
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
6 *
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
10 * (at your option) any later version.
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
11 *
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
15 * GNU General Public License for more details.
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
16 *
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
20 */
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
21
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
22 #include "OSS4.h"
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
23
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
24 #include <glib.h>
2501
7b284f323ad8 Include cleanups, part #6.
Matti Hamalainen <ccr@tnsp.org>
parents: 2124
diff changeset
25 #include <audacious/plugin.h>
1214
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
26 #include <audacious/i18n.h>
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
27 #include <stdlib.h>
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
28
2695
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
29 OSSConfig oss_cfg;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
30
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
31 static void oss_about(void)
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
32 {
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
33 static GtkWidget *dialog;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
34
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
35 if (dialog != NULL)
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
36 return;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
37
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
38 dialog = audacious_info_dialog(_("About OSSv4 Driver"),
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
39 _("Audacious OSSv4 Driver\n\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
40 "Based on the OSSv3 Output plugin,\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
41 "Ported to OSSv4's VMIX by Cristi Magherusan <majeru@gentoo.ro>\n\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
42 "This program is free software; you can redistribute it and/or modify\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
43 "it under the terms of the GNU General Public License as published by\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
44 "the Free Software Foundation; either version 2 of the License, or\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
45 "(at your option) any later version.\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
46 "\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
47 "This program is distributed in the hope that it will be useful,\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
48 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
49 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
50 "GNU General Public License for more details.\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
51 "\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
52 "You should have received a copy of the GNU General Public License\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
53 "along with this program; if not, write to the Free Software\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
54 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n"
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
55 "USA."), _("Ok"), FALSE, NULL, NULL);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
56 g_signal_connect(G_OBJECT(dialog), "destroy",
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
57 G_CALLBACK(gtk_widget_destroyed), &dialog);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
58 }
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
59
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
60 static void oss_init(void)
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
61 {
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
62 mcs_handle_t *db;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
63
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
64 memset(&oss_cfg, 0, sizeof(OSSConfig));
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
65
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
66 oss_cfg.audio_device = 0;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
67 oss_cfg.buffer_size = 3000;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
68 oss_cfg.prebuffer = 25;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
69 oss_cfg.use_alt_audio_device = FALSE;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
70 oss_cfg.alt_audio_device = NULL;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
71
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
72 if ((db = aud_cfg_db_open())) {
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
73 aud_cfg_db_get_int(db, "OSS", "audio_device", &oss_cfg.audio_device);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
74 aud_cfg_db_get_int(db, "OSS", "buffer_size", &oss_cfg.buffer_size);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
75 aud_cfg_db_get_int(db, "OSS", "prebuffer", &oss_cfg.prebuffer);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
76 aud_cfg_db_get_bool(db, "OSS", "save_volume", &oss_cfg.save_volume);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
77 aud_cfg_db_get_bool(db, "OSS", "use_alt_audio_device",
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
78 &oss_cfg.use_alt_audio_device);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
79 aud_cfg_db_get_string(db, "OSS", "alt_audio_device",
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
80 &oss_cfg.alt_audio_device);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
81 aud_cfg_db_get_int(db, "OSS", "saved_volume", &vol);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
82 aud_cfg_db_close(db);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
83 }
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
84 //volume gets saved anyway, but is ignored unless "saved_volume" is true
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
85 if(!oss_cfg.save_volume)
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
86 vol=0x6464; //maximum
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
87 }
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
88
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
89 static void oss_cleanup(void)
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
90 {
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
91 mcs_handle_t *db;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
92 db = aud_cfg_db_open();
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
93 aud_cfg_db_set_int(db, "OSS", "saved_volume", vol);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
94 aud_cfg_db_close(db);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
95
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
96 if (oss_cfg.alt_audio_device) {
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
97 g_free(oss_cfg.alt_audio_device);
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
98 oss_cfg.alt_audio_device = NULL;
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
99 }
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
100
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
101 }
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
102
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
103 static OutputPlugin oss4_op = {
1629
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
104 .description = "OSS4 Output Plugin", /* Description */
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
105 .init = oss_init,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
106 .cleanup = oss_cleanup,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
107 .about = oss_about,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
108 .configure = oss_configure,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
109 .get_volume = oss_get_volume,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
110 .set_volume = oss_set_volume,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
111 .open_audio = oss_open,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
112 .write_audio = oss_write,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
113 .close_audio = oss_close,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
114 .flush = oss_flush,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
115 .pause = oss_pause,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
116 .buffer_free = oss_free,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
117 .buffer_playing = oss_playing,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
118 .output_time = oss_get_output_time,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
119 .written_time = oss_get_written_time,
4c937c5a03d2 OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1395
diff changeset
120 .tell_audio = oss_tell
1214
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
121 };
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
122
2695
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
123 static OutputPlugin *oss4_oplist[] = { &oss4_op, NULL };
1214
2a722c3ccd9e damn, I forgot to 'hg add' the sources
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
124
2695
c2861c84f850 Perform same cleanups as in "old" OSS plugin.
Matti Hamalainen <ccr@tnsp.org>
parents: 2693
diff changeset
125 DECLARE_PLUGIN(OSS4, NULL, NULL, NULL, oss4_oplist, NULL, NULL, NULL, NULL);