Mercurial > audlegacy-plugins
annotate src/rocklight/rocklight.c @ 2284:d19b53359b24
cleaned up the sndfile wav plugin, currently limiting it ONLY TO WAV
PLAYBACK. if somebody is more experienced with it and wants to restore
the other formats, go ahead (maybe change the name of the plugin too?).
author | mf0102 <0102@gmx.at> |
---|---|
date | Wed, 09 Jan 2008 15:41:22 +0100 |
parents | 2ebeb7816c5e |
children | 3134a0987162 |
rev | line source |
---|---|
411 | 1 /* |
2 * Copyright (C) 2004 Benedikt 'Hunz' Heinz <rocklight@hunz.org> | |
3 * Copyright (C) 2006 Tony Vroon <chainsaw@gentoo.org> | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 * 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
|
6 * 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
|
7 * 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
|
8 * (at your option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * 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
|
11 * 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
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * GNU Library General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * 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
|
16 * 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
|
17 * 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
|
18 */ |
411 | 19 |
20 #include <sys/types.h> | |
21 #include <sys/stat.h> | |
22 #include <fcntl.h> | |
23 | |
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1395
diff
changeset
|
24 #include <audacious/plugin.h> |
411 | 25 #include "rocklight.h" |
26 | |
27 enum type { | |
28 NONE = 0, | |
29 THINKLIGHT, | |
30 SYSLED, | |
31 }; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 static int fd, last, state; |
411 | 34 static enum type type; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 static void rocklight_init(void) { |
411 | 37 type = NONE; |
38 | |
39 fd = open("/proc/acpi/ibm/light", O_RDWR); | |
40 if (fd >= 0) { | |
41 type = THINKLIGHT; | |
42 return; | |
43 } | |
44 | |
45 fd = open("/sys/class/leds/pmu-front-led/brightness", O_RDWR); | |
46 if (fd >= 0) { | |
47 type = SYSLED; | |
48 return; | |
49 } | |
50 | |
51 fd = open("/sys/class/leds/smu-front-led/brightness", O_RDWR); | |
52 if (fd >= 0) { | |
53 type = SYSLED; | |
54 return; | |
55 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
56 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 static void rocklight_cleanup(void) { |
411 | 59 close(fd); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 static void rocklight_playback_start(void) { |
411 | 63 /* Get original value */ |
64 switch (type) { | |
65 case THINKLIGHT: | |
66 last = state = thinklight_get(fd); | |
67 break; | |
68 | |
69 case SYSLED: | |
70 last = state = sysled_get(fd); | |
71 break; | |
72 | |
73 default: | |
74 break; | |
75 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
77 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 static void rocklight_playback_stop(void) { |
411 | 79 if (last == state) return; |
80 | |
81 /* Reset to original value */ | |
82 switch (type) { | |
83 case THINKLIGHT: | |
84 thinklight_set(fd, state); | |
85 break; | |
86 | |
87 case SYSLED: | |
88 sysled_set(fd, state); | |
89 break; | |
90 | |
91 default: | |
92 break; | |
93 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
95 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 static void rocklight_render_freq(gint16 data[2][256]) { |
411 | 97 int new = ((data[0][0] + data[1][0]) >> 7) >= 80? 1:0; |
98 | |
99 if (new == last) return; | |
100 last = new; | |
101 | |
102 switch (type) { | |
103 case THINKLIGHT: | |
104 thinklight_set(fd, new); | |
105 break; | |
106 | |
107 case SYSLED: | |
108 sysled_set(fd, new); | |
109 break; | |
110 | |
111 default: | |
112 break; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 |
411 | 116 static VisPlugin rocklight_vp = { |
117 .description = "RockLight", | |
118 | |
119 .num_pcm_chs_wanted = 0, | |
120 .num_freq_chs_wanted = 2, | |
121 | |
122 .init = rocklight_init, | |
123 .cleanup = rocklight_cleanup, | |
124 .playback_start = rocklight_playback_start, | |
125 .playback_stop = rocklight_playback_stop, | |
126 .render_freq = rocklight_render_freq | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 |
1143
48aba1f78016
[svn] - rocklight: convert to plugin2 architecture.
nenolod
parents:
411
diff
changeset
|
129 VisPlugin *rocklight_vplist[] = { &rocklight_vp, NULL }; |
48aba1f78016
[svn] - rocklight: convert to plugin2 architecture.
nenolod
parents:
411
diff
changeset
|
130 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1143
diff
changeset
|
131 DECLARE_PLUGIN(rocklight, NULL, NULL, NULL, NULL, NULL, NULL, rocklight_vplist,NULL); |