Mercurial > audlegacy
annotate Plugins/Visualization/libvisual-proxy/main.c @ 395:0923a41170bb trunk
[svn] Add S3M support back after receiving a convincing testcase.
author | chainsaw |
---|---|
date | Sat, 07 Jan 2006 06:18:13 -0800 |
parents | 244cc47a7ae3 |
children |
rev | line source |
---|---|
61 | 1 #include <stdlib.h> |
2 #include <stdio.h> | |
3 #include <unistd.h> | |
4 #include <string.h> | |
5 | |
6 #include <audacious/plugin.h> | |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
257
diff
changeset
|
7 #include <libaudacious/util.h> |
61 | 8 #include <libaudacious/beepctrl.h> |
9 | |
10 #include <SDL.h> | |
11 #include <SDL_thread.h> | |
12 | |
13 #include <gtk/gtk.h> | |
14 #include <glib/gi18n.h> | |
15 | |
16 #include <libvisual/libvisual.h> | |
17 | |
18 #include "config.h" | |
19 | |
20 #include "lv_bmp_config.h" | |
21 #include "about.h" | |
22 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
23 #define LV_XMMS_DEFAULT_INPUT_PLUGIN "alsa" |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
24 #undef LV_XMMS_ENABLE_DEBUG |
61 | 25 |
26 /* SDL variables */ | |
27 static SDL_Surface *screen = NULL; | |
28 static SDL_Color sdlpal[256]; | |
29 static SDL_Thread *render_thread; | |
30 static SDL_mutex *pcm_mutex; | |
31 | |
32 /* Libvisual and visualisation variables */ | |
33 static VisVideo *video; | |
34 static VisPalette *pal; | |
35 | |
36 static char song_name[1024]; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
37 static char *cur_lv_plugin = NULL; |
61 | 38 |
39 static VisBin *bin = NULL; | |
40 | |
41 static VisSongInfo *songinfo; | |
42 | |
43 static Options *options; | |
44 | |
45 static int gl_plug = 0; | |
46 | |
47 static gint16 xmmspcm[2][512]; | |
48 | |
49 /* Thread state variables */ | |
50 static int visual_running = 0; | |
51 static int visual_stopped = 1; | |
52 | |
53 static void lv_bmp_init (void); | |
54 static void lv_bmp_cleanup (void); | |
55 static void lv_bmp_disable (VisPlugin *); | |
56 static void lv_bmp_playback_start (void); | |
57 static void lv_bmp_playback_stop (void); | |
58 static void lv_bmp_render_pcm (gint16 data[2][512]); | |
59 | |
60 static int sdl_quit (void); | |
61 static void sdl_set_pal (void); | |
62 static void sdl_draw (SDL_Surface *screen); | |
63 static int sdl_create (int width, int height); | |
64 static int sdl_event_handle (void); | |
65 | |
66 static int visual_upload_callback (VisInput *input, VisAudio *audio, void *private); | |
67 static int visual_resize (int width, int height); | |
68 static int visual_initialize (int width, int height); | |
69 static int visual_render (void*); | |
70 | |
71 static gint disable_func (gpointer data); | |
72 static void dummy (GtkWidget *widget, gpointer data); | |
73 | |
74 VisPlugin *get_vplugin_info (void); | |
75 | |
76 VisPlugin lv_bmp_vp = | |
77 { | |
78 NULL, /* (void*) handle, filled in by xmms */ | |
79 NULL, /* (char*) Filename, filled in by xmms */ | |
80 0, /* The session ID for attaching to the control socket */ | |
81 "libvisual proxy plugin", /* description */ | |
82 2, /* Numbers of PCM channels wanted in the call to render_pcm */ | |
83 0, /* Numbers of freq channels wanted in the call to render_freq */ | |
84 lv_bmp_init, /* init */ | |
317
45a0d9a765be
[svn] Begin resurrecting config dialog. It compiles. Basic functionality is available, but see debug spew for TODO list.
chainsaw
parents:
314
diff
changeset
|
85 lv_bmp_cleanup, /* cleanup */ |
61 | 86 NULL, /* about */ |
321
bd81a73eadff
[svn] Okay, braindead configuration handling. Disabling config button for now.
chainsaw
parents:
318
diff
changeset
|
87 NULL, /* configure */ |
317
45a0d9a765be
[svn] Begin resurrecting config dialog. It compiles. Basic functionality is available, but see debug spew for TODO list.
chainsaw
parents:
314
diff
changeset
|
88 lv_bmp_disable, /* disable plugin */ |
61 | 89 lv_bmp_playback_start, /* playback start */ |
90 lv_bmp_playback_stop, /* playback stop */ | |
91 lv_bmp_render_pcm, /* render pcm */ | |
92 NULL, /* render freq */ | |
93 }; | |
94 | |
95 VisPlugin *get_vplugin_info () | |
96 { | |
97 return &lv_bmp_vp; | |
98 } | |
99 | |
100 static char *lv_bmp_get_songname () | |
101 { | |
102 return xmms_remote_get_playlist_title (lv_bmp_vp.xmms_session, | |
103 xmms_remote_get_playlist_pos (lv_bmp_vp.xmms_session)); | |
104 } | |
105 | |
106 static void lv_bmp_init () | |
107 { | |
108 char **argv; | |
109 int argc; | |
110 gchar *msg; | |
111 GtkWidget *msgwin; | |
112 | |
113 if (!visual_is_initialized ()) { | |
114 argv = g_malloc (sizeof(char*)); | |
257
256b3acc87d4
[svn] Properly report Audacious instead of XMMS or BMP in all places. Patch by laci; closes bug #379.
chainsaw
parents:
61
diff
changeset
|
115 argv[0] = g_strdup (_("Audacious plugin")); |
61 | 116 argc = 1; |
117 | |
118 visual_init (&argc, &argv); | |
119 | |
120 g_free (argv[0]); | |
121 g_free (argv); | |
122 } | |
123 | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
124 #ifdef LV_XMMS_ENABLE_DEBUG |
61 | 125 visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_HIGH); |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
126 #else |
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
127 visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_NONE); |
61 | 128 #endif |
129 | |
130 options = lv_bmp_config_open (); | |
131 if (!options) { | |
132 visual_log (VISUAL_LOG_CRITICAL, _("Cannot get options")); | |
133 return; | |
134 } | |
135 | |
136 lv_bmp_config_load_prefs (); | |
137 | |
138 if (SDL_Init (SDL_INIT_VIDEO) < 0) { | |
139 msg = g_strconcat (_("Cannot initialize SDL!\n"), | |
140 SDL_GetError(), | |
141 "\n\n", PACKAGE_NAME, | |
375
244cc47a7ae3
[svn] We have no choice but to continue as planned. Deploy the sentinels!
chainsaw
parents:
321
diff
changeset
|
142 _(" will not be loaded."), NULL); |
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
257
diff
changeset
|
143 msgwin = xmms_show_message ("libvisual-proxy", msg, _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
61 | 144 gtk_widget_show (msgwin); |
145 g_free (msg); | |
146 return; | |
147 } | |
148 | |
149 pcm_mutex = SDL_CreateMutex (); | |
150 | |
151 if (strlen (options->last_plugin) <= 0 ) { | |
152 visual_log (VISUAL_LOG_INFO, _("Last plugin: (none)")); | |
153 } else { | |
154 visual_log (VISUAL_LOG_INFO, _("Last plugin: %s"), options->last_plugin); | |
155 } | |
156 | |
157 cur_lv_plugin = options->last_plugin; | |
158 if (!(visual_actor_valid_by_name (cur_lv_plugin))) { | |
159 visual_log (VISUAL_LOG_INFO, _("%s is not a valid actor plugin"), cur_lv_plugin); | |
160 cur_lv_plugin = lv_bmp_config_get_next_actor (); | |
161 } | |
162 | |
163 SDL_WM_SetCaption (cur_lv_plugin, cur_lv_plugin); | |
164 | |
165 if (!cur_lv_plugin) { | |
166 visual_log (VISUAL_LOG_CRITICAL, _("Could not get actor plugin")); | |
167 lv_bmp_config_close (); | |
168 return; | |
169 } else { | |
170 lv_bmp_config_set_current_actor (cur_lv_plugin); | |
171 } | |
172 | |
173 visual_log (VISUAL_LOG_DEBUG, "calling SDL_CreateThread()"); | |
174 | |
175 render_thread = SDL_CreateThread ((void *) visual_render, NULL); | |
176 } | |
177 | |
178 static void lv_bmp_cleanup () | |
179 { | |
180 visual_log (VISUAL_LOG_DEBUG, "entering cleanup..."); | |
181 visual_running = 0; | |
182 | |
183 SDL_WaitThread (render_thread, NULL); | |
184 | |
185 render_thread = NULL; | |
186 visual_stopped = 1; | |
187 | |
188 visual_log (VISUAL_LOG_DEBUG, "calling SDL_DestroyMutex()"); | |
189 SDL_DestroyMutex (pcm_mutex); | |
190 | |
191 pcm_mutex = NULL; | |
192 | |
193 /* | |
194 * WARNING This must be synchronized with config module. | |
195 */ | |
196 | |
197 options->last_plugin = cur_lv_plugin; | |
198 | |
199 visual_log (VISUAL_LOG_DEBUG, "calling lv_bmp_config_save_prefs()"); | |
200 lv_bmp_config_save_prefs (); | |
201 | |
202 visual_log (VISUAL_LOG_DEBUG, "closing config file"); | |
203 lv_bmp_config_close (); | |
204 | |
205 visual_log (VISUAL_LOG_DEBUG, "destroying VisBin..."); | |
206 visual_object_unref (VISUAL_OBJECT (bin)); | |
207 | |
208 visual_log (VISUAL_LOG_DEBUG, "calling sdl_quit()"); | |
209 sdl_quit (); | |
210 | |
211 visual_log (VISUAL_LOG_DEBUG, "calling visual_quit()"); | |
212 visual_quit (); | |
213 } | |
214 | |
215 static void lv_bmp_disable (VisPlugin* plugin) | |
216 { | |
217 | |
218 } | |
219 | |
220 static void lv_bmp_playback_start () | |
221 { | |
222 | |
223 } | |
224 static void lv_bmp_playback_stop () | |
225 { | |
226 | |
227 } | |
228 | |
229 static void lv_bmp_render_pcm (gint16 data[2][512]) | |
230 { | |
231 if (visual_running == 1) { | |
232 SDL_mutexP (pcm_mutex); | |
233 memcpy (xmmspcm, data, sizeof(gint16)*2*512); | |
234 strncpy (song_name, lv_bmp_get_songname (), 1023); | |
235 SDL_mutexV (pcm_mutex); | |
236 } | |
237 } | |
238 | |
239 static int sdl_quit () | |
240 { | |
241 visual_log (VISUAL_LOG_DEBUG, "Calling SDL_FreeSurface()"); | |
242 if (screen != NULL) | |
243 SDL_FreeSurface (screen); | |
244 | |
245 screen = NULL; | |
246 | |
247 visual_log (VISUAL_LOG_DEBUG, "sdl_quit: calling SDL_Quit()"); | |
248 /* | |
249 * FIXME this doesn't work! | |
250 */ | |
251 SDL_Quit (); | |
252 | |
253 visual_log (VISUAL_LOG_DEBUG, "Leaving..."); | |
254 return 0; | |
255 } | |
256 | |
257 static void sdl_set_pal () | |
258 { | |
259 int i; | |
260 | |
261 visual_log_return_if_fail (screen != NULL); | |
262 | |
263 if (pal != NULL) { | |
264 for (i = 0; i < 256; i ++) { | |
265 sdlpal[i].r = pal->colors[i].r; | |
266 sdlpal[i].g = pal->colors[i].g; | |
267 sdlpal[i].b = pal->colors[i].b; | |
268 } | |
269 SDL_SetColors (screen, sdlpal, 0, 256); | |
270 } | |
271 } | |
272 | |
273 static void sdl_draw (SDL_Surface *screen) | |
274 { | |
275 visual_log_return_if_fail (screen != NULL); | |
276 SDL_Flip (screen); | |
277 } | |
278 | |
279 static int sdl_create (int width, int height) | |
280 { | |
281 const SDL_VideoInfo *videoinfo; | |
282 int videoflags; | |
283 | |
284 if (screen != NULL) | |
285 SDL_FreeSurface (screen); | |
286 | |
287 visual_log (VISUAL_LOG_DEBUG, "sdl_create video->bpp %d", video->bpp); | |
288 visual_log (VISUAL_LOG_DEBUG, gl_plug ? "OpenGl plugin at create: yes" : "OpenGl plugin at create: no"); | |
289 | |
290 if (gl_plug == 1) { | |
291 videoinfo = SDL_GetVideoInfo (); | |
292 | |
293 if (videoinfo == 0) { | |
294 visual_log (VISUAL_LOG_CRITICAL, _("Could not get video info")); | |
295 return -1; | |
296 } | |
297 | |
298 videoflags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_RESIZABLE; | |
299 | |
300 if (videoinfo->hw_available) | |
301 videoflags |= SDL_HWSURFACE; | |
302 else | |
303 videoflags |= SDL_SWSURFACE; | |
304 | |
305 if (videoinfo->blit_hw) | |
306 videoflags |= SDL_HWACCEL; | |
307 | |
308 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); | |
309 | |
310 visual_log (VISUAL_LOG_DEBUG, "Setting video mode %dx%d", width, height); | |
311 screen = SDL_SetVideoMode (width, height, 16, videoflags); | |
312 } else { | |
313 visual_log (VISUAL_LOG_DEBUG, "Setting video mode %dx%d", width, height); | |
314 screen = SDL_SetVideoMode (width, height, video->bpp * 8, SDL_RESIZABLE); | |
315 } | |
316 | |
317 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY / 4, SDL_DEFAULT_REPEAT_INTERVAL / 4); | |
318 | |
319 visual_video_set_buffer (video, screen->pixels); | |
320 visual_log (VISUAL_LOG_DEBUG, "pointer to the pixels: %p", screen->pixels); | |
321 | |
322 visual_video_set_pitch (video, screen->pitch); | |
323 visual_log (VISUAL_LOG_DEBUG, "pitch: %d", video->pitch); | |
324 | |
325 return 0; | |
326 } | |
327 | |
328 static int visual_initialize (int width, int height) | |
329 { | |
330 VisInput *input; | |
331 VisVideoDepth depth; | |
332 int ret; | |
333 | |
334 bin = visual_bin_new (); | |
335 visual_bin_set_supported_depth (bin, VISUAL_VIDEO_DEPTH_ALL); | |
336 // visual_bin_set_preferred_depth (bin, VISUAL_BIN_DEPTH_LOWEST); | |
337 | |
338 depth = visual_video_depth_enum_from_value (options->depth); | |
339 if (depth == VISUAL_VIDEO_DEPTH_ERROR) | |
340 depth = VISUAL_VIDEO_DEPTH_24BIT; | |
341 options->depth = depth; | |
342 | |
343 video = visual_video_new (); | |
344 | |
345 ret = visual_video_set_depth (video, depth); | |
346 if (ret < 0) { | |
347 visual_log (VISUAL_LOG_CRITICAL, _("Cannot set video depth")); | |
348 return -1; | |
349 } | |
350 visual_video_set_dimension (video, width, height); | |
351 | |
352 ret = visual_bin_set_video (bin, video); | |
353 if (ret < 0) { | |
354 visual_log (VISUAL_LOG_CRITICAL, _("Cannot set video")); | |
355 return -1; | |
356 } | |
357 /*visual_bin_connect_by_names (bin, cur_lv_plugin, NULL);*/ | |
358 visual_bin_connect_by_names (bin, cur_lv_plugin, LV_XMMS_DEFAULT_INPUT_PLUGIN); | |
359 | |
360 if (visual_bin_get_depth (bin) == VISUAL_VIDEO_DEPTH_GL) { | |
361 visual_video_set_depth (video, VISUAL_VIDEO_DEPTH_GL); | |
362 gl_plug = 1; | |
363 } else { | |
364 gl_plug = 0; | |
365 } | |
366 | |
367 visual_log (VISUAL_LOG_DEBUG, gl_plug ? "OpenGl plugin: yes" : "OpenGl plugin: no"); | |
368 ret = sdl_create (width, height); | |
369 if (ret < 0) { | |
370 return -1; | |
371 } | |
372 | |
373 /* Called so the flag is set to FALSE, seen we create the initial environment here */ | |
374 visual_bin_depth_changed (bin); | |
375 | |
376 input = visual_bin_get_input (bin); | |
377 ret = visual_input_set_callback (input, visual_upload_callback, NULL); | |
378 if (ret < 0) { | |
379 visual_log (VISUAL_LOG_CRITICAL, _("Cannot set input plugin callback")); | |
380 return -1; | |
381 } | |
382 | |
383 visual_bin_switch_set_style (bin, VISUAL_SWITCH_STYLE_MORPH); | |
384 visual_bin_switch_set_automatic (bin, TRUE); | |
385 visual_bin_switch_set_mode (bin, VISUAL_MORPH_MODE_TIME); | |
386 visual_bin_switch_set_time (bin, 4, 0); | |
387 | |
388 visual_bin_realize (bin); | |
389 visual_bin_sync (bin, FALSE); | |
390 | |
391 return 0; | |
392 } | |
393 | |
394 static int visual_upload_callback (VisInput *input, VisAudio *audio, void *private_data) | |
395 { | |
396 int i; | |
397 | |
398 visual_log_return_val_if_fail (audio != NULL, -1); | |
399 | |
400 for (i = 0; i < 512; i++) { | |
401 audio->plugpcm[0][i] = xmmspcm[0][i]; | |
402 audio->plugpcm[1][i] = xmmspcm[1][i]; | |
403 } | |
404 | |
405 return 0; | |
406 } | |
407 | |
408 static int visual_resize (int width, int height) | |
409 { | |
410 visual_video_set_dimension (video, width, height); | |
411 | |
412 sdl_create (width, height); | |
413 | |
414 options->width = width; | |
415 options->height = height; | |
416 | |
417 visual_bin_sync (bin, FALSE); | |
418 | |
419 return 0; | |
420 } | |
421 | |
422 static int visual_render (void *arg) | |
423 { | |
424 visual_running = 1; | |
425 visual_stopped = 0; | |
426 static long render_time, now; | |
427 long frame_length; | |
428 long idle_time; | |
429 long frames; | |
430 int ret; | |
431 | |
432 ret = visual_initialize (options->width, options->height); | |
433 if (ret < 0) { | |
434 visual_log (VISUAL_LOG_CRITICAL, _("Cannot initialize plugin's visual stuff")); | |
435 return -1; | |
436 } | |
437 | |
438 frame_length = (1.0 / options->fps) * 1000; | |
439 frames = 0; | |
440 while (visual_running == 1) { | |
441 /* Update songinfo */ | |
442 songinfo = visual_actor_get_songinfo (visual_bin_get_actor (bin)); | |
443 visual_songinfo_set_type (songinfo, VISUAL_SONGINFO_TYPE_SIMPLE); | |
444 | |
445 visual_songinfo_set_simple_name (songinfo, song_name); | |
446 | |
447 /* On depth change */ | |
448 if (visual_bin_depth_changed (bin) == TRUE) { | |
449 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
450 SDL_LockSurface (screen); | |
451 | |
452 visual_video_set_buffer (video, screen->pixels); | |
453 if (visual_bin_get_depth (bin) == VISUAL_VIDEO_DEPTH_GL) | |
454 gl_plug = 1; | |
455 else | |
456 gl_plug = 0; | |
457 | |
458 sdl_create (options->width, options->height); | |
459 visual_bin_sync (bin, TRUE); | |
460 | |
461 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
462 SDL_UnlockSurface (screen); | |
463 } | |
464 | |
465 render_time = SDL_GetTicks(); | |
466 | |
467 if (gl_plug == 1) { | |
468 visual_bin_run (bin); | |
469 | |
470 SDL_GL_SwapBuffers (); | |
471 } else { | |
472 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
473 SDL_LockSurface (screen); | |
474 | |
475 visual_bin_run (bin); | |
476 | |
477 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
478 SDL_UnlockSurface (screen); | |
479 | |
480 pal = visual_bin_get_palette (bin); | |
481 sdl_set_pal (); | |
482 | |
483 sdl_draw (screen); | |
484 } | |
485 | |
486 now = SDL_GetTicks(); | |
487 idle_time = now - render_time; | |
488 | |
489 if (idle_time < frame_length) | |
490 usleep(idle_time * 900); | |
491 | |
492 sdl_event_handle (); | |
493 | |
494 if (options->fullscreen && !(screen->flags & SDL_FULLSCREEN)) | |
495 SDL_WM_ToggleFullScreen (screen); | |
496 frames++; | |
497 /* | |
498 * Sometime we actualize the frame_length, because we let user | |
499 * choose maximum FPS dinamically. | |
500 */ | |
501 if (frames > options->fps) { | |
502 frames = 0; | |
503 frame_length = (1.0 / options->fps) * 1000; | |
504 } | |
505 } | |
506 | |
507 visual_stopped = 1; | |
508 return 0; | |
509 } | |
510 | |
511 static int sdl_event_handle () | |
512 { | |
513 SDL_Event event; | |
514 VisEventQueue *vevent; | |
318
43e7cbbf77e1
[svn] Convert to confdb usage. Squash most qualifier-related warnings. Remove pixmap/icon functionality. Eliminate dead code.
chainsaw
parents:
317
diff
changeset
|
515 char *next_plugin; |
61 | 516 |
517 while (SDL_PollEvent (&event)) { | |
518 vevent = visual_plugin_get_eventqueue (visual_actor_get_plugin (visual_bin_get_actor (bin))); | |
519 | |
520 switch (event.type) { | |
521 case SDL_KEYUP: | |
522 visual_event_queue_add_keyboard (vevent, event.key.keysym.sym, event.key.keysym.mod, VISUAL_KEY_UP); | |
523 break; | |
524 | |
525 case SDL_KEYDOWN: | |
526 visual_event_queue_add_keyboard (vevent, event.key.keysym.sym, event.key.keysym.mod, VISUAL_KEY_DOWN); | |
527 | |
528 switch (event.key.keysym.sym) { | |
529 /* XMMS CONTROLS */ | |
530 case SDLK_UP: | |
531 xmms_remote_set_main_volume (lv_bmp_vp.xmms_session, | |
532 xmms_remote_get_main_volume (lv_bmp_vp.xmms_session) + 1); | |
533 break; | |
534 case SDLK_DOWN: | |
535 xmms_remote_set_main_volume (lv_bmp_vp.xmms_session, | |
536 xmms_remote_get_main_volume (lv_bmp_vp.xmms_session) - 1); | |
537 break; | |
538 case SDLK_LEFT: | |
539 if (xmms_remote_is_playing (lv_bmp_vp.xmms_session)) | |
540 xmms_remote_jump_to_time (lv_bmp_vp.xmms_session, | |
541 xmms_remote_get_output_time (lv_bmp_vp.xmms_session) - 5000); | |
542 break; | |
543 case SDLK_RIGHT: | |
544 if (xmms_remote_is_playing (lv_bmp_vp.xmms_session)) | |
545 xmms_remote_jump_to_time (lv_bmp_vp.xmms_session, | |
546 xmms_remote_get_output_time (lv_bmp_vp.xmms_session) + 5000); | |
547 break; | |
548 case SDLK_z: | |
549 xmms_remote_playlist_prev (lv_bmp_vp.xmms_session); | |
550 break; | |
551 | |
552 case SDLK_x: | |
553 xmms_remote_play (lv_bmp_vp.xmms_session); | |
554 break; | |
555 | |
556 case SDLK_c: | |
557 xmms_remote_pause (lv_bmp_vp.xmms_session); | |
558 break; | |
559 | |
560 case SDLK_v: | |
561 xmms_remote_stop (lv_bmp_vp.xmms_session); | |
562 break; | |
563 | |
564 case SDLK_b: | |
565 xmms_remote_playlist_next (lv_bmp_vp.xmms_session); | |
566 break; | |
567 | |
568 /* PLUGIN CONTROLS */ | |
569 case SDLK_F11: | |
570 case SDLK_TAB: | |
571 SDL_WM_ToggleFullScreen (screen); | |
572 lv_bmp_config_toggle_fullscreen(); | |
573 | |
574 if ((screen->flags & SDL_FULLSCREEN) > 0) | |
575 SDL_ShowCursor (SDL_DISABLE); | |
576 else | |
577 SDL_ShowCursor (SDL_ENABLE); | |
578 | |
579 break; | |
580 | |
581 case SDLK_a: | |
582 next_plugin = lv_bmp_config_get_prev_actor (); | |
583 | |
584 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
585 SDL_LockSurface (screen); | |
586 | |
587 if (next_plugin != NULL && (strcmp (next_plugin, cur_lv_plugin) != 0)) { | |
588 lv_bmp_config_set_current_actor (next_plugin); | |
589 cur_lv_plugin = next_plugin; | |
590 visual_bin_set_morph_by_name (bin, lv_bmp_config_morph_plugin()); | |
591 visual_bin_switch_actor_by_name (bin, cur_lv_plugin); | |
592 } | |
593 | |
594 SDL_WM_SetCaption (cur_lv_plugin, cur_lv_plugin); | |
595 | |
596 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
597 SDL_UnlockSurface (screen); | |
598 | |
599 break; | |
600 | |
601 case SDLK_s: | |
602 next_plugin = lv_bmp_config_get_next_actor (); | |
603 | |
604 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
605 SDL_LockSurface (screen); | |
606 | |
607 if (next_plugin != NULL && (strcmp (next_plugin, cur_lv_plugin) != 0)) { | |
608 lv_bmp_config_set_current_actor (next_plugin); | |
609 cur_lv_plugin = next_plugin; | |
610 visual_bin_set_morph_by_name (bin, lv_bmp_config_morph_plugin()); | |
611 visual_bin_switch_actor_by_name (bin, cur_lv_plugin); | |
612 } | |
613 | |
614 SDL_WM_SetCaption (cur_lv_plugin, cur_lv_plugin); | |
615 | |
616 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
617 SDL_UnlockSurface (screen); | |
618 | |
619 break; | |
620 | |
621 default: /* to avoid warnings */ | |
622 break; | |
623 } | |
624 break; | |
625 | |
626 case SDL_VIDEORESIZE: | |
627 visual_resize (event.resize.w, event.resize.h); | |
628 break; | |
629 | |
630 case SDL_MOUSEMOTION: | |
631 visual_event_queue_add_mousemotion (vevent, event.motion.x, event.motion.y); | |
632 break; | |
633 | |
634 case SDL_MOUSEBUTTONDOWN: | |
635 visual_event_queue_add_mousebutton (vevent, event.button.button, VISUAL_MOUSE_DOWN, | |
636 event.button.x, event.button.y); | |
637 break; | |
638 | |
639 case SDL_MOUSEBUTTONUP: | |
640 visual_event_queue_add_mousebutton (vevent, event.button.button, VISUAL_MOUSE_UP, | |
641 event.button.x, event.button.y); | |
642 break; | |
643 | |
644 case SDL_QUIT: | |
645 GDK_THREADS_ENTER (); | |
646 gtk_idle_add (disable_func, NULL); | |
647 GDK_THREADS_LEAVE (); | |
648 break; | |
649 | |
650 default: /* to avoid warnings */ | |
651 break; | |
652 } | |
653 } | |
654 | |
655 return 0; | |
656 } | |
657 | |
658 static gint disable_func (gpointer data) | |
659 { | |
660 lv_bmp_vp.disable_plugin (&lv_bmp_vp); | |
661 | |
662 return FALSE; | |
663 } | |
664 | |
665 | |
666 static void dummy (GtkWidget *widget, gpointer data) | |
667 { | |
668 } | |
669 |