annotate src/rootvis/rootvis.c @ 2647:5808b64d3f68

branch merge
author Paula Stanciu <paula.stanciu@gmail.com>
date Sun, 25 May 2008 21:29:48 +0300
parents 31e6845e722a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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_configure(void);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
17 static void rootvis_playback_start(void);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
18 static void rootvis_playback_stop(void);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
19 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
20
910
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
21 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
22
900
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
23 // Callback functions
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
24 VisPlugin rootvis_vtable = {
1650
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
25 .description = "Root Spectrum Analyzer 0.0.8",
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
26 .num_pcm_chs_wanted = 0,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
27 .num_freq_chs_wanted = 2,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
28 .init = rootvis_init,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
29 .cleanup = rootvis_cleanup,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
30 .configure = rootvis_configure,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
31 .playback_start = rootvis_playback_start,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
32 .playback_stop = rootvis_playback_stop,
8d872d64e695 fixed rootvis plugin
mf0102 <0102@gmx.at>
parents: 1395
diff changeset
33 .render_freq = rootvis_render_freq
900
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
34 };
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
35
1144
359cd2c10405 [svn] - rootvis: convert to plugin2 architecture
nenolod
parents: 1061
diff changeset
36 VisPlugin *rootvis_vplist[] = { &rootvis_vtable, NULL };
359cd2c10405 [svn] - rootvis: convert to plugin2 architecture
nenolod
parents: 1061
diff changeset
37
1652
83050cd4d14c updated rootvis plugin
mf0102 <0102@gmx.at>
parents: 1650
diff changeset
38 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
39
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
40 // X related
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
41 struct rootvis_x {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
42 int screen;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
43 Display *display;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
44 Window rootWin, Parent;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
45 Pixmap rootBg;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
46 GC gc;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
47
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
48 Visual *vis;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
49 Colormap cm;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
50 Imlib_Image background;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
51 Imlib_Image buffer;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
52 };
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 // thread talk
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
55
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
56 struct rootvis_threads {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
57 gint16 freq_data[2][256];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
58 pthread_t worker[2];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
59 pthread_mutex_t mutex1;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
60 enum {GO, STOP} control;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
61 char dirty;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
62 /*** dirty flaglist ***
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
63 1: channel 1 geometry change
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
64 2: channel 1 color change
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
65 4: channel 2 geometry change
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
66 8: channel 2 color change
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
67 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
68 32: switch mono/stereo
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
69 */
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
70 } threads;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
71
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
72 // For use in config_backend:
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
73
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
74 void threads_lock(void) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
75 print_status("Locking");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
76 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
77 }
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 void threads_unlock(char dirty) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
80 print_status("Unlocking");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
81 threads.dirty = threads.dirty & dirty;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
82 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
83 }
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 // Some helper stuff
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
86
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
87 void clean_data(void) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
88 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
89 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
90 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
91 }
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 void print_status(char msg[]) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
94 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
95 }
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 void error_exit(char msg[]) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
98 printf("*** ERROR (rootvis): %s\n", msg);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
99 rootvis_vtable.disable_plugin(&rootvis_vtable);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
100 }
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 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
103 print_status("Opening X Display");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
104 drw->display = XOpenDisplay(display);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
105 if (drw->display == NULL) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
106 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
107 getenv("DISPLAY") ? getenv("DISPLAY") : "(default)");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
108 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
109 pthread_exit(NULL);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
110 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
111 print_status("Getting screen and window");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
112 drw->screen = DefaultScreen(drw->display);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
113 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
114
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
115 print_status("Initializing Imlib2");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
116
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
117 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
118 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
119
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
120 imlib_context_set_display(drw->display);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
121 imlib_context_set_visual(drw->vis);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
122 imlib_context_set_colormap(drw->cm);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
123
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
124 imlib_context_set_dither(0);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
125 imlib_context_set_blend(1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
126 }
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 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
129 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
130 Atom tmp_rootmapid, tmp_type;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
131 int tmp_format;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
132 unsigned long tmp_length, tmp_after;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
133 unsigned char *data = NULL;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
134
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
135 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
136 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
137 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
138 &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
139 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
140 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
141 imlib_context_set_drawable(drw->rootBg);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
142 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
143 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
144 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
145 if (drw->background == NULL)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
146 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
147 }
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 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
151 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
152 imlib_context_set_image(drw->background);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
153 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
154 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
155 imlib_free_image();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
156 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
157 }
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 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
160 imlib_context_set_image(drw->background);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
161 drw->buffer = imlib_clone_image();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
162 imlib_context_set_image(drw->buffer);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
163 }
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 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
166 imlib_context_set_drawable(drw->rootWin);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
167 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
168 imlib_free_image();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
169 }
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 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
172
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
173 /* 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
174 this also avoids some calculations */
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
175 register int a, b, c, d;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
176 float angle;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
177 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
178
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
179 if (conf.geo[t].orientation < 2) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
180 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
181 c = conf.bar[t].width;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
182 b = d = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
183 } else {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
184 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
185 *(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
186 d = conf.bar[t].width;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
187 a = c = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
188 }
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 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
191 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
192 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
193 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
194
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
195 if (conf.bar[t].shadow > 0) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
196 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
197 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
198 if (conf.bar[t].gradient)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
199 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
200 else if (conf.bar[t].bevel)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
201 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
202
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
203 if (conf.peak[t].shadow > 0)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
204 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
205 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
206 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
207 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
208 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
209 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
210 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
211 }
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 if (conf.bar[t].gradient)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
215 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
216 switch (conf.geo[t].orientation) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
217 case 0: angle = 0.0; break;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
218 case 1: angle = 180.0; break;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
219 case 2: angle = 90.0; break;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
220 case 3: default:
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
221 angle = -90.0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
222 }
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 imlib_context_set_color_range(range);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 imlib_free_color_range();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
235 }
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 if (conf.bar[t].bevel)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
238 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
239 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
240 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
241 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
242 }
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 if (peak > 0) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
245 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
246 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
247 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
248 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
249 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
250 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
251 }
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 // Our worker thread
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
255
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
256 void* worker_func(void* threadnump) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
257 struct rootvis_x draw;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
258 gint16 freq_data[256];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
259 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
260 unsigned int threadnum, i, j, level;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
261 unsigned short damage_coords[4];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
262 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
263 int barcount = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
264
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
265 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
266
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
267 print_status("Memory allocations");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
268 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
269 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
270 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
271 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
272 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
273 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
274 error_exit("Allocation of memory failed");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
275 pthread_exit(NULL);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
276 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
277 print_status("Allocations done");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
278
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
279 draw.display = NULL;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
280
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
281 while (threads.control != STOP) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
282
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 //print_status("start sleep");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
285 struct timespec sleeptime;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
286 sleeptime.tv_sec = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
287 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
288 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
289 //print_status("end sleep");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
290 }
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 /* 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
293 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
294 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
295 i = threads.dirty;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
296 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
297 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
298
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
299 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
300 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
301 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
302
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
303 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
304 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
305 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
306 if (conf.geo[threadnum].orientation < 2) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
307 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
308 *(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
309 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
310 } else {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
311 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
312 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
313 *(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
314 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
315 print_status("Geometry recalculations");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
316 scale = conf.geo[threadnum].height /
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
317 (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
318 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
319 (2*conf.data[threadnum].linearity - 1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
320 y00 = -log(-x00) * scale;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
321 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
322 memset(level1, 0, 256*sizeof(short));
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
323 memset(peak1, 0, 256*sizeof(short));
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
324 memset(peak2, 0, 256*sizeof(short));
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
325
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
326 draw_init(&draw, damage_coords);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
327 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
328 /*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
329 }*/
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 /* 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
332 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
333 levelsw = level1;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
334 level1 = level2;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
335 level2 = levelsw;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
336 levelsw = peak1;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
337 peak1 = peak2;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
338 peak2 = levelsw;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
339
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
340 for (i = 0; i < barcount; i++) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
341 level = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
342 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
343 if (level < freq_data[j])
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
344 level = freq_data[j];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
345 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
346 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
347 if (level < conf.geo[threadnum].height) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
348 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
349 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
350 else level1[i] = level;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
351 } 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
352 if (conf.peak[threadnum].enabled) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
353 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
354 peak1[i] = level1[i];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
355 peakstep[i] = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
356 } 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
357 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
358 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
359 else peak1[i] = 0;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
360 else {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
361 peak1[i] = peak2[i];
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
362 peakstep[i]++;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
363 }
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 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
368 draw_start(&draw, damage_coords);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
369 for (i = 0; i < barcount; i++)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
370 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
371 draw_end(&draw, damage_coords);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
372 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
373 }
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 print_status("Worker thread: Exiting");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
376 if (draw.display != NULL) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
377 draw_close(&draw, damage_coords);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
378 XCloseDisplay(draw.display);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
379 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
380 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
381 return NULL;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
382 }
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 // da xmms functions
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
386
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
387 static void rootvis_init(void) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
388 int rc1;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
389 print_status("Initializing");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
390 pthread_mutex_init(&threads.mutex1, NULL);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
391 threads.control = GO;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
392 clean_data();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
393 config_init();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
394 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
395 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
396 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
397 error_exit("Thread creation failed");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
398 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
399 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
400 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
401 error_exit("Thread creation failed");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
402 }
910
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
403 plugin_is_initted = TRUE;
900
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
404 }
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 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
407 if ( plugin_is_initted )
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
408 {
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
409 print_status("Cleanup... ");
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
410 threads.control = STOP;
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
411 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
412 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
413 print_status("Clean Exit");
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
414 plugin_is_initted = FALSE;
5aaf6c282617 [svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents: 900
diff changeset
415 }
900
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
416 }
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 static void rootvis_configure(void)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
419 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
420 print_status("Configuration trigger");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
421 config_init();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
422 config_show(2);
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
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
425 static void rootvis_playback_start(void)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
426 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
427 print_status("Playback starting");
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
428 }
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 static void rootvis_playback_stop(void)
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
431 {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
432 clean_data();
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
433 }
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 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
436 int channel, bucket;
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
437 pthread_mutex_lock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
438 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
439 for (channel = 0; channel < 2; channel++) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
440 for (bucket = 0; bucket < 256; bucket++) {
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
441 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
442 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
443 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
444 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
445 }
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
446 pthread_mutex_unlock(&threads.mutex1);
d985f0dcdeb0 [svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff changeset
447 }