annotate src/projectm-1.0/main.cxx @ 2246:f06b48381052

- drop protected: declarations, protected: is not needed here (and causes error on gcc4.3) - new screenshot code
author William Pitcock <nenolod@atheme.org>
date Mon, 17 Dec 2007 15:51:45 -0600
parents 0edf1cb262c0
children 822c887712dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
1 /*
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
2 * main.cxx: plugin glue to libprojectm
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
3 * Copyright (c) 2008 William Pitcock <nenolod@sacredspiral.co.uk>
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
4 * Portions copyright (c) 2004-2006 Peter Sperl
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
5 *
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
6 * This program is free software; you may distribute it under the terms
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
7 * of the GNU General Public License; version 2.
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
8 */
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
9
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
10 #include <stdio.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
11 #include <string.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
12 #include <string>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
13 #include <stdlib.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
14 #include <unistd.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
15 #include <fcntl.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
16 #include <SDL/SDL.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
17 #include <SDL/SDL_thread.h>
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
18
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
19 extern "C"
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
20 {
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
21 #include <audacious/util.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
22 #include <audacious/plugin.h>
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
23 #include <audacious/playlist.h>
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
24 #include <audacious/auddrct.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
25 }
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
26
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
27 #include <math.h>
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
28 #include "ConfigFile.h"
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
29
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
30 #include <libprojectM/projectM.hpp>
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
31
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
32 #include "sdltoprojectM.h"
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
33
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
34 #include <GL/gl.h>
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
35 #define CONFIG_FILE "/share/projectM/config.inp"
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
36
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
37 // Forward declarations
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
38 extern "C" void projectM_xmms_init(void);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
39 extern "C" void projectM_cleanup(void);
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
40 extern "C" void projectM_render_pcm(gint16 pcm_data[2][512]);
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
41 extern "C" int worker_func(void *);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
42 std::string read_config();
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
43
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
44 extern "C" VisPlugin projectM_vtable;
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
45
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
46 int SDLThreadWrapper(void *);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
47 void handle_playback_trigger(void *, void *);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
48
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
49 class projectMPlugin
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
50 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
51 private:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
52 projectM *pm;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
53
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
54 gint wvw, wvh, fvw, fvh;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
55 gboolean fullscreen;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
56 gboolean error;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
57
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
58 SDL_Event event;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
59 SDL_Surface *screen;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
60 SDL_Thread *worker_thread;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
61 SDL_sem *sem;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
62
2246
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
63 public:
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
64 projectMPlugin()
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
65 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
66 std::string configFile = read_config();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
67 ConfigFile config(configFile);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
68
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
69 this->wvw = config.read<int>("Window Width", 512);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
70 this->wvh = config.read<int>("Window Height", 512);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
71
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
72 this->fullscreen = FALSE;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
73 if (config.read("Fullscreen", true))
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
74 this->fullscreen = TRUE;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
75
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
76 /* initialise SDL */
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
77 if (SDL_Init(SDL_INIT_VIDEO) < 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
78 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
79 this->error++;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
80 return;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
81 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
82
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
83 SDL_WM_SetCaption("projectM", "audacious");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
84 SDL_EnableUNICODE(1);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
85
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
86 this->sem = SDL_CreateSemaphore(0);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
87
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
88 /* XXX */
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
89 aud_hook_associate("playback begin", handle_playback_trigger, NULL);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
90 }
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
91
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
92 ~projectMPlugin()
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
93 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
94 if (!this->sem)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
95 return;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
96
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
97 SDL_SemWait(this->sem);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
98
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
99 if (this->worker_thread)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
100 SDL_WaitThread(this->worker_thread, NULL);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
101
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
102 SDL_DestroySemaphore(this->sem);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
103 SDL_Quit();
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
104
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
105 this->sem = 0;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
106 this->worker_thread = 0;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
107
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
108 delete this->pm;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
109 this->pm = 0;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
110
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
111 aud_hook_dissociate("playback begin", handle_playback_trigger);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
112 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
113
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
114 int run(void *unused)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
115 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
116 if (error)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
117 return -1;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
118
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
119 std::string configFile = read_config();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
120 this->initDisplay(this->wvw, this->wvh, &this->fvw, &this->fvh, this->fullscreen);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
121 this->pm = new projectM(configFile);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
122 this->pm->projectM_resetGL(this->wvw, this->wvh);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
123
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
124 SDL_SemPost(this->sem);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
125
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
126 while (SDL_SemValue(this->sem) == 1)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
127 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
128 projectMEvent evt;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
129 projectMKeycode key;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
130 projectMModifier mod;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
131
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
132 SDL_Event event;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
133 while (SDL_PollEvent(&event))
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
134 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
135 evt = sdl2pmEvent(event);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
136
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
137 key = sdl2pmKeycode(event.key.keysym.sym);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
138 mod = sdl2pmModifier(event.key.keysym.mod);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
139
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
140 switch (evt)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
141 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
142 case PROJECTM_KEYDOWN:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
143 switch (key)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
144 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
145 case PROJECTM_K_c:
2246
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
146 this->takeScreenshot();
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
147 break;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
148
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
149 case PROJECTM_K_f:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
150 int w, h;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
151 if (fullscreen == 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
152 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
153 w = fvw;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
154 h = fvh;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
155 fullscreen = 1;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
156 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
157 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
158 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
159 w = wvw;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
160 h = wvh;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
161 fullscreen = 0;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
162 }
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
163
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
164 this->resizeDisplay(w, h, fullscreen);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
165 this->pm->projectM_resetGL(w, h);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
166
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
167 break;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
168
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
169 default:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
170 this->pm->key_handler(evt, key, mod);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
171 break;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
172 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
173
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
174 break;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
175
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
176 case PROJECTM_VIDEORESIZE:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
177 wvw = event.resize.w;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
178 wvh = event.resize.h;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
179 this->resizeDisplay(wvw, wvh, fullscreen);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
180 this->pm->projectM_resetGL(wvw, wvh);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
181
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
182 break;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
183
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
184 case PROJECTM_VIDEOQUIT:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
185 std::cerr << "XXX: PROJECTM_VIDEOQUIT is not implemented yet!" << std::endl;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
186 break;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
187
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
188 default:
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
189 break;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
190 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
191 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
192
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
193 this->pm->renderFrame();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
194
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
195 SDL_GL_SwapBuffers();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
196 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
197
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
198 return 0;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
199 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
200
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
201 void launchThread()
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
202 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
203 /* SDL sucks and won't let you use C++ functors... */
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
204 this->worker_thread = SDL_CreateThread(SDLThreadWrapper, NULL);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
205 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
206
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
207 void addPCMData(gint16 pcm_data[2][512])
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
208 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
209 if (SDL_SemValue(this->sem) == 1)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
210 this->pm->pcm->addPCM16(pcm_data);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
211 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
212
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
213 void initDisplay(gint width, gint height, gint *rwidth, gint *rheight, gboolean fullscreen)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
214 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
215 this->wvw = width;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
216 this->wvh = height;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
217 this->fvw = *rwidth;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
218 this->fvw = *rheight;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
219 this->fullscreen = fullscreen;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
220
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
221 const SDL_VideoInfo *info = NULL;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
222 int bpp;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
223 int flags;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
224
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
225 info = SDL_GetVideoInfo();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
226 if (!info)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
227 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
228 this->error++;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
229 return;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
230 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
231
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
232 /* initialize fullscreen resolution to something "sane" */
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
233 *rwidth = width;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
234 *rheight = height;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
235
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
236 bpp = info->vfmt->BitsPerPixel;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
237 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
238 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
239 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
240
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
241 if (this->fullscreen)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
242 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
243 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
244 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_RESIZABLE;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
246 this->screen = SDL_SetVideoMode(width, height, bpp, flags);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
247 if (!this->screen)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
248 this->error++;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
249 }
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
250
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
251 void resizeDisplay(gint width, gint height, gboolean fullscreen)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
252 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
253 this->fullscreen = fullscreen;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
254
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
255 int flags;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
256
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
257 if (this->fullscreen)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
258 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
259 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
260 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_RESIZABLE;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
261
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
262 this->screen = SDL_SetVideoMode(width, height, 0, flags);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
263 if (this->screen == 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
264 return;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
265
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
266 SDL_ShowCursor(this->fullscreen ? SDL_DISABLE : SDL_ENABLE);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
267 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
268
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
269 void triggerPlaybackBegin(PlaylistEntry *entry)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
270 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
271 std::string title(entry->title);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
272 this->pm->projectM_setTitle(title);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
273 }
2246
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
274
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
275 void takeScreenshot(void)
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
276 {
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
277 static int frame = 1;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
278
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
279 std::string dumpPath(g_get_home_dir());
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
280 dumpPath.append(".projectM/");
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
281
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
282 gchar *frame_ = g_strdup_printf("%.8d.bmp", frame);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
283
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
284 dumpPath.append(frame_);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
285
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
286 SDL_Surface *bitmap;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
287
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
288 GLint viewport[4];
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
289 long bytewidth;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
290 GLint width, height;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
291 long bytes;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
292
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
293 glReadBuffer(GL_FRONT);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
294 glGetIntegerv(GL_VIEWPORT, viewport);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
295
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
296 width = viewport[2];
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
297 height = viewport[3];
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
298
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
299 bytewidth = width * 4;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
300 bytewidth = (bytewidth + 3) & ~3;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
301 bytes = bytewidth * height;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
302
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
303 bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
304 glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bitmap->pixels);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
305
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
306 SDL_SaveBMP(bitmap, dumpPath.c_str());
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
307
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
308 SDL_FreeSurface(bitmap);
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
309
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
310 frame++;
f06b48381052 - drop protected: declarations, protected: is not needed here (and causes error on gcc4.3)
William Pitcock <nenolod@atheme.org>
parents: 2245
diff changeset
311 }
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
312 };
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
313
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
314 /* glue to implementation section */
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
315 projectMPlugin *thePlugin = 0;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
316
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
317 /* SDL sucks and won't let you use proper C++ functors. :( */
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
318 int SDLThreadWrapper(void *unused)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
319 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
320 return thePlugin->run(unused);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
321 }
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
322
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
323 void handle_playback_trigger(gpointer plentry_p, gpointer unused)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
324 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
325 PlaylistEntry *entry = reinterpret_cast<PlaylistEntry *>(plentry_p);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
326
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
327 if (!thePlugin)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
328 return;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
329
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
330 thePlugin->triggerPlaybackBegin(entry);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
331 }
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
332
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
333 extern "C" void projectM_xmms_init(void)
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
334 {
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
335 thePlugin = new projectMPlugin;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
336 thePlugin->launchThread();
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
337 }
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
338
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
339 extern "C" void projectM_cleanup(void)
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
340 {
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
341 if (!thePlugin)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
342 return;
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
343
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
344 delete thePlugin;
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
345 }
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
346
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
347 extern "C" void projectM_render_pcm(gint16 pcm_data[2][512])
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
348 {
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
349 if (!thePlugin)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
350 return;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
351
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
352 thePlugin->addPCMData(pcm_data);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
353 }
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
354
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
355 /********************************************************************************
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
356 * XXX: This code is from projectM and still needs to be rewritten! *
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
357 ********************************************************************************/
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
358 std::string read_config()
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
359 {
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
360
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
361 // int n;
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
362
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
363 char num[512];
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
364 FILE *in;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
365 FILE *out;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
366
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
367 char *home;
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
368 char projectM_home[1024];
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
369 char projectM_config[1024];
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
370
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
371 strcpy(projectM_config, PROJECTM_PREFIX);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
372 strcpy(projectM_config + strlen(PROJECTM_PREFIX), CONFIG_FILE);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
373 projectM_config[strlen(PROJECTM_PREFIX) + strlen(CONFIG_FILE)] = '\0';
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
374 //printf("dir:%s \n",projectM_config);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
375 home = getenv("HOME");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
376 strcpy(projectM_home, home);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
377 strcpy(projectM_home + strlen(home), "/.projectM/config.inp");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
378 projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0';
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
379
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
380
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
381 if ((in = fopen(projectM_home, "r")) != 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
382 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
383 //printf("reading ~/.projectM/config.inp \n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
384 fclose(in);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
385 return std::string(projectM_home);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
386 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
387 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
388 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
389 printf("trying to create ~/.projectM/config.inp \n");
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
390
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
391 strcpy(projectM_home, home);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
392 strcpy(projectM_home + strlen(home), "/.projectM");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
393 projectM_home[strlen(home) + strlen("/.projectM")] = '\0';
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
394 mkdir(projectM_home, 0755);
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
395
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
396 strcpy(projectM_home, home);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
397 strcpy(projectM_home + strlen(home), "/.projectM/config.inp");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
398 projectM_home[strlen(home) + strlen("/.projectM/config.inp")] = '\0';
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
399
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
400 if ((out = fopen(projectM_home, "w")) != 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
401 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
402
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
403 if ((in = fopen(projectM_config, "r")) != 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
404 {
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
405
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
406 while (fgets(num, 80, in) != NULL)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
407 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
408 fputs(num, out);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
409 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
410 fclose(in);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
411 fclose(out);
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
412
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
413
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
414 if ((in = fopen(projectM_home, "r")) != 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
415 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
416 printf("created ~/.projectM/config.inp successfully\n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
417 fclose(in);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
418 return std::string(projectM_home);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
419 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
420 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
421 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
422 printf("This shouldn't happen, using implementation defualts\n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
423 abort();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
424 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
425 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
426 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
427 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
428 printf("Cannot find projectM default config, using implementation defaults\n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
429 abort();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
430 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
431 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
432 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
433 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
434 printf("Cannot create ~/.projectM/config.inp, using default config file\n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
435 if ((in = fopen(projectM_config, "r")) != 0)
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
436 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
437 printf("Successfully opened default config file\n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
438 fclose(in);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
439 return std::string(projectM_config);
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
440 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
441 else
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
442 {
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
443 printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n");
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
444 abort();
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
445 }
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
446 }
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
447
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
448 }
1920
a6d84a2cfaa7 projectm-1.0: add the new files this time
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
diff changeset
449
2245
0edf1cb262c0 projectm-1.0: rewrite the plugin.
William Pitcock <nenolod@atheme.org>
parents: 2028
diff changeset
450 abort();
2028
47a4e93ed7ce projectm-1.0: update to http://projectm.svn.sourceforge.net/svnroot/projectm@567
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 1920
diff changeset
451 }