Mercurial > audlegacy
annotate audacious/svis.c @ 249:a4566101cab4 trunk
[svn] Add two missing casts and update the player buffer description from XMMS to Audacious.
author | chainsaw |
---|---|
date | Sat, 03 Dec 2005 09:14:33 -0800 |
parents | 0ee0b9b6db7e |
children | f12d7e208b43 |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 #include "svis.h" | |
23 | |
24 #include <glib.h> | |
25 #include <gdk/gdk.h> | |
26 #include <string.h> | |
27 | |
28 #include "main.h" | |
29 #include "mainwin.h" | |
30 #include "plugin.h" | |
31 #include "widget.h" | |
32 #include "vis.h" | |
33 | |
34 static gint svis_redraw_delays[] = { 1, 2, 4, 8 }; | |
35 | |
36 /* FIXME: Are the svis_scope_colors correct? */ | |
37 static guint8 svis_scope_colors[] = { 20, 19, 18, 19, 20 }; | |
38 static guint8 svis_vu_normal_colors[] = { 17, 17, 17, 12, 12, 12, 2, 2 }; | |
39 | |
40 #define DRAW_DS_PIXEL(ptr,value) \ | |
41 *(ptr) = (value); \ | |
42 *((ptr) + 1) = (value); \ | |
43 *((ptr) + 76) = (value); \ | |
44 *((ptr) + 77) = (value); | |
45 | |
46 #define SVIS_HEIGHT 5 | |
47 #define SVIS_WIDTH 38 | |
48 | |
49 void | |
50 svis_timeout_func(SVis * svis, guchar * data) | |
51 { | |
52 static GTimer *timer = NULL; | |
53 gulong micros = 9999999; | |
54 gboolean falloff = FALSE; | |
55 gint i; | |
56 | |
57 if (!timer) { | |
58 timer = g_timer_new(); | |
59 g_timer_start(timer); | |
60 } | |
61 else { | |
62 g_timer_elapsed(timer, µs); | |
63 if (micros > 14000) | |
64 g_timer_reset(timer); | |
65 | |
66 } | |
67 | |
68 if (cfg.vis_type == INPUT_VIS_ANALYZER) { | |
69 if (micros > 14000) | |
70 falloff = TRUE; | |
71 | |
72 for (i = 0; i < 2; i++) { | |
73 if (falloff || data) { | |
74 if (data && data[i] > svis->vs_data[i]) | |
75 svis->vs_data[i] = data[i]; | |
76 else if (falloff) { | |
77 if (svis->vs_data[i] >= 2) | |
78 svis->vs_data[i] -= 2; | |
79 else | |
80 svis->vs_data[i] = 0; | |
81 } | |
82 } | |
83 | |
84 } | |
85 } | |
86 else if (data) { | |
87 for (i = 0; i < 75; i++) | |
88 svis->vs_data[i] = data[i]; | |
89 } | |
90 | |
91 if (micros > 14000) { | |
92 if (!svis->vs_refresh_delay) { | |
93 svis_draw((Widget *) svis); | |
94 svis->vs_refresh_delay = svis_redraw_delays[cfg.vis_refresh]; | |
95 | |
96 } | |
97 svis->vs_refresh_delay--; | |
98 } | |
99 } | |
100 | |
101 void | |
102 svis_draw(Widget * w) | |
103 { | |
104 SVis *svis = (SVis *) w; | |
105 gint x, y, h; | |
106 guchar svis_color[24][3]; | |
107 guchar rgb_data[SVIS_WIDTH * 2 * SVIS_HEIGHT * 2], *ptr, c; | |
108 guint32 colors[24]; | |
109 GdkRgbCmap *cmap; | |
110 | |
111 GDK_THREADS_ENTER(); | |
112 | |
113 skin_get_viscolor(bmp_active_skin, svis_color); | |
114 for (y = 0; y < 24; y++) { | |
115 colors[y] = | |
116 svis_color[y][0] << 16 | svis_color[y][1] << 8 | svis_color[y][2]; | |
117 } | |
118 cmap = gdk_rgb_cmap_new(colors, 24); | |
119 | |
120 memset(rgb_data, 0, SVIS_WIDTH * SVIS_HEIGHT); | |
121 if (cfg.vis_type == VIS_ANALYZER) { | |
122 switch (cfg.vu_mode) { | |
123 case VU_NORMAL: | |
124 for (y = 0; y < 2; y++) { | |
125 ptr = rgb_data + ((y * 3) * 38); | |
126 h = (svis->vs_data[y] * 7) / 37; | |
127 for (x = 0; x < h; x++, ptr += 5) { | |
128 c = svis_vu_normal_colors[x]; | |
129 *(ptr) = c; | |
130 *(ptr + 1) = c; | |
131 *(ptr + 2) = c; | |
132 *(ptr + 38) = c; | |
133 *(ptr + 39) = c; | |
134 *(ptr + 40) = c; | |
135 } | |
136 } | |
137 break; | |
138 case VU_SMOOTH: | |
139 for (y = 0; y < 2; y++) { | |
140 ptr = rgb_data + ((y * 3) * SVIS_WIDTH); | |
141 for (x = 0; x < svis->vs_data[y]; x++, ptr++) { | |
142 c = 17 - ((x * 15) / 37); | |
143 *(ptr) = c; | |
144 *(ptr + 38) = c; | |
145 } | |
146 } | |
147 break; | |
148 } | |
149 } | |
150 else if (cfg.vis_type == VIS_SCOPE) { | |
151 for (x = 0; x < 38; x++) { | |
152 h = svis->vs_data[x << 1] / 3; | |
153 ptr = rgb_data + ((4 - h) * 38) + x; | |
154 *ptr = svis_scope_colors[h]; | |
155 } | |
156 } | |
157 | |
158 gdk_draw_indexed_image(mainwin->window, mainwin_gc, | |
159 svis->vs_widget.x, svis->vs_widget.y, | |
160 svis->vs_widget.width, | |
161 svis->vs_widget.height, | |
162 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | |
163 38, cmap); | |
164 | |
165 gdk_rgb_cmap_free(cmap); | |
166 GDK_THREADS_LEAVE(); | |
167 } | |
168 | |
169 void | |
170 svis_clear_data(SVis * svis) | |
171 { | |
172 gint i; | |
173 | |
192
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
0
diff
changeset
|
174 if (!svis) |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
0
diff
changeset
|
175 return; |
0ee0b9b6db7e
[svn] headless now working, use --headless if you wish to experiment.
nenolod
parents:
0
diff
changeset
|
176 |
0 | 177 for (i = 0; i < 75; i++) { |
178 svis->vs_data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0; | |
179 } | |
180 } | |
181 | |
182 void | |
183 svis_clear(SVis * svis) | |
184 { | |
185 gdk_window_clear_area(mainwin->window, svis->vs_widget.x, | |
186 svis->vs_widget.y, svis->vs_widget.width, | |
187 svis->vs_widget.height); | |
188 } | |
189 | |
190 SVis * | |
191 create_svis(GList ** wlist, | |
192 GdkPixmap * parent, | |
193 GdkGC * gc, | |
194 gint x, gint y) | |
195 { | |
196 SVis *svis; | |
197 | |
198 svis = g_new0(SVis, 1); | |
199 widget_init(&svis->vs_widget, parent, gc, x, y, SVIS_WIDTH, SVIS_HEIGHT, | |
200 1); | |
201 | |
202 widget_list_add(wlist, WIDGET(svis)); | |
203 return svis; | |
204 } |