Mercurial > audlegacy-plugins
annotate src/OSS/OSS.c @ 3191:a65f440cbed3
alsa-ng: Fix possible race conditions, sluggish pause and seek.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Mon, 22 Jun 2009 16:05:57 -0400 |
parents | b562bc52a93e |
children |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* BMP - Cross-platform multimedia player |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 * Copyright (C) 2003-2004 BMP development team. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 * Based on XMMS: |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 * Copyright (C) 1998-2003 XMMS development team. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 * This program is free software; you can redistribute it and/or modify |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * (at your option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 #include "OSS.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 #include <glib.h> |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2861
diff
changeset
|
25 #include <audlegacy/i18n.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
28 OSSConfig oss_cfg; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
29 |
2861 | 30 static GtkWidget *about_dialog = NULL; |
31 | |
2694 | 32 static void oss_about(void) |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
33 { |
2861 | 34 if (about_dialog != NULL) |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
35 return; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
36 |
2861 | 37 about_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(about_dialog), "destroy", | |
54 G_CALLBACK(gtk_widget_destroyed), &about_dialog); | |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
55 } |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
56 |
3103 | 57 static OutputPluginInitStatus oss_init(void) |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
58 { |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
59 mcs_handle_t *db; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
60 |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
61 memset(&oss_cfg, 0, sizeof(OSSConfig)); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
62 |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
63 oss_cfg.audio_device = 0; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
64 oss_cfg.mixer_device = 0; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
65 oss_cfg.buffer_size = 3000; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
66 oss_cfg.prebuffer = 25; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
67 oss_cfg.use_alt_audio_device = FALSE; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
68 oss_cfg.alt_audio_device = NULL; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
69 oss_cfg.use_master = 0; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
70 |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
71 if ((db = aud_cfg_db_open())) { |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
72 aud_cfg_db_get_int(db, "OSS", "audio_device", &oss_cfg.audio_device); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
73 aud_cfg_db_get_int(db, "OSS", "mixer_device", &oss_cfg.mixer_device); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
74 aud_cfg_db_get_int(db, "OSS", "buffer_size", &oss_cfg.buffer_size); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
75 aud_cfg_db_get_int(db, "OSS", "prebuffer", &oss_cfg.prebuffer); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
76 aud_cfg_db_get_bool(db, "OSS", "use_master", &oss_cfg.use_master); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
77 aud_cfg_db_get_bool(db, "OSS", "use_alt_audio_device", |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
78 &oss_cfg.use_alt_audio_device); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
79 aud_cfg_db_get_string(db, "OSS", "alt_audio_device", |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
80 &oss_cfg.alt_audio_device); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
81 aud_cfg_db_get_bool(db, "OSS", "use_alt_mixer_device", |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
82 &oss_cfg.use_alt_mixer_device); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
83 aud_cfg_db_get_string(db, "OSS", "alt_mixer_device", |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
84 &oss_cfg.alt_mixer_device); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
85 aud_cfg_db_close(db); |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
86 } |
3103 | 87 |
88 return OUTPUT_PLUGIN_INIT_FOUND_DEVICES; | |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
89 } |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
90 |
2694 | 91 static void oss_cleanup(void) |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
92 { |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
93 if (oss_cfg.alt_audio_device) { |
2692
c1913516022a
Use g_free() as it should be used.
Matti Hamalainen <ccr@tnsp.org>
parents:
2691
diff
changeset
|
94 g_free(oss_cfg.alt_audio_device); |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
95 oss_cfg.alt_audio_device = NULL; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
96 } |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
97 |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
98 if (oss_cfg.alt_mixer_device) { |
2692
c1913516022a
Use g_free() as it should be used.
Matti Hamalainen <ccr@tnsp.org>
parents:
2691
diff
changeset
|
99 g_free(oss_cfg.alt_mixer_device); |
2691
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
100 oss_cfg.alt_mixer_device = NULL; |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
101 } |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
102 } |
1d2596522075
Combine about.c and init.c to OSS.c
Matti Hamalainen <ccr@tnsp.org>
parents:
1629
diff
changeset
|
103 |
2694 | 104 static OutputPlugin oss_op = { |
3103 | 105 .description = "OSS Output Plugin", |
106 .probe_priority = 1, | |
1629
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
107 .init = oss_init, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
108 .cleanup = oss_cleanup, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
109 .about = oss_about, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
110 .configure = oss_configure, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
111 .get_volume = oss_get_volume, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
112 .set_volume = oss_set_volume, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
113 .open_audio = oss_open, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
114 .write_audio = oss_write, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
115 .close_audio = oss_close, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
116 .flush = oss_flush, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
117 .pause = oss_pause, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
118 .buffer_free = oss_free, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
119 .buffer_playing = oss_playing, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
120 .output_time = oss_get_output_time, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
121 .written_time = oss_get_written_time, |
4c937c5a03d2
OSS, OSS4: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1395
diff
changeset
|
122 .tell_audio = oss_tell |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 |
2694 | 125 static OutputPlugin *oss_oplist[] = { &oss_op, NULL }; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1111
diff
changeset
|
127 DECLARE_PLUGIN(OSS, NULL, NULL, NULL, oss_oplist, NULL, NULL, NULL, NULL); |