Mercurial > audlegacy
annotate Plugins/Visualization/libvisual-proxy/main.c @ 316:950f104f2e11 trunk
[svn] Fix spacing in --help output, patch by Mikachu.
| author | chainsaw |
|---|---|
| date | Sun, 18 Dec 2005 06:41:22 -0800 |
| parents | 31725d73a697 |
| children | 45a0d9a765be |
| 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 | |
| 23 #define LV_XMMS_DEFAULT_INPUT_PLUGIN "esd" | |
| 24 | |
| 25 /* SDL variables */ | |
| 26 static SDL_Surface *screen = NULL; | |
| 27 static SDL_Color sdlpal[256]; | |
| 28 static SDL_Thread *render_thread; | |
| 29 static SDL_mutex *pcm_mutex; | |
| 30 static SDL_Surface *icon; | |
| 31 | |
| 32 /* Libvisual and visualisation variables */ | |
| 33 static VisVideo *video; | |
| 34 static VisPalette *pal; | |
| 35 | |
| 36 static char song_name[1024]; | |
| 37 static const char *cur_lv_plugin = NULL; | |
| 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 */ | |
| 85 lv_bmp_cleanup, /* cleanup */ | |
| 86 NULL, /* about */ | |
| 87 NULL, /* configure */ | |
| 88 lv_bmp_disable, /* disable plugin */ | |
| 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 | |
| 124 #if LV_XMMS_ENABLE_DEBUG | |
| 125 visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_HIGH); | |
| 126 #endif | |
| 127 /*g_print ("Trying to set verboseness\n"); | |
| 128 visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_LOW); | |
| 129 g_print ("Verboseness done\n");*/ | |
| 130 | |
| 131 options = lv_bmp_config_open (); | |
| 132 if (!options) { | |
| 133 visual_log (VISUAL_LOG_CRITICAL, _("Cannot get options")); | |
| 134 return; | |
| 135 } | |
| 136 | |
| 137 lv_bmp_config_load_prefs (); | |
| 138 | |
| 139 if (SDL_Init (SDL_INIT_VIDEO) < 0) { | |
| 140 msg = g_strconcat (_("Cannot initialize SDL!\n"), | |
| 141 SDL_GetError(), | |
| 142 "\n\n", PACKAGE_NAME, | |
| 143 _(" will not be loaded."), 0); | |
|
314
31725d73a697
[svn] Squash the implicit declaration warnings by including the correct util.h
chainsaw
parents:
257
diff
changeset
|
144 msgwin = xmms_show_message ("libvisual-proxy", msg, _("Accept"), TRUE, GTK_SIGNAL_FUNC(dummy), NULL); |
| 61 | 145 gtk_widget_show (msgwin); |
| 146 g_free (msg); | |
| 147 return; | |
| 148 } | |
| 149 | |
| 150 icon = SDL_LoadBMP (options->icon_file); | |
| 151 if (icon) | |
| 152 SDL_WM_SetIcon (icon, NULL); | |
| 153 else | |
| 154 visual_log (VISUAL_LOG_WARNING, _("Cannot not load icon: %s"), SDL_GetError()); | |
| 155 | |
| 156 pcm_mutex = SDL_CreateMutex (); | |
| 157 | |
| 158 if (strlen (options->last_plugin) <= 0 ) { | |
| 159 visual_log (VISUAL_LOG_INFO, _("Last plugin: (none)")); | |
| 160 } else { | |
| 161 visual_log (VISUAL_LOG_INFO, _("Last plugin: %s"), options->last_plugin); | |
| 162 } | |
| 163 | |
| 164 cur_lv_plugin = options->last_plugin; | |
| 165 if (!(visual_actor_valid_by_name (cur_lv_plugin))) { | |
| 166 visual_log (VISUAL_LOG_INFO, _("%s is not a valid actor plugin"), cur_lv_plugin); | |
| 167 cur_lv_plugin = lv_bmp_config_get_next_actor (); | |
| 168 } | |
| 169 | |
| 170 SDL_WM_SetCaption (cur_lv_plugin, cur_lv_plugin); | |
| 171 | |
| 172 if (!cur_lv_plugin) { | |
| 173 visual_log (VISUAL_LOG_CRITICAL, _("Could not get actor plugin")); | |
| 174 lv_bmp_config_close (); | |
| 175 return; | |
| 176 } else { | |
| 177 lv_bmp_config_set_current_actor (cur_lv_plugin); | |
| 178 } | |
| 179 | |
| 180 visual_log (VISUAL_LOG_DEBUG, "calling SDL_CreateThread()"); | |
| 181 | |
| 182 render_thread = SDL_CreateThread ((void *) visual_render, NULL); | |
| 183 } | |
| 184 | |
| 185 static void lv_bmp_cleanup () | |
| 186 { | |
| 187 visual_log (VISUAL_LOG_DEBUG, "entering cleanup..."); | |
| 188 visual_running = 0; | |
| 189 | |
| 190 SDL_WaitThread (render_thread, NULL); | |
| 191 | |
| 192 render_thread = NULL; | |
| 193 visual_stopped = 1; | |
| 194 | |
| 195 visual_log (VISUAL_LOG_DEBUG, "calling SDL_DestroyMutex()"); | |
| 196 SDL_DestroyMutex (pcm_mutex); | |
| 197 | |
| 198 pcm_mutex = NULL; | |
| 199 | |
| 200 /* | |
| 201 * WARNING This must be synchronized with config module. | |
| 202 */ | |
| 203 | |
| 204 options->last_plugin = cur_lv_plugin; | |
| 205 | |
| 206 visual_log (VISUAL_LOG_DEBUG, "calling lv_bmp_config_save_prefs()"); | |
| 207 lv_bmp_config_save_prefs (); | |
| 208 | |
| 209 visual_log (VISUAL_LOG_DEBUG, "closing config file"); | |
| 210 lv_bmp_config_close (); | |
| 211 | |
| 212 if (icon != NULL) | |
| 213 SDL_FreeSurface (icon); | |
| 214 | |
| 215 visual_log (VISUAL_LOG_DEBUG, "destroying VisBin..."); | |
| 216 visual_object_unref (VISUAL_OBJECT (bin)); | |
| 217 | |
| 218 visual_log (VISUAL_LOG_DEBUG, "calling sdl_quit()"); | |
| 219 sdl_quit (); | |
| 220 | |
| 221 visual_log (VISUAL_LOG_DEBUG, "calling visual_quit()"); | |
| 222 visual_quit (); | |
| 223 } | |
| 224 | |
| 225 static void lv_bmp_disable (VisPlugin* plugin) | |
| 226 { | |
| 227 | |
| 228 } | |
| 229 | |
| 230 static void lv_bmp_playback_start () | |
| 231 { | |
| 232 | |
| 233 } | |
| 234 static void lv_bmp_playback_stop () | |
| 235 { | |
| 236 | |
| 237 } | |
| 238 | |
| 239 static void lv_bmp_render_pcm (gint16 data[2][512]) | |
| 240 { | |
| 241 if (visual_running == 1) { | |
| 242 SDL_mutexP (pcm_mutex); | |
| 243 memcpy (xmmspcm, data, sizeof(gint16)*2*512); | |
| 244 strncpy (song_name, lv_bmp_get_songname (), 1023); | |
| 245 SDL_mutexV (pcm_mutex); | |
| 246 } | |
| 247 } | |
| 248 | |
| 249 static int sdl_quit () | |
| 250 { | |
| 251 visual_log (VISUAL_LOG_DEBUG, "Calling SDL_FreeSurface()"); | |
| 252 if (screen != NULL) | |
| 253 SDL_FreeSurface (screen); | |
| 254 | |
| 255 screen = NULL; | |
| 256 | |
| 257 visual_log (VISUAL_LOG_DEBUG, "sdl_quit: calling SDL_Quit()"); | |
| 258 /* | |
| 259 * FIXME this doesn't work! | |
| 260 */ | |
| 261 SDL_Quit (); | |
| 262 | |
| 263 visual_log (VISUAL_LOG_DEBUG, "Leaving..."); | |
| 264 return 0; | |
| 265 } | |
| 266 | |
| 267 static void sdl_set_pal () | |
| 268 { | |
| 269 int i; | |
| 270 | |
| 271 visual_log_return_if_fail (screen != NULL); | |
| 272 | |
| 273 if (pal != NULL) { | |
| 274 for (i = 0; i < 256; i ++) { | |
| 275 sdlpal[i].r = pal->colors[i].r; | |
| 276 sdlpal[i].g = pal->colors[i].g; | |
| 277 sdlpal[i].b = pal->colors[i].b; | |
| 278 } | |
| 279 SDL_SetColors (screen, sdlpal, 0, 256); | |
| 280 } | |
| 281 } | |
| 282 | |
| 283 static void sdl_draw (SDL_Surface *screen) | |
| 284 { | |
| 285 visual_log_return_if_fail (screen != NULL); | |
| 286 SDL_Flip (screen); | |
| 287 } | |
| 288 | |
| 289 static int sdl_create (int width, int height) | |
| 290 { | |
| 291 const SDL_VideoInfo *videoinfo; | |
| 292 int videoflags; | |
| 293 | |
| 294 if (screen != NULL) | |
| 295 SDL_FreeSurface (screen); | |
| 296 | |
| 297 visual_log (VISUAL_LOG_DEBUG, "sdl_create video->bpp %d", video->bpp); | |
| 298 visual_log (VISUAL_LOG_DEBUG, gl_plug ? "OpenGl plugin at create: yes" : "OpenGl plugin at create: no"); | |
| 299 | |
| 300 if (gl_plug == 1) { | |
| 301 videoinfo = SDL_GetVideoInfo (); | |
| 302 | |
| 303 if (videoinfo == 0) { | |
| 304 visual_log (VISUAL_LOG_CRITICAL, _("Could not get video info")); | |
| 305 return -1; | |
| 306 } | |
| 307 | |
| 308 videoflags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_RESIZABLE; | |
| 309 | |
| 310 if (videoinfo->hw_available) | |
| 311 videoflags |= SDL_HWSURFACE; | |
| 312 else | |
| 313 videoflags |= SDL_SWSURFACE; | |
| 314 | |
| 315 if (videoinfo->blit_hw) | |
| 316 videoflags |= SDL_HWACCEL; | |
| 317 | |
| 318 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); | |
| 319 | |
| 320 visual_log (VISUAL_LOG_DEBUG, "Setting video mode %dx%d", width, height); | |
| 321 screen = SDL_SetVideoMode (width, height, 16, videoflags); | |
| 322 } else { | |
| 323 visual_log (VISUAL_LOG_DEBUG, "Setting video mode %dx%d", width, height); | |
| 324 screen = SDL_SetVideoMode (width, height, video->bpp * 8, SDL_RESIZABLE); | |
| 325 } | |
| 326 | |
| 327 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY / 4, SDL_DEFAULT_REPEAT_INTERVAL / 4); | |
| 328 | |
| 329 visual_video_set_buffer (video, screen->pixels); | |
| 330 visual_log (VISUAL_LOG_DEBUG, "pointer to the pixels: %p", screen->pixels); | |
| 331 | |
| 332 visual_video_set_pitch (video, screen->pitch); | |
| 333 visual_log (VISUAL_LOG_DEBUG, "pitch: %d", video->pitch); | |
| 334 | |
| 335 return 0; | |
| 336 } | |
| 337 | |
| 338 static int visual_initialize (int width, int height) | |
| 339 { | |
| 340 VisInput *input; | |
| 341 VisVideoDepth depth; | |
| 342 int ret; | |
| 343 | |
| 344 bin = visual_bin_new (); | |
| 345 visual_bin_set_supported_depth (bin, VISUAL_VIDEO_DEPTH_ALL); | |
| 346 // visual_bin_set_preferred_depth (bin, VISUAL_BIN_DEPTH_LOWEST); | |
| 347 | |
| 348 depth = visual_video_depth_enum_from_value (options->depth); | |
| 349 if (depth == VISUAL_VIDEO_DEPTH_ERROR) | |
| 350 depth = VISUAL_VIDEO_DEPTH_24BIT; | |
| 351 options->depth = depth; | |
| 352 | |
| 353 video = visual_video_new (); | |
| 354 | |
| 355 ret = visual_video_set_depth (video, depth); | |
| 356 if (ret < 0) { | |
| 357 visual_log (VISUAL_LOG_CRITICAL, _("Cannot set video depth")); | |
| 358 return -1; | |
| 359 } | |
| 360 visual_video_set_dimension (video, width, height); | |
| 361 | |
| 362 ret = visual_bin_set_video (bin, video); | |
| 363 if (ret < 0) { | |
| 364 visual_log (VISUAL_LOG_CRITICAL, _("Cannot set video")); | |
| 365 return -1; | |
| 366 } | |
| 367 /*visual_bin_connect_by_names (bin, cur_lv_plugin, NULL);*/ | |
| 368 visual_bin_connect_by_names (bin, cur_lv_plugin, LV_XMMS_DEFAULT_INPUT_PLUGIN); | |
| 369 | |
| 370 if (visual_bin_get_depth (bin) == VISUAL_VIDEO_DEPTH_GL) { | |
| 371 visual_video_set_depth (video, VISUAL_VIDEO_DEPTH_GL); | |
| 372 gl_plug = 1; | |
| 373 } else { | |
| 374 gl_plug = 0; | |
| 375 } | |
| 376 | |
| 377 visual_log (VISUAL_LOG_DEBUG, gl_plug ? "OpenGl plugin: yes" : "OpenGl plugin: no"); | |
| 378 ret = sdl_create (width, height); | |
| 379 if (ret < 0) { | |
| 380 return -1; | |
| 381 } | |
| 382 | |
| 383 /* Called so the flag is set to FALSE, seen we create the initial environment here */ | |
| 384 visual_bin_depth_changed (bin); | |
| 385 | |
| 386 input = visual_bin_get_input (bin); | |
| 387 ret = visual_input_set_callback (input, visual_upload_callback, NULL); | |
| 388 if (ret < 0) { | |
| 389 visual_log (VISUAL_LOG_CRITICAL, _("Cannot set input plugin callback")); | |
| 390 return -1; | |
| 391 } | |
| 392 | |
| 393 visual_bin_switch_set_style (bin, VISUAL_SWITCH_STYLE_MORPH); | |
| 394 visual_bin_switch_set_automatic (bin, TRUE); | |
| 395 visual_bin_switch_set_mode (bin, VISUAL_MORPH_MODE_TIME); | |
| 396 visual_bin_switch_set_time (bin, 4, 0); | |
| 397 | |
| 398 visual_bin_realize (bin); | |
| 399 visual_bin_sync (bin, FALSE); | |
| 400 | |
| 401 return 0; | |
| 402 } | |
| 403 | |
| 404 static int visual_upload_callback (VisInput *input, VisAudio *audio, void *private_data) | |
| 405 { | |
| 406 int i; | |
| 407 | |
| 408 visual_log_return_val_if_fail (audio != NULL, -1); | |
| 409 | |
| 410 for (i = 0; i < 512; i++) { | |
| 411 audio->plugpcm[0][i] = xmmspcm[0][i]; | |
| 412 audio->plugpcm[1][i] = xmmspcm[1][i]; | |
| 413 } | |
| 414 | |
| 415 return 0; | |
| 416 } | |
| 417 | |
| 418 static int visual_resize (int width, int height) | |
| 419 { | |
| 420 visual_video_set_dimension (video, width, height); | |
| 421 | |
| 422 sdl_create (width, height); | |
| 423 | |
| 424 options->width = width; | |
| 425 options->height = height; | |
| 426 | |
| 427 visual_bin_sync (bin, FALSE); | |
| 428 | |
| 429 return 0; | |
| 430 } | |
| 431 | |
| 432 static int visual_render (void *arg) | |
| 433 { | |
| 434 visual_running = 1; | |
| 435 visual_stopped = 0; | |
| 436 static long render_time, now; | |
| 437 long frame_length; | |
| 438 long idle_time; | |
| 439 long frames; | |
| 440 int ret; | |
| 441 | |
| 442 ret = visual_initialize (options->width, options->height); | |
| 443 if (ret < 0) { | |
| 444 visual_log (VISUAL_LOG_CRITICAL, _("Cannot initialize plugin's visual stuff")); | |
| 445 return -1; | |
| 446 } | |
| 447 | |
| 448 frame_length = (1.0 / options->fps) * 1000; | |
| 449 frames = 0; | |
| 450 while (visual_running == 1) { | |
| 451 /* Update songinfo */ | |
| 452 songinfo = visual_actor_get_songinfo (visual_bin_get_actor (bin)); | |
| 453 visual_songinfo_set_type (songinfo, VISUAL_SONGINFO_TYPE_SIMPLE); | |
| 454 | |
| 455 visual_songinfo_set_simple_name (songinfo, song_name); | |
| 456 | |
| 457 /* On depth change */ | |
| 458 if (visual_bin_depth_changed (bin) == TRUE) { | |
| 459 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 460 SDL_LockSurface (screen); | |
| 461 | |
| 462 visual_video_set_buffer (video, screen->pixels); | |
| 463 if (visual_bin_get_depth (bin) == VISUAL_VIDEO_DEPTH_GL) | |
| 464 gl_plug = 1; | |
| 465 else | |
| 466 gl_plug = 0; | |
| 467 | |
| 468 sdl_create (options->width, options->height); | |
| 469 visual_bin_sync (bin, TRUE); | |
| 470 | |
| 471 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 472 SDL_UnlockSurface (screen); | |
| 473 } | |
| 474 | |
| 475 render_time = SDL_GetTicks(); | |
| 476 | |
| 477 if (gl_plug == 1) { | |
| 478 visual_bin_run (bin); | |
| 479 | |
| 480 SDL_GL_SwapBuffers (); | |
| 481 } else { | |
| 482 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 483 SDL_LockSurface (screen); | |
| 484 | |
| 485 visual_bin_run (bin); | |
| 486 | |
| 487 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 488 SDL_UnlockSurface (screen); | |
| 489 | |
| 490 pal = visual_bin_get_palette (bin); | |
| 491 sdl_set_pal (); | |
| 492 | |
| 493 sdl_draw (screen); | |
| 494 } | |
| 495 | |
| 496 now = SDL_GetTicks(); | |
| 497 idle_time = now - render_time; | |
| 498 | |
| 499 if (idle_time < frame_length) | |
| 500 usleep(idle_time * 900); | |
| 501 | |
| 502 sdl_event_handle (); | |
| 503 | |
| 504 if (options->fullscreen && !(screen->flags & SDL_FULLSCREEN)) | |
| 505 SDL_WM_ToggleFullScreen (screen); | |
| 506 frames++; | |
| 507 /* | |
| 508 * Sometime we actualize the frame_length, because we let user | |
| 509 * choose maximum FPS dinamically. | |
| 510 */ | |
| 511 if (frames > options->fps) { | |
| 512 frames = 0; | |
| 513 frame_length = (1.0 / options->fps) * 1000; | |
| 514 } | |
| 515 } | |
| 516 | |
| 517 visual_stopped = 1; | |
| 518 return 0; | |
| 519 } | |
| 520 | |
| 521 static int sdl_event_handle () | |
| 522 { | |
| 523 SDL_Event event; | |
| 524 VisEventQueue *vevent; | |
| 525 const char *next_plugin; | |
| 526 | |
| 527 while (SDL_PollEvent (&event)) { | |
| 528 vevent = visual_plugin_get_eventqueue (visual_actor_get_plugin (visual_bin_get_actor (bin))); | |
| 529 | |
| 530 switch (event.type) { | |
| 531 case SDL_KEYUP: | |
| 532 visual_event_queue_add_keyboard (vevent, event.key.keysym.sym, event.key.keysym.mod, VISUAL_KEY_UP); | |
| 533 break; | |
| 534 | |
| 535 case SDL_KEYDOWN: | |
| 536 visual_event_queue_add_keyboard (vevent, event.key.keysym.sym, event.key.keysym.mod, VISUAL_KEY_DOWN); | |
| 537 | |
| 538 switch (event.key.keysym.sym) { | |
| 539 /* XMMS CONTROLS */ | |
| 540 case SDLK_UP: | |
| 541 xmms_remote_set_main_volume (lv_bmp_vp.xmms_session, | |
| 542 xmms_remote_get_main_volume (lv_bmp_vp.xmms_session) + 1); | |
| 543 break; | |
| 544 case SDLK_DOWN: | |
| 545 xmms_remote_set_main_volume (lv_bmp_vp.xmms_session, | |
| 546 xmms_remote_get_main_volume (lv_bmp_vp.xmms_session) - 1); | |
| 547 break; | |
| 548 case SDLK_LEFT: | |
| 549 if (xmms_remote_is_playing (lv_bmp_vp.xmms_session)) | |
| 550 xmms_remote_jump_to_time (lv_bmp_vp.xmms_session, | |
| 551 xmms_remote_get_output_time (lv_bmp_vp.xmms_session) - 5000); | |
| 552 break; | |
| 553 case SDLK_RIGHT: | |
| 554 if (xmms_remote_is_playing (lv_bmp_vp.xmms_session)) | |
| 555 xmms_remote_jump_to_time (lv_bmp_vp.xmms_session, | |
| 556 xmms_remote_get_output_time (lv_bmp_vp.xmms_session) + 5000); | |
| 557 break; | |
| 558 case SDLK_z: | |
| 559 xmms_remote_playlist_prev (lv_bmp_vp.xmms_session); | |
| 560 break; | |
| 561 | |
| 562 case SDLK_x: | |
| 563 xmms_remote_play (lv_bmp_vp.xmms_session); | |
| 564 break; | |
| 565 | |
| 566 case SDLK_c: | |
| 567 xmms_remote_pause (lv_bmp_vp.xmms_session); | |
| 568 break; | |
| 569 | |
| 570 case SDLK_v: | |
| 571 xmms_remote_stop (lv_bmp_vp.xmms_session); | |
| 572 break; | |
| 573 | |
| 574 case SDLK_b: | |
| 575 xmms_remote_playlist_next (lv_bmp_vp.xmms_session); | |
| 576 break; | |
| 577 | |
| 578 /* PLUGIN CONTROLS */ | |
| 579 case SDLK_F11: | |
| 580 case SDLK_TAB: | |
| 581 SDL_WM_ToggleFullScreen (screen); | |
| 582 lv_bmp_config_toggle_fullscreen(); | |
| 583 | |
| 584 if ((screen->flags & SDL_FULLSCREEN) > 0) | |
| 585 SDL_ShowCursor (SDL_DISABLE); | |
| 586 else | |
| 587 SDL_ShowCursor (SDL_ENABLE); | |
| 588 | |
| 589 break; | |
| 590 | |
| 591 case SDLK_a: | |
| 592 next_plugin = lv_bmp_config_get_prev_actor (); | |
| 593 | |
| 594 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 595 SDL_LockSurface (screen); | |
| 596 | |
| 597 if (next_plugin != NULL && (strcmp (next_plugin, cur_lv_plugin) != 0)) { | |
| 598 lv_bmp_config_set_current_actor (next_plugin); | |
| 599 cur_lv_plugin = next_plugin; | |
| 600 visual_bin_set_morph_by_name (bin, lv_bmp_config_morph_plugin()); | |
| 601 visual_bin_switch_actor_by_name (bin, cur_lv_plugin); | |
| 602 } | |
| 603 | |
| 604 SDL_WM_SetCaption (cur_lv_plugin, cur_lv_plugin); | |
| 605 | |
| 606 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 607 SDL_UnlockSurface (screen); | |
| 608 | |
| 609 break; | |
| 610 | |
| 611 case SDLK_s: | |
| 612 next_plugin = lv_bmp_config_get_next_actor (); | |
| 613 | |
| 614 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 615 SDL_LockSurface (screen); | |
| 616 | |
| 617 if (next_plugin != NULL && (strcmp (next_plugin, cur_lv_plugin) != 0)) { | |
| 618 lv_bmp_config_set_current_actor (next_plugin); | |
| 619 cur_lv_plugin = next_plugin; | |
| 620 visual_bin_set_morph_by_name (bin, lv_bmp_config_morph_plugin()); | |
| 621 visual_bin_switch_actor_by_name (bin, cur_lv_plugin); | |
| 622 } | |
| 623 | |
| 624 SDL_WM_SetCaption (cur_lv_plugin, cur_lv_plugin); | |
| 625 | |
| 626 if (SDL_MUSTLOCK (screen) == SDL_TRUE) | |
| 627 SDL_UnlockSurface (screen); | |
| 628 | |
| 629 break; | |
| 630 | |
| 631 default: /* to avoid warnings */ | |
| 632 break; | |
| 633 } | |
| 634 break; | |
| 635 | |
| 636 case SDL_VIDEORESIZE: | |
| 637 visual_resize (event.resize.w, event.resize.h); | |
| 638 break; | |
| 639 | |
| 640 case SDL_MOUSEMOTION: | |
| 641 visual_event_queue_add_mousemotion (vevent, event.motion.x, event.motion.y); | |
| 642 break; | |
| 643 | |
| 644 case SDL_MOUSEBUTTONDOWN: | |
| 645 visual_event_queue_add_mousebutton (vevent, event.button.button, VISUAL_MOUSE_DOWN, | |
| 646 event.button.x, event.button.y); | |
| 647 break; | |
| 648 | |
| 649 case SDL_MOUSEBUTTONUP: | |
| 650 visual_event_queue_add_mousebutton (vevent, event.button.button, VISUAL_MOUSE_UP, | |
| 651 event.button.x, event.button.y); | |
| 652 break; | |
| 653 | |
| 654 case SDL_QUIT: | |
| 655 GDK_THREADS_ENTER (); | |
| 656 gtk_idle_add (disable_func, NULL); | |
| 657 GDK_THREADS_LEAVE (); | |
| 658 break; | |
| 659 | |
| 660 default: /* to avoid warnings */ | |
| 661 break; | |
| 662 } | |
| 663 } | |
| 664 | |
| 665 return 0; | |
| 666 } | |
| 667 | |
| 668 static gint disable_func (gpointer data) | |
| 669 { | |
| 670 lv_bmp_vp.disable_plugin (&lv_bmp_vp); | |
| 671 | |
| 672 return FALSE; | |
| 673 } | |
| 674 | |
| 675 | |
| 676 static void dummy (GtkWidget *widget, gpointer data) | |
| 677 { | |
| 678 } | |
| 679 |
