Mercurial > audlegacy-plugins
annotate src/rootvis/rootvis.c @ 1395:761e17b23e0c
added Discovery plugin type
author | Cristi Magherusan <majeru@atheme-project.org> |
---|---|
date | Fri, 03 Aug 2007 07:21:36 +0300 |
parents | 359cd2c10405 |
children | 8d872d64e695 |
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 = { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
26 0, // Handle, filled in by xmms |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
27 0, // Filename, filled in by xmms |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
28 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
29 "Root Spectrum Analyzer 0.0.8", // description |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
30 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
31 0, // # of PCM channels for render_pcm() |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
32 2, // # of freq channels wanted for render_freq() |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
33 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
34 rootvis_init, // Called when plugin is enabled |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
35 rootvis_cleanup, // Called when plugin is disabled |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
36 NULL,//rootvis_about, // Show the about box |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
37 rootvis_configure, // Show the configure box |
1144 | 38 NULL, // Called to disable plugin, filled in by xmms |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
39 rootvis_playback_start, // Called when playback starts |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
40 rootvis_playback_stop, // Called when playback stops |
1144 | 41 NULL, // Render the PCM data, must return quickly |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
42 rootvis_render_freq // Render the freq data, must return quickly |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
43 }; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
44 |
1144 | 45 VisPlugin *rootvis_vplist[] = { &rootvis_vtable, NULL }; |
46 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1144
diff
changeset
|
47 DECLARE_PLUGIN(rootvis, NULL, NULL, NULL, NULL, NULL, NULL, rootvis_vplist,NULL); |
900
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 // X related |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
50 struct rootvis_x { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
51 int screen; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
52 Display *display; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
53 Window rootWin, Parent; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
54 Pixmap rootBg; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
55 GC gc; |
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 Visual *vis; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
58 Colormap cm; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
59 Imlib_Image background; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
60 Imlib_Image buffer; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
61 }; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
62 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
63 // thread talk |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
64 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
65 struct rootvis_threads { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
66 gint16 freq_data[2][256]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
67 pthread_t worker[2]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
68 pthread_mutex_t mutex1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
69 enum {GO, STOP} control; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
70 char dirty; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
71 /*** dirty flaglist *** |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
72 1: channel 1 geometry change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
73 2: channel 1 color change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
74 4: channel 2 geometry change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
75 8: channel 2 color change |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
76 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
|
77 32: switch mono/stereo |
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 } threads; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
80 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
81 // For use in config_backend: |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
82 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
83 void threads_lock(void) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
84 print_status("Locking"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
85 pthread_mutex_lock(&threads.mutex1); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
88 void threads_unlock(char dirty) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
89 print_status("Unlocking"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
90 threads.dirty = threads.dirty & dirty; |
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 // Some helper stuff |
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 void clean_data(void) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
97 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
98 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
|
99 pthread_mutex_unlock(&threads.mutex1); |
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 print_status(char msg[]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
103 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
|
104 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
105 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
106 void error_exit(char msg[]) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
107 printf("*** ERROR (rootvis): %s\n", msg); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
108 rootvis_vtable.disable_plugin(&rootvis_vtable); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
109 } |
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 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
|
112 print_status("Opening X Display"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
113 drw->display = XOpenDisplay(display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
114 if (drw->display == NULL) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
115 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
|
116 getenv("DISPLAY") ? getenv("DISPLAY") : "(default)"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
117 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
|
118 pthread_exit(NULL); |
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 print_status("Getting screen and window"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
121 drw->screen = DefaultScreen(drw->display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
122 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
|
123 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
124 print_status("Initializing Imlib2"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
125 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
126 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
|
127 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
|
128 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
129 imlib_context_set_display(drw->display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
130 imlib_context_set_visual(drw->vis); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
131 imlib_context_set_colormap(drw->cm); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
132 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
133 imlib_context_set_dither(0); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
134 imlib_context_set_blend(1); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
137 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
|
138 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
139 Atom tmp_rootmapid, tmp_type; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
140 int tmp_format; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
141 unsigned long tmp_length, tmp_after; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
142 unsigned char *data = NULL; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
143 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
144 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
|
145 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
146 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
|
147 &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
|
148 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
|
149 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
150 imlib_context_set_drawable(drw->rootBg); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
151 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
|
152 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
153 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
154 if (drw->background == NULL) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
155 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
|
156 } |
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_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
|
160 pthread_mutex_lock(&threads.mutex1); |
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 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
|
163 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
|
164 imlib_free_image(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
165 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
166 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
167 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
168 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
|
169 imlib_context_set_image(drw->background); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
170 drw->buffer = imlib_clone_image(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
171 imlib_context_set_image(drw->buffer); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
174 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
|
175 imlib_context_set_drawable(drw->rootWin); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
176 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
|
177 imlib_free_image(); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
180 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
|
181 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
182 /* 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
|
183 this also avoids some calculations */ |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
184 register int a, b, c, d; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
185 float angle; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
186 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
|
187 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
188 if (conf.geo[t].orientation < 2) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
189 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
|
190 c = conf.bar[t].width; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
191 b = d = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
192 } else { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
193 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
|
194 *(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
|
195 d = conf.bar[t].width; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
196 a = c = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
197 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
198 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
199 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
|
200 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
|
201 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
|
202 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
|
203 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
204 if (conf.bar[t].shadow > 0) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
205 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
|
206 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
|
207 if (conf.bar[t].gradient) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
208 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
|
209 else if (conf.bar[t].bevel) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
210 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
|
211 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
212 if (conf.peak[t].shadow > 0) |
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 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
|
215 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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
221 } |
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 if (conf.bar[t].gradient) |
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 switch (conf.geo[t].orientation) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
226 case 0: angle = 0.0; break; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
227 case 1: angle = 180.0; break; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
228 case 2: angle = 90.0; break; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
229 case 3: default: |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
230 angle = -90.0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
231 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
232 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
233 imlib_context_set_color_range(range); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 imlib_free_color_range(); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
246 if (conf.bar[t].bevel) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
247 { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
248 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
|
249 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
|
250 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
|
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 if (peak > 0) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
261 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
262 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
263 // Our worker thread |
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 void* worker_func(void* threadnump) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
266 struct rootvis_x draw; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
267 gint16 freq_data[256]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
268 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
|
269 unsigned int threadnum, i, j, level; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
270 unsigned short damage_coords[4]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
271 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
|
272 int barcount = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
273 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
274 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
|
275 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
276 print_status("Memory allocations"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 error_exit("Allocation of memory failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
284 pthread_exit(NULL); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
285 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
286 print_status("Allocations done"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
287 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
288 draw.display = NULL; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
289 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
290 while (threads.control != STOP) { |
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 //print_status("start sleep"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
294 struct timespec sleeptime; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
295 sleeptime.tv_sec = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
296 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
|
297 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
|
298 //print_status("end sleep"); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
301 /* 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
|
302 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
303 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
|
304 i = threads.dirty; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
305 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
|
306 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
307 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
308 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
|
309 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
|
310 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
|
311 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
312 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
|
313 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
|
314 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
|
315 if (conf.geo[threadnum].orientation < 2) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
316 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
|
317 *(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
|
318 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
|
319 } else { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
320 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
|
321 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
|
322 *(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
|
323 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
324 print_status("Geometry recalculations"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
325 scale = conf.geo[threadnum].height / |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
326 (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
|
327 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
|
328 (2*conf.data[threadnum].linearity - 1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
329 y00 = -log(-x00) * scale; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
330 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
|
331 memset(level1, 0, 256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
332 memset(peak1, 0, 256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
333 memset(peak2, 0, 256*sizeof(short)); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
334 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
335 draw_init(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
336 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
337 /*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
|
338 }*/ |
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 /* 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
|
341 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
|
342 levelsw = level1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
343 level1 = level2; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
344 level2 = levelsw; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
345 levelsw = peak1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
346 peak1 = peak2; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
347 peak2 = levelsw; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
348 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
349 for (i = 0; i < barcount; i++) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
350 level = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
351 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
|
352 if (level < freq_data[j]) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
353 level = freq_data[j]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
354 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
|
355 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
|
356 if (level < conf.geo[threadnum].height) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
357 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
|
358 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
|
359 else level1[i] = level; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
360 } 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
|
361 if (conf.peak[threadnum].enabled) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
362 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
|
363 peak1[i] = level1[i]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
364 peakstep[i] = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
365 } 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
|
366 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
|
367 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
|
368 else peak1[i] = 0; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
369 else { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
370 peak1[i] = peak2[i]; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
371 peakstep[i]++; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
372 } |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
376 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
377 draw_start(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
378 for (i = 0; i < barcount; i++) |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
379 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
|
380 draw_end(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
381 pthread_mutex_unlock(&threads.mutex1); |
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 print_status("Worker thread: Exiting"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
385 if (draw.display != NULL) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
386 draw_close(&draw, damage_coords); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
387 XCloseDisplay(draw.display); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
388 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
389 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
|
390 return NULL; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
391 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
392 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
393 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
394 // da xmms functions |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
395 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
396 static void rootvis_init(void) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
397 int rc1; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
398 print_status("Initializing"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
399 pthread_mutex_init(&threads.mutex1, NULL); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
400 threads.control = GO; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
401 clean_data(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
402 config_init(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
403 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
|
404 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
|
405 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
|
406 error_exit("Thread creation failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
407 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
408 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
|
409 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
|
410 error_exit("Thread creation failed"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
411 } |
910
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
412 plugin_is_initted = TRUE; |
900
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
413 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
414 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
415 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
|
416 if ( plugin_is_initted ) |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
417 { |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
418 print_status("Cleanup... "); |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
419 threads.control = STOP; |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
420 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
|
421 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
|
422 print_status("Clean Exit"); |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
423 plugin_is_initted = FALSE; |
5aaf6c282617
[svn] rootvis: do not call cleanup routines if the plugin was not initted
giacomo
parents:
900
diff
changeset
|
424 } |
900
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
427 static void rootvis_about(void) |
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 print_status("About"); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
432 static void rootvis_configure(void) |
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 print_status("Configuration trigger"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
435 config_init(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
436 config_show(2); |
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 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
439 static void rootvis_playback_start(void) |
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 print_status("Playback starting"); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
442 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
443 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
444 static void rootvis_playback_stop(void) |
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 clean_data(); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
447 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
448 |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
449 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
|
450 int channel, bucket; |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
451 pthread_mutex_lock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
452 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
|
453 for (channel = 0; channel < 2; channel++) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
454 for (bucket = 0; bucket < 256; bucket++) { |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
455 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
|
456 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
|
457 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
|
458 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
459 } |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
460 pthread_mutex_unlock(&threads.mutex1); |
d985f0dcdeb0
[svn] - add a starting point for xmms-rootvis port. giacomo will need to
nenolod
parents:
diff
changeset
|
461 } |