Mercurial > audlegacy-plugins
annotate src/rootvis/rootvis.c @ 1652:83050cd4d14c
updated rootvis plugin
author | mf0102 <0102@gmx.at> |
---|---|
date | Fri, 07 Sep 2007 14:24:39 +0200 |
parents | 8d872d64e695 |
children | 31e6845e722a |
rev | line source |
---|---|
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
1 #include <string.h> |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
2 #include <math.h> |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
3 #include <pthread.h> |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
4 #include <time.h> |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
5 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
6 #include "rootvis.h" |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
7 // as imlib2 uses X definitions, it has to be included after the X includes, which are done in rootvis.h |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
8 #include <Imlib2.h> |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
9 #include "config.h" |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
10 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
11 extern Window ToonGetRootWindow(Display*, int, Window*); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
12 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
13 // Forward declarations |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
14 static void rootvis_init(void); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
15 static void rootvis_cleanup(void); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
16 static void rootvis_about(void); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
17 static void rootvis_configure(void); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
18 static void rootvis_playback_start(void); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
19 static void rootvis_playback_stop(void); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
20 static void rootvis_render_freq(gint16 freq_data[2][256]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
21 |
910
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
22 static gboolean plugin_is_initted = FALSE; |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
23 |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
24 // Callback functions |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
25 VisPlugin rootvis_vtable = { |
1650 | 26 .description = "Root Spectrum Analyzer 0.0.8", |
27 .num_pcm_chs_wanted = 0, | |
28 .num_freq_chs_wanted = 2, | |
29 .init = rootvis_init, | |
30 .cleanup = rootvis_cleanup, | |
31 .configure = rootvis_configure, | |
32 .playback_start = rootvis_playback_start, | |
33 .playback_stop = rootvis_playback_stop, | |
34 .render_freq = rootvis_render_freq | |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
35 }; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
36 |
1144 | 37 VisPlugin *rootvis_vplist[] = { &rootvis_vtable, NULL }; |
38 | |
1652 | 39 SIMPLE_VISUAL_PLUGIN(rootvis, rootvis_vplist); |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
40 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
41 // X related |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
42 struct rootvis_x { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
43 int screen; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
44 Display *display; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
45 Window rootWin, Parent; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
46 Pixmap rootBg; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
47 GC gc; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
48 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
49 Visual *vis; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
50 Colormap cm; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
51 Imlib_Image background; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
52 Imlib_Image buffer; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
53 }; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
54 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
55 // thread talk |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
56 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
57 struct rootvis_threads { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
58 gint16 freq_data[2][256]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
59 pthread_t worker[2]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
60 pthread_mutex_t mutex1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
61 enum {GO, STOP} control; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
62 char dirty; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
63 /*** dirty flaglist *** |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
64 1: channel 1 geometry change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
65 2: channel 1 color change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
66 4: channel 2 geometry change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
67 8: channel 2 color change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
68 16: no data yet (don't do anything) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
69 32: switch mono/stereo |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
70 */ |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
71 } threads; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
72 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
73 // For use in config_backend: |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
74 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
75 void threads_lock(void) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
76 print_status("Locking"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
77 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
78 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
79 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
80 void threads_unlock(char dirty) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
81 print_status("Unlocking"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
82 threads.dirty = threads.dirty & dirty; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
83 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
84 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
85 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
86 // Some helper stuff |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
87 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
88 void clean_data(void) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
89 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
90 memset(threads.freq_data, 0, sizeof(gint16) * 2 * 256); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
91 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
92 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
93 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
94 void print_status(char msg[]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
95 if (conf.debug == 1) printf(">> rootvis >> %s\n", msg); // for debug purposes, but doesn't tell much anyway |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
96 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
97 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
98 void error_exit(char msg[]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
99 printf("*** ERROR (rootvis): %s\n", msg); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
100 rootvis_vtable.disable_plugin(&rootvis_vtable); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
101 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
102 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
103 void initialize_X(struct rootvis_x* drw, char* display) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
104 print_status("Opening X Display"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
105 drw->display = XOpenDisplay(display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
106 if (drw->display == NULL) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
107 fprintf(stderr, "cannot connect to X server %s\n", |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
108 getenv("DISPLAY") ? getenv("DISPLAY") : "(default)"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
109 error_exit("Connecting to X server failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
110 pthread_exit(NULL); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
111 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
112 print_status("Getting screen and window"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
113 drw->screen = DefaultScreen(drw->display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
114 drw->rootWin = ToonGetRootWindow(drw->display, drw->screen, &drw->Parent); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
115 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
116 print_status("Initializing Imlib2"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
117 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
118 drw->vis = DefaultVisual(drw->display, drw->screen); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
119 drw->cm = DefaultColormap(drw->display, drw->screen); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
120 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
121 imlib_context_set_display(drw->display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
122 imlib_context_set_visual(drw->vis); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
123 imlib_context_set_colormap(drw->cm); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
124 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
125 imlib_context_set_dither(0); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
126 imlib_context_set_blend(1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
127 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
128 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
129 void draw_init(struct rootvis_x* drw, unsigned short damage_coords[4]) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
130 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
131 Atom tmp_rootmapid, tmp_type; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
132 int tmp_format; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
133 unsigned long tmp_length, tmp_after; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
134 unsigned char *data = NULL; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
135 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
136 if ((tmp_rootmapid = XInternAtom(drw->display, "_XROOTPMAP_ID", True)) != None) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
137 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
138 int ret = XGetWindowProperty(drw->display, drw->rootWin, tmp_rootmapid, 0L, 1L, False, AnyPropertyType, |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
139 &tmp_type, &tmp_format, &tmp_length, &tmp_after,&data); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
140 if ((ret == Success)&&(tmp_type == XA_PIXMAP)&&((drw->rootBg = *((Pixmap *)data)) != None)) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
141 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
142 imlib_context_set_drawable(drw->rootBg); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
143 drw->background = imlib_create_image_from_drawable(0, damage_coords[0], damage_coords[1], damage_coords[2], damage_coords[3], 1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
144 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
145 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
146 if (drw->background == NULL) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
147 error_exit("Initial image could not be created"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
148 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
149 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
150 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
151 void draw_close(struct rootvis_x* drw, unsigned short damage_coords[4]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
152 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
153 imlib_context_set_image(drw->background); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
154 imlib_render_image_on_drawable(damage_coords[0], damage_coords[1]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
155 XClearArea(drw->display, drw->rootWin, damage_coords[0], damage_coords[1], damage_coords[2], damage_coords[3], True); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
156 imlib_free_image(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
157 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
158 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
159 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
160 void draw_start(struct rootvis_x* drw, unsigned short damage_coords[4]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
161 imlib_context_set_image(drw->background); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
162 drw->buffer = imlib_clone_image(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
163 imlib_context_set_image(drw->buffer); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
164 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
165 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
166 void draw_end(struct rootvis_x* drw, unsigned short damage_coords[4]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
167 imlib_context_set_drawable(drw->rootWin); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
168 imlib_render_image_on_drawable(damage_coords[0], damage_coords[1]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
169 imlib_free_image(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
170 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
171 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
172 void draw_bar(struct rootvis_x* drw, int t, int i, unsigned short level, unsigned short oldlevel, unsigned short peak, unsigned short oldpeak) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
173 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
174 /* to make following cleaner, we work with redundant helper variables |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
175 this also avoids some calculations */ |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
176 register int a, b, c, d; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
177 float angle; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
178 Imlib_Color_Range range = imlib_create_color_range(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
179 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
180 if (conf.geo[t].orientation < 2) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
181 a = i*(conf.bar[t].width + conf.bar[t].shadow + conf.geo[t].space); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
182 c = conf.bar[t].width; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
183 b = d = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
184 } else { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
185 b = (conf.data[t].cutoff/conf.data[t].div - i - 1) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
186 *(conf.bar[t].width + conf.bar[t].shadow + conf.geo[t].space); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
187 d = conf.bar[t].width; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
188 a = c = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
189 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
190 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
191 if (conf.geo[t].orientation == 0) { b = conf.geo[t].height - level; d = level; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
192 else if (conf.geo[t].orientation == 1) { b = 0; d = level; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
193 else if (conf.geo[t].orientation == 2) { a = 0; c = level; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
194 else { a = conf.geo[t].height - level; c = level; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
195 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
196 if (conf.bar[t].shadow > 0) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
197 imlib_context_set_color(conf.bar[t].shadow_color[0], conf.bar[t].shadow_color[1], |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
198 conf.bar[t].shadow_color[2], conf.bar[t].shadow_color[3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
199 if (conf.bar[t].gradient) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
200 imlib_image_fill_rectangle(a + conf.bar[t].shadow, b + conf.bar[t].shadow, c, d); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
201 else if (conf.bar[t].bevel) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
202 imlib_image_draw_rectangle(a + conf.bar[t].shadow, b + conf.bar[t].shadow, c, d); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
203 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
204 if (conf.peak[t].shadow > 0) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
205 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
206 int aa = a, bb = b, cc = c, dd = d; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
207 if (conf.geo[t].orientation == 0) { bb = conf.geo[t].height - peak; dd = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
208 else if (conf.geo[t].orientation == 1) { bb = peak - 1; dd = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
209 else if (conf.geo[t].orientation == 2) { aa = peak - 1; cc = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
210 else { aa = conf.geo[t].height - peak; cc = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
211 imlib_image_fill_rectangle(aa + conf.bar[t].shadow, bb + conf.bar[t].shadow, cc, dd); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
212 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
213 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
214 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
215 if (conf.bar[t].gradient) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
216 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
217 switch (conf.geo[t].orientation) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
218 case 0: angle = 0.0; break; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
219 case 1: angle = 180.0; break; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
220 case 2: angle = 90.0; break; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
221 case 3: default: |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
222 angle = -90.0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
223 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
224 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
225 imlib_context_set_color_range(range); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
226 imlib_context_set_color(conf.bar[t].color[3][0], conf.bar[t].color[3][1], conf.bar[t].color[3][2], conf.bar[t].color[3][3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
227 imlib_add_color_to_color_range(0); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
228 imlib_context_set_color(conf.bar[t].color[2][0], conf.bar[t].color[2][1], conf.bar[t].color[2][2], conf.bar[t].color[2][3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
229 imlib_add_color_to_color_range(level * 2 / 5); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
230 imlib_context_set_color(conf.bar[t].color[1][0], conf.bar[t].color[1][1], conf.bar[t].color[1][2], conf.bar[t].color[1][3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
231 imlib_add_color_to_color_range(level * 4 / 5); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
232 imlib_context_set_color(conf.bar[t].color[0][0], conf.bar[t].color[0][1], conf.bar[t].color[0][2], conf.bar[t].color[0][3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
233 imlib_add_color_to_color_range(level); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
234 imlib_image_fill_color_range_rectangle(a, b, c, d, angle); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
235 imlib_free_color_range(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
236 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
237 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
238 if (conf.bar[t].bevel) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
239 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
240 imlib_context_set_color(conf.bar[t].bevel_color[0], conf.bar[t].bevel_color[1], |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
241 conf.bar[t].bevel_color[2], conf.bar[t].bevel_color[3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
242 imlib_image_draw_rectangle(a, b, c, d); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
243 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
244 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
245 if (peak > 0) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
246 if (conf.geo[t].orientation == 0) { b = conf.geo[t].height - peak; d = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
247 else if (conf.geo[t].orientation == 1) { b = peak - 1; d = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
248 else if (conf.geo[t].orientation == 2) { a = peak - 1; c = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
249 else { a = conf.geo[t].height - peak; c = 1; } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
250 imlib_context_set_color(conf.peak[t].color[0], conf.peak[t].color[1], conf.peak[t].color[2], conf.peak[t].color[3]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
251 imlib_image_fill_rectangle(a, b, c, d); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
252 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
253 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
254 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
255 // Our worker thread |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
256 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
257 void* worker_func(void* threadnump) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
258 struct rootvis_x draw; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
259 gint16 freq_data[256]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
260 double scale = 0.0, x00 = 0.0, y00 = 0.0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
261 unsigned int threadnum, i, j, level; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
262 unsigned short damage_coords[4]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
263 unsigned short *level1 = NULL, *level2 = NULL, *levelsw, *peak1 = NULL, *peak2 = NULL, *peakstep; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
264 int barcount = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
265 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
266 if (threadnump == NULL) threadnum = 0; else threadnum = 1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
267 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
268 print_status("Memory allocations"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
269 level1 = (unsigned short*)calloc(256, sizeof(short)); // need to be zeroed out |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
270 level2 = (unsigned short*)malloc(256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
271 peak1 = (unsigned short*)calloc(256, sizeof(short)); // need to be zeroed out |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
272 peak2 = (unsigned short*)calloc(256, sizeof(short)); // need to be zeroed out for disabled peaks |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
273 peakstep = (unsigned short*)calloc(256, sizeof(short)); // need to be zeroed out |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
274 if ((level1 == NULL)||(level2 == NULL)||(peak1 == NULL)||(peak2 == NULL)||(peakstep == NULL)) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
275 error_exit("Allocation of memory failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
276 pthread_exit(NULL); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
277 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
278 print_status("Allocations done"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
279 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
280 draw.display = NULL; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
281 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
282 while (threads.control != STOP) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
283 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
284 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
285 //print_status("start sleep"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
286 struct timespec sleeptime; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
287 sleeptime.tv_sec = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
288 sleeptime.tv_nsec = 999999999 / conf.data[threadnum].fps; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
289 while (nanosleep(&sleeptime, &sleeptime) == -1) {}; //print_status("INTR"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
290 //print_status("end sleep"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
291 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
292 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
293 /* we will unset our own dirty flags after receiving them */ |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
294 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
295 memcpy(&freq_data, &threads.freq_data[threadnum], sizeof(gint16)*256); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
296 i = threads.dirty; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
297 if ((i & 16) == 0) threads.dirty = i & (~(3 + threadnum*9)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
298 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
299 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
300 if ((i & 16) == 0) { // we've gotten data |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
301 if (draw.display == NULL) initialize_X(&draw, conf.geo[threadnum].display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
302 else if (i & (1 + threadnum*3)) draw_close(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
303 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
304 if (i & (1 + threadnum*3)) { // geometry has changed |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
305 damage_coords[0] = conf.geo[threadnum].posx; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
306 damage_coords[1] = conf.geo[threadnum].posy; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
307 if (conf.geo[threadnum].orientation < 2) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
308 damage_coords[2] = conf.data[threadnum].cutoff/conf.data[threadnum].div |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
309 *(conf.bar[threadnum].width + conf.bar[threadnum].shadow + conf.geo[threadnum].space); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
310 damage_coords[3] = conf.geo[threadnum].height + conf.bar[threadnum].shadow; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
311 } else { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
312 damage_coords[2] = conf.geo[threadnum].height + conf.bar[threadnum].shadow; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
313 damage_coords[3] = conf.data[threadnum].cutoff/conf.data[threadnum].div |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
314 *(conf.bar[threadnum].width + conf.bar[threadnum].shadow + conf.geo[threadnum].space); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
315 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
316 print_status("Geometry recalculations"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
317 scale = conf.geo[threadnum].height / |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
318 (log((1 - conf.data[threadnum].linearity) / conf.data[threadnum].linearity) * 4); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
319 x00 = conf.data[threadnum].linearity*conf.data[threadnum].linearity*32768.0 / |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
320 (2*conf.data[threadnum].linearity - 1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
321 y00 = -log(-x00) * scale; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
322 barcount = conf.data[threadnum].cutoff/conf.data[threadnum].div; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
323 memset(level1, 0, 256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
324 memset(peak1, 0, 256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
325 memset(peak2, 0, 256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
326 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
327 draw_init(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
328 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
329 /*if (i & (2 + threadnum*6)) { // colors have changed |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
330 }*/ |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
331 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
332 /* instead of copying the old level array to the second array, |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
333 we just tell the first is now the second one */ |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
334 levelsw = level1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
335 level1 = level2; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
336 level2 = levelsw; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
337 levelsw = peak1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
338 peak1 = peak2; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
339 peak2 = levelsw; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
340 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
341 for (i = 0; i < barcount; i++) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
342 level = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
343 for (j = i*conf.data[threadnum].div; j < (i+1)*conf.data[threadnum].div; j++) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
344 if (level < freq_data[j]) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
345 level = freq_data[j]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
346 level = level * (i*conf.data[threadnum].div + 1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
347 level = floor(abs(log(level - x00)*scale + y00)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
348 if (level < conf.geo[threadnum].height) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
349 if ((level2[i] > conf.bar[threadnum].falloff)&&(level < level2[i] - conf.bar[threadnum].falloff)) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
350 level1[i] = level2[i] - conf.bar[threadnum].falloff; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
351 else level1[i] = level; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
352 } else level1[i] = conf.geo[threadnum].height; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
353 if (conf.peak[threadnum].enabled) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
354 if (level1[i] > peak2[i] - conf.peak[threadnum].falloff) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
355 peak1[i] = level1[i]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
356 peakstep[i] = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
357 } else if (peakstep[i] == conf.peak[threadnum].step) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
358 if (peak2[i] > conf.peak[threadnum].falloff) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
359 peak1[i] = peak2[i] - conf.peak[threadnum].falloff; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
360 else peak1[i] = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
361 else { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
362 peak1[i] = peak2[i]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
363 peakstep[i]++; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
364 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
365 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
366 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
367 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
368 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
369 draw_start(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
370 for (i = 0; i < barcount; i++) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
371 draw_bar(&draw, threadnum, i, level1[i], level2[i], peak1[i], peak2[i]); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
372 draw_end(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
373 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
374 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
375 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
376 print_status("Worker thread: Exiting"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
377 if (draw.display != NULL) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
378 draw_close(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
379 XCloseDisplay(draw.display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
380 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
381 free(level1); free(level2); free(peak1); free(peak2); free(peakstep); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
382 return NULL; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
383 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
384 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
385 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
386 // da xmms functions |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
387 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
388 static void rootvis_init(void) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
389 int rc1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
390 print_status("Initializing"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
391 pthread_mutex_init(&threads.mutex1, NULL); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
392 threads.control = GO; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
393 clean_data(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
394 config_init(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
395 threads.dirty = 31; // this means simply everything has changed and there was no data |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
396 if ((rc1 = pthread_create(&threads.worker[0], NULL, worker_func, NULL))) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
397 fprintf(stderr, "Thread creation failed: %d\n", rc1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
398 error_exit("Thread creation failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
399 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
400 if ((conf.stereo)&&(rc1 = pthread_create(&threads.worker[1], NULL, worker_func, &rc1))) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
401 fprintf(stderr, "Thread creation failed: %d\n", rc1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
402 error_exit("Thread creation failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
403 } |
910
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
404 plugin_is_initted = TRUE; |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
405 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
406 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
407 static void rootvis_cleanup(void) { |
910
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
408 if ( plugin_is_initted ) |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
409 { |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
410 print_status("Cleanup... "); |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
411 threads.control = STOP; |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
412 pthread_join(threads.worker[0], NULL); |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
413 if (conf.stereo) pthread_join(threads.worker[1], NULL); |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
414 print_status("Clean Exit"); |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
415 plugin_is_initted = FALSE; |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
416 } |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
417 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
418 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
419 static void rootvis_about(void) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
420 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
421 print_status("About"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
422 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
423 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
424 static void rootvis_configure(void) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
425 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
426 print_status("Configuration trigger"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
427 config_init(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
428 config_show(2); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
429 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
430 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
431 static void rootvis_playback_start(void) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
432 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
433 print_status("Playback starting"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
434 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
435 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
436 static void rootvis_playback_stop(void) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
437 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
438 clean_data(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
439 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
440 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
441 static void rootvis_render_freq(gint16 freq_data[2][256]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
442 int channel, bucket; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
443 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
444 threads.dirty = threads.dirty & (~(16)); // unset no data yet flag |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
445 for (channel = 0; channel < 2; channel++) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
446 for (bucket = 0; bucket < 256; bucket++) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
447 if (conf.stereo) threads.freq_data[channel][bucket] = freq_data[channel][bucket]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
448 else if (channel == 0) threads.freq_data[0][bucket] = freq_data[channel][bucket] / 2; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
449 else threads.freq_data[0][bucket] += freq_data[channel][bucket] / 2; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
450 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
451 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
452 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
453 } |