annotate Plugins/Output/sun/sun.c @ 1458:f12d7e208b43 trunk

[svn] Update FSF address in copyright notices. Update autotools templates.
author chainsaw
date Wed, 02 Aug 2006 15:44:07 -0700
parents 400161c76515
children 705d4c089fce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
1 /*
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
2 * Copyright (C) 2001 CubeSoft Communications, Inc.
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
3 * <http://www.csoft.org>
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
4 *
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
8 * (at your option) any later version.
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
9 *
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
13 * GNU General Public License for more details.
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
14 *
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
1458
f12d7e208b43 [svn] Update FSF address in copyright notices. Update autotools templates.
chainsaw
parents: 1016
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
18 */
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
19
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
20 #include "sun.h"
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
21 #include "libaudacious/configdb.h"
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
22
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
23 #include <glib.h>
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
24 #include <glib/gi18n.h>
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
25 #include <errno.h>
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
26
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
27 struct sun_audio audio;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
28
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
29 OutputPlugin sun_op =
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
30 {
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
31 NULL,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
32 NULL,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
33 NULL, /* Description */
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
34 sun_init,
791
093965283548 [svn] - finish up here
nenolod
parents: 758
diff changeset
35 sun_cleanup,
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
36 sun_about,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
37 sun_configure,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
38 sun_get_volume,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
39 sun_set_volume,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
40 sun_open,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
41 sun_write,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
42 sun_close,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
43 sun_flush,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
44 sun_pause,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
45 sun_free,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
46 sun_playing,
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
47 sun_output_time,
791
093965283548 [svn] - finish up here
nenolod
parents: 758
diff changeset
48 sun_written_time,
093965283548 [svn] - finish up here
nenolod
parents: 758
diff changeset
49 NULL
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
50 };
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
51
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
52
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
53 OutputPlugin * get_oplugin_info(void)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
54 {
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
55 sun_op.description = g_strdup_printf(_("BSD Sun Driver %s"),
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
56 SUN_VERSION);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
57 return (&sun_op);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
58 }
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
59
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
60 void sun_init(void)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
61 {
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
62 ConfigDb *cfgfile;
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
63 char *s;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
64
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
65 memset(&audio, 0, sizeof(struct sun_audio));
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
66
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
67 cfgfile = bmp_cfg_db_open();
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
68 /* Devices */
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
69 bmp_cfg_db_get_string(cfgfile, "sun", "audio_devaudio", &audio.devaudio);
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
70 bmp_cfg_db_get_string(cfgfile, "sun",
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
71 "audio_devaudioctl", &audio.devaudioctl);
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
72 bmp_cfg_db_get_string(cfgfile, "sun", "audio_devmixer", &audio.devmixer);
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
73
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
74 /* Buffering */
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
75 bmp_cfg_db_get_int(cfgfile, "sun",
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
76 "buffer_size", &audio.req_buffer_size);
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
77 bmp_cfg_db_get_int(cfgfile, "sun",
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
78 "prebuffer_size", &audio.req_prebuffer_size);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
79
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
80 /* Mixer */
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
81 bmp_cfg_db_get_string(cfgfile, "sun", "mixer_voldev", &audio.mixer_voldev);
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
82 bmp_cfg_db_get_bool(cfgfile, "sun",
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
83 "mixer_keepopen", &audio.mixer_keepopen);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
84
1016
400161c76515 [svn] - configdb stuff
nenolod
parents: 791
diff changeset
85 bmp_cfg_db_close(cfgfile);
758
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
86
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
87 /* Audio device path */
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
88 if ((s = getenv("AUDIODEVICE")))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
89 audio.devaudio = g_strdup(s);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
90 else if (!audio.devaudio || !strcmp("", audio.devaudio))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
91 audio.devaudio = g_strdup(SUN_DEV_AUDIO);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
92
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
93 /* Audio control device path */
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
94 if (!audio.devaudioctl || !strcmp("", audio.devaudioctl))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
95 audio.devaudioctl = g_strdup(SUN_DEV_AUDIOCTL);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
96
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
97 /* Mixer device path */
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
98 if ((s = getenv("MIXERDEVICE")))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
99 audio.devmixer = g_strdup(s);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
100 else if (!audio.devmixer || !strcmp("", audio.devmixer))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
101 audio.devmixer = g_strdup(SUN_DEV_MIXER);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
102
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
103 if (!audio.mixer_voldev || !strcmp("", audio.mixer_voldev))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
104 audio.mixer_voldev = g_strdup(SUN_DEFAULT_VOLUME_DEV);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
105
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
106 /* Default buffering settings */
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
107 if (!audio.req_buffer_size)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
108 audio.req_buffer_size = SUN_DEFAULT_BUFFER_SIZE;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
109 if (!audio.req_prebuffer_size)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
110 audio.req_prebuffer_size = SUN_DEFAULT_PREBUFFER_SIZE;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
111
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
112 audio.input = NULL;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
113 audio.output = NULL;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
114 audio.effect = NULL;
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
115
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
116 if (pthread_mutex_init(&audio.mixer_mutex, NULL) != 0)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
117 perror("mixer_mutex");
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
118 }
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
119
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
120 void sun_cleanup(void)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
121 {
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
122 g_free(audio.devaudio);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
123 g_free(audio.devaudioctl);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
124 g_free(audio.devmixer);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
125 g_free(audio.mixer_voldev);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
126
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
127 if (!pthread_mutex_lock(&audio.mixer_mutex))
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
128 {
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
129 if (audio.mixerfd)
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
130 close(audio.mixerfd);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
131 pthread_mutex_unlock(&audio.mixer_mutex);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
132 pthread_mutex_destroy(&audio.mixer_mutex);
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
133 }
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
134 }
f9e8807ea6e5 [svn] - Initial port of the bsd/sun audio output plugin from XMMS. Needs testing.
nenolod
parents:
diff changeset
135