comparison src/adplug/adplug-xmms.cc @ 955:4709ce4e209e trunk

[svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
author chainsaw
date Sat, 14 Apr 2007 15:23:50 -0700
parents cae46214b8bf
children b1128efde471
comparison
equal deleted inserted replaced
954:d7a6fd179cd2 955:4709ce4e209e
33 #include "players.h" 33 #include "players.h"
34 #include "audacious/plugin.h" 34 #include "audacious/plugin.h"
35 #include "audacious/util.h" 35 #include "audacious/util.h"
36 #include "audacious/configdb.h" 36 #include "audacious/configdb.h"
37 #include <audacious/i18n.h> 37 #include <audacious/i18n.h>
38 extern "C" { 38 extern "C"
39 {
39 #include "audacious/output.h" 40 #include "audacious/output.h"
40 } 41 }
41 42
42 43
43 /***** Defines *****/ 44 /***** Defines *****/
58 // Default AdPlug user's configuration subdirectory 59 // Default AdPlug user's configuration subdirectory
59 #define ADPLUG_CONFDIR ".adplug" 60 #define ADPLUG_CONFDIR ".adplug"
60 61
61 /***** Global variables *****/ 62 /***** Global variables *****/
62 63
63 extern "C" InputPlugin adplug_ip; 64 extern "C" InputPlugin adplug_ip;
64 static gboolean audio_error = FALSE; 65 static gboolean audio_error = FALSE;
65 GtkWidget *about_win = NULL; 66 GtkWidget *about_win = NULL;
66 67
67 // Configuration (and defaults) 68 // Configuration (and defaults)
68 static struct { 69 static struct
69 gint freq; 70 {
70 gboolean bit16, stereo, endless; 71 gint freq;
71 CPlayers players; 72 gboolean bit16, stereo, endless;
72 } cfg = { 44100l, true, false, false, CAdPlug::players }; 73 CPlayers players;
74 } cfg =
75 {
76 44100l, true, false, false, CAdPlug::players};
73 77
74 // Player variables 78 // Player variables
75 static struct { 79 static struct
76 CPlayer *p; 80 {
77 CAdPlugDatabase *db; 81 CPlayer *p;
78 unsigned int subsong, songlength; 82 CAdPlugDatabase *db;
79 int seek; 83 unsigned int subsong, songlength;
80 char filename[PATH_MAX]; 84 int seek;
81 char *songtitle; 85 char filename[PATH_MAX];
82 float time_ms; 86 char *songtitle;
83 bool playing; 87 float time_ms;
84 GThread *play_thread; 88 bool playing;
85 GtkLabel *infobox; 89 GThread *play_thread;
86 GtkDialog *infodlg; 90 GtkLabel *infobox;
87 } plr = { 0, 0, 0, 0, -1, "", NULL, 0.0f, false, 0, NULL, NULL }; 91 GtkDialog *infodlg;
92 } plr =
93 {
94 0, 0, 0, 0, -1, "", NULL, 0.0f, false, 0, NULL, NULL};
88 95
89 static InputPlayback *playback; 96 static InputPlayback *playback;
90 97
91 // XXX: this function is not in the public API yet. 98 // XXX: this function is not in the public API yet.
92 extern "C" VFSFile *vfs_buffered_file_new_from_uri(gchar *uri); 99 extern "C" VFSFile * vfs_buffered_file_new_from_uri (gchar * uri);
93 100
94 /***** Debugging *****/ 101 /***** Debugging *****/
95 102
96 #ifdef DEBUG 103 #ifdef DEBUG
97 104
98 #include <stdarg.h> 105 #include <stdarg.h>
99 106
100 static void dbg_printf(const char *fmt, ...) 107 static void
108 dbg_printf (const char *fmt, ...)
101 { 109 {
102 va_list argptr; 110 va_list argptr;
103 111
104 va_start(argptr, fmt); 112 va_start (argptr, fmt);
105 vfprintf(stderr, fmt, argptr); 113 vfprintf (stderr, fmt, argptr);
106 va_end(argptr); 114 va_end (argptr);
107 } 115 }
108 116
109 #else 117 #else
110 118
111 static void dbg_printf(const char *fmt, ...) 119 static void
112 { } 120 dbg_printf (const char *fmt, ...)
121 {
122 }
113 123
114 #endif 124 #endif
115 125
116 /***** [Dialog]: Utility functions *****/ 126 /***** [Dialog]: Utility functions *****/
117 127
118 static GtkWidget *make_framed(GtkWidget *what, const gchar *label) 128 static GtkWidget *
119 { 129 make_framed (GtkWidget * what, const gchar * label)
120 GtkWidget *framebox = gtk_frame_new(label); 130 {
121 131 GtkWidget *framebox = gtk_frame_new (label);
122 gtk_container_add(GTK_CONTAINER(framebox), what); 132
133 gtk_container_add (GTK_CONTAINER (framebox), what);
123 return framebox; 134 return framebox;
124 } 135 }
125 136
126 static GtkWidget *print_left(const gchar *text) 137 static GtkWidget *
127 { 138 print_left (const gchar * text)
128 GtkLabel *label = GTK_LABEL(gtk_label_new(text)); 139 {
129 140 GtkLabel *label = GTK_LABEL (gtk_label_new (text));
130 gtk_label_set_justify(label, GTK_JUSTIFY_LEFT); 141
131 gtk_misc_set_padding(GTK_MISC(label), 2, 2); 142 gtk_label_set_justify (label, GTK_JUSTIFY_LEFT);
132 return GTK_WIDGET(label); 143 gtk_misc_set_padding (GTK_MISC (label), 2, 2);
133 } 144 return GTK_WIDGET (label);
134 145 }
135 static void MessageBox(const char *title, const char *text, const char *button) 146
136 { 147 static void
137 char *tmptitle = (char *)malloc(strlen(title) + 1), 148 MessageBox (const char *title, const char *text, const char *button)
138 *tmptxt = (char *)malloc(strlen(text) + 1), 149 {
139 *tmpbutton = (char *)malloc(strlen(button) + 1); 150 char *tmptitle = (char *) malloc (strlen (title) + 1),
140 151 *tmptxt = (char *) malloc (strlen (text) + 1),
141 strcpy(tmptitle, title); strcpy(tmptxt, text); strcpy(tmpbutton, button); 152 *tmpbutton = (char *) malloc (strlen (button) + 1);
142 153
143 GtkWidget *msgbox = xmms_show_message(tmptitle, tmptxt, tmpbutton, FALSE, 154 strcpy (tmptitle, title);
144 G_CALLBACK(gtk_widget_destroyed), &msgbox); 155 strcpy (tmptxt, text);
145 156 strcpy (tmpbutton, button);
146 free(tmptitle); free(tmptxt); free(tmpbutton); 157
158 GtkWidget *msgbox = xmms_show_message (tmptitle, tmptxt, tmpbutton, FALSE,
159 G_CALLBACK (gtk_widget_destroyed),
160 &msgbox);
161
162 free (tmptitle);
163 free (tmptxt);
164 free (tmpbutton);
147 } 165 }
148 166
149 /***** Dialog boxes *****/ 167 /***** Dialog boxes *****/
150 168
151 static void adplug_about(void) 169 static void
152 { 170 adplug_about (void)
153 if(!about_win) 171 {
154 { 172 if (!about_win)
155 gchar * about_title = g_strjoin( "" , _("About ") , ADPLUG_NAME , NULL ); 173 {
156 const gchar * version_text = CAdPlug::get_version().c_str(); 174 gchar *about_title = g_strjoin ("", _("About "), ADPLUG_NAME, NULL);
157 gchar * about_text = g_strjoin( "" , ADPLUG_NAME , 175 const gchar *version_text = CAdPlug::get_version ().c_str ();
158 _("\nCopyright (C) 2002, 2003 Simon Peter <dn.tlp@gmx.net>\n\n" 176 gchar *about_text = g_strjoin ("", ADPLUG_NAME,
159 "This plugin is released under the terms and conditions of the GNU LGPL.\n" 177 _
160 "See http://www.gnu.org/licenses/lgpl.html for details." 178 ("\nCopyright (C) 2002, 2003 Simon Peter <dn.tlp@gmx.net>\n\n"
161 "\n\nThis plugin uses the AdPlug library, which is copyright (C) Simon Peter, et al.\n" 179 "This plugin is released under the terms and conditions of the GNU LGPL.\n"
162 "Linked AdPlug library version: ") , 180 "See http://www.gnu.org/licenses/lgpl.html for details."
163 version_text , NULL ); 181 "\n\nThis plugin uses the AdPlug library, which is copyright (C) Simon Peter, et al.\n"
164 about_win = xmms_show_message( about_title , about_text , _("Ok") , FALSE , NULL , NULL ); 182 "Linked AdPlug library version: "),
165 g_signal_connect( G_OBJECT(about_win) , "destroy" , 183 version_text, NULL);
166 G_CALLBACK(gtk_widget_destroyed), &about_win ); 184 about_win =
167 g_free( about_text ); 185 xmms_show_message (about_title, about_text, _("Ok"), FALSE, NULL, NULL);
168 g_free( about_title ); 186 g_signal_connect (G_OBJECT (about_win), "destroy",
169 } 187 G_CALLBACK (gtk_widget_destroyed), &about_win);
170 gtk_widget_show( about_win ); 188 g_free (about_text);
171 } 189 g_free (about_title);
172 190 }
173 static void close_config_box_ok(GtkButton *button, GPtrArray *rblist) 191 gtk_widget_show (about_win);
192 }
193
194 static void
195 close_config_box_ok (GtkButton * button, GPtrArray * rblist)
174 { 196 {
175 // Apply configuration settings 197 // Apply configuration settings
176 cfg.bit16 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 0))); 198 cfg.bit16 =
177 cfg.stereo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 1))); 199 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
178 200 (g_ptr_array_index (rblist, 0)));
179 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 2)))) cfg.freq = 11025; 201 cfg.stereo =
180 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 3)))) cfg.freq = 22050; 202 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
181 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 4)))) cfg.freq = 44100; 203 (g_ptr_array_index (rblist, 1)));
182 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 5)))) cfg.freq = 48000; 204
183 205 if (gtk_toggle_button_get_active
184 cfg.endless = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_ptr_array_index(rblist, 6))); 206 (GTK_TOGGLE_BUTTON (g_ptr_array_index (rblist, 2))))
185 207 cfg.freq = 11025;
186 cfg.players = *(CPlayers *)g_ptr_array_index(rblist, 7); 208 if (gtk_toggle_button_get_active
187 delete (CPlayers *)g_ptr_array_index(rblist, 7); 209 (GTK_TOGGLE_BUTTON (g_ptr_array_index (rblist, 3))))
188 210 cfg.freq = 22050;
189 g_ptr_array_free(rblist, FALSE); 211 if (gtk_toggle_button_get_active
190 } 212 (GTK_TOGGLE_BUTTON (g_ptr_array_index (rblist, 4))))
191 213 cfg.freq = 44100;
192 static void close_config_box_cancel(GtkButton *button, GPtrArray *rblist) 214 if (gtk_toggle_button_get_active
193 { 215 (GTK_TOGGLE_BUTTON (g_ptr_array_index (rblist, 5))))
194 delete (CPlayers *)g_ptr_array_index(rblist, 7); 216 cfg.freq = 48000;
195 g_ptr_array_free(rblist, FALSE); 217
196 } 218 cfg.endless =
197 219 !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
198 static void config_fl_row_select(GtkCList *fl, gint row, gint col, 220 (g_ptr_array_index (rblist, 6)));
199 GdkEventButton *event, CPlayers *pl) 221
200 { 222 cfg.players = *(CPlayers *) g_ptr_array_index (rblist, 7);
201 pl->push_back((CPlayerDesc *)gtk_clist_get_row_data(fl, row)); 223 delete (CPlayers *) g_ptr_array_index (rblist, 7);
202 pl->unique(); 224
203 } 225 g_ptr_array_free (rblist, FALSE);
204 226 }
205 static void config_fl_row_unselect(GtkCList *fl, gint row, gint col, 227
206 GdkEventButton *event, CPlayers *pl) 228 static void
207 { 229 close_config_box_cancel (GtkButton * button, GPtrArray * rblist)
208 pl->remove((CPlayerDesc *)gtk_clist_get_row_data(fl, row)); 230 {
209 } 231 delete (CPlayers *) g_ptr_array_index (rblist, 7);
210 232 g_ptr_array_free (rblist, FALSE);
211 static void adplug_config(void) 233 }
212 { 234
213 GtkDialog *config_dlg = GTK_DIALOG(gtk_dialog_new()); 235 static void
214 GtkNotebook *notebook = GTK_NOTEBOOK(gtk_notebook_new()); 236 config_fl_row_select (GtkCList * fl, gint row, gint col,
237 GdkEventButton * event, CPlayers * pl)
238 {
239 pl->push_back ((CPlayerDesc *) gtk_clist_get_row_data (fl, row));
240 pl->unique ();
241 }
242
243 static void
244 config_fl_row_unselect (GtkCList * fl, gint row, gint col,
245 GdkEventButton * event, CPlayers * pl)
246 {
247 pl->remove ((CPlayerDesc *) gtk_clist_get_row_data (fl, row));
248 }
249
250 static void
251 adplug_config (void)
252 {
253 GtkDialog *config_dlg = GTK_DIALOG (gtk_dialog_new ());
254 GtkNotebook *notebook = GTK_NOTEBOOK (gtk_notebook_new ());
215 GtkTable *table; 255 GtkTable *table;
216 GtkTooltips *tooltips = gtk_tooltips_new(); 256 GtkTooltips *tooltips = gtk_tooltips_new ();
217 GPtrArray *rblist = g_ptr_array_new(); 257 GPtrArray *rblist = g_ptr_array_new ();
218 258
219 gtk_window_set_title(GTK_WINDOW(config_dlg), "AdPlug :: Configuration"); 259 gtk_window_set_title (GTK_WINDOW (config_dlg), "AdPlug :: Configuration");
220 gtk_window_set_policy(GTK_WINDOW(config_dlg), FALSE, FALSE, TRUE); // Window is auto sized 260 gtk_window_set_policy (GTK_WINDOW (config_dlg), FALSE, FALSE, TRUE); // Window is auto sized
221 gtk_window_set_modal(GTK_WINDOW(config_dlg), TRUE); 261 gtk_window_set_modal (GTK_WINDOW (config_dlg), TRUE);
222 gtk_container_add(GTK_CONTAINER(config_dlg->vbox), GTK_WIDGET(notebook)); 262 gtk_container_add (GTK_CONTAINER (config_dlg->vbox), GTK_WIDGET (notebook));
223 263
224 // Add Ok & Cancel buttons 264 // Add Ok & Cancel buttons
225 { 265 {
226 GtkWidget *button; 266 GtkWidget *button;
227 267
228 button = gtk_button_new_with_label("Ok"); 268 button = gtk_button_new_with_label ("Ok");
229 g_signal_connect(G_OBJECT(button), "clicked", 269 g_signal_connect (G_OBJECT (button), "clicked",
230 G_CALLBACK(close_config_box_ok), 270 G_CALLBACK (close_config_box_ok), (gpointer) rblist);
231 (gpointer)rblist); 271 g_signal_connect_data (G_OBJECT (button), "clicked",
232 g_signal_connect_data(G_OBJECT(button), "clicked", 272 G_CALLBACK (gtk_widget_destroy),
233 G_CALLBACK(gtk_widget_destroy), 273 GTK_OBJECT (config_dlg), NULL,
234 GTK_OBJECT(config_dlg),NULL,(GConnectFlags) (G_CONNECT_AFTER|G_CONNECT_SWAPPED)); 274 (GConnectFlags) (G_CONNECT_AFTER |
235 gtk_container_add(GTK_CONTAINER(config_dlg->action_area), button); 275 G_CONNECT_SWAPPED));
236 276 gtk_container_add (GTK_CONTAINER (config_dlg->action_area), button);
237 button = gtk_button_new_with_label("Cancel"); 277
238 g_signal_connect(G_OBJECT(button), "clicked", 278 button = gtk_button_new_with_label ("Cancel");
239 G_CALLBACK(close_config_box_cancel), 279 g_signal_connect (G_OBJECT (button), "clicked",
240 (gpointer)rblist); 280 G_CALLBACK (close_config_box_cancel),
241 g_signal_connect_swapped(G_OBJECT(button), "clicked", 281 (gpointer) rblist);
242 G_CALLBACK(gtk_widget_destroy), 282 g_signal_connect_swapped (G_OBJECT (button), "clicked",
243 GTK_OBJECT(config_dlg)); 283 G_CALLBACK (gtk_widget_destroy),
244 gtk_container_add(GTK_CONTAINER(config_dlg->action_area), button); 284 GTK_OBJECT (config_dlg));
285 gtk_container_add (GTK_CONTAINER (config_dlg->action_area), button);
245 } 286 }
246 287
247 /***** Page 1: General *****/ 288 /***** Page 1: General *****/
248 289
249 table = GTK_TABLE(gtk_table_new(1, 2, TRUE)); 290 table = GTK_TABLE (gtk_table_new (1, 2, TRUE));
250 gtk_table_set_row_spacings(table, 5); gtk_table_set_col_spacings(table, 5); 291 gtk_table_set_row_spacings (table, 5);
251 gtk_notebook_append_page(notebook, GTK_WIDGET(table), print_left("General")); 292 gtk_table_set_col_spacings (table, 5);
293 gtk_notebook_append_page (notebook, GTK_WIDGET (table),
294 print_left ("General"));
252 295
253 // Add "Sound quality" section 296 // Add "Sound quality" section
254 { 297 {
255 GtkTable *sqt = GTK_TABLE(gtk_table_new(2, 2, FALSE)); 298 GtkTable *sqt = GTK_TABLE (gtk_table_new (2, 2, FALSE));
256 GtkVBox *fvb; 299 GtkVBox *fvb;
257 GtkRadioButton *rb; 300 GtkRadioButton *rb;
258 301
259 gtk_table_set_row_spacings(sqt, 5); 302 gtk_table_set_row_spacings (sqt, 5);
260 gtk_table_set_col_spacings(sqt, 5); 303 gtk_table_set_col_spacings (sqt, 5);
261 gtk_table_attach_defaults(table, make_framed(GTK_WIDGET(sqt), "Sound quality"), 304 gtk_table_attach_defaults (table,
262 0, 1, 0, 1); 305 make_framed (GTK_WIDGET (sqt),
306 "Sound quality"), 0, 1, 0, 1);
263 307
264 // Add "Resolution" section 308 // Add "Resolution" section
265 fvb = GTK_VBOX(gtk_vbox_new(TRUE, 0)); 309 fvb = GTK_VBOX (gtk_vbox_new (TRUE, 0));
266 gtk_table_attach_defaults(sqt, make_framed(GTK_WIDGET(fvb), "Resolution"), 310 gtk_table_attach_defaults (sqt,
267 0, 1, 0, 1); 311 make_framed (GTK_WIDGET (fvb), "Resolution"),
268 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(NULL, "8bit")); 312 0, 1, 0, 1);
269 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), !cfg.bit16); 313 rb = GTK_RADIO_BUTTON (gtk_radio_button_new_with_label (NULL, "8bit"));
270 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 314 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), !cfg.bit16);
271 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label_from_widget(rb, "16bit")); 315 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
272 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), cfg.bit16); 316 rb =
273 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 317 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label_from_widget
274 g_ptr_array_add(rblist, (gpointer)rb); 318 (rb, "16bit"));
319 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), cfg.bit16);
320 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
321 g_ptr_array_add (rblist, (gpointer) rb);
275 322
276 // Add "Channels" section 323 // Add "Channels" section
277 fvb = GTK_VBOX(gtk_vbox_new(TRUE, 0)); 324 fvb = GTK_VBOX (gtk_vbox_new (TRUE, 0));
278 gtk_table_attach_defaults(sqt, make_framed(GTK_WIDGET(fvb), "Channels"), 325 gtk_table_attach_defaults (sqt,
279 0, 1, 1, 2); 326 make_framed (GTK_WIDGET (fvb), "Channels"), 0,
280 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(NULL, "Mono")); 327 1, 1, 2);
281 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), !cfg.stereo); 328 rb = GTK_RADIO_BUTTON (gtk_radio_button_new_with_label (NULL, "Mono"));
282 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 329 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), !cfg.stereo);
283 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label_from_widget(rb, "Stereo")); 330 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
284 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), cfg.stereo); 331 rb =
285 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 332 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label_from_widget
286 gtk_tooltips_set_tip(tooltips, GTK_WIDGET(rb), 333 (rb, "Stereo"));
287 "Setting stereo is not recommended, unless you need to. " 334 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), cfg.stereo);
288 "This won't add any stereo effects to the sound - OPL2 " 335 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
289 "is just mono - but eats up more CPU power!", NULL); 336 gtk_tooltips_set_tip (tooltips, GTK_WIDGET (rb),
290 g_ptr_array_add(rblist, (gpointer)rb); 337 "Setting stereo is not recommended, unless you need to. "
338 "This won't add any stereo effects to the sound - OPL2 "
339 "is just mono - but eats up more CPU power!", NULL);
340 g_ptr_array_add (rblist, (gpointer) rb);
291 341
292 // Add "Frequency" section 342 // Add "Frequency" section
293 fvb = GTK_VBOX(gtk_vbox_new(TRUE, 0)); 343 fvb = GTK_VBOX (gtk_vbox_new (TRUE, 0));
294 gtk_table_attach_defaults(sqt, make_framed(GTK_WIDGET(fvb), "Frequency"), 344 gtk_table_attach_defaults (sqt,
295 1, 2, 0, 2); 345 make_framed (GTK_WIDGET (fvb), "Frequency"), 1,
296 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label(NULL, "11025")); 346 2, 0, 2);
297 if(cfg.freq == 11025) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), TRUE); 347 rb = GTK_RADIO_BUTTON (gtk_radio_button_new_with_label (NULL, "11025"));
298 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 348 if (cfg.freq == 11025)
299 g_ptr_array_add(rblist, (gpointer)rb); 349 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), TRUE);
300 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label_from_widget(rb, "22050")); 350 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
301 if(cfg.freq == 22050) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), TRUE); 351 g_ptr_array_add (rblist, (gpointer) rb);
302 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 352 rb =
303 g_ptr_array_add(rblist, (gpointer)rb); 353 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label_from_widget
304 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label_from_widget(rb, "44100")); 354 (rb, "22050"));
305 if(cfg.freq == 44100) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), TRUE); 355 if (cfg.freq == 22050)
306 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 356 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), TRUE);
307 g_ptr_array_add(rblist, (gpointer)rb); 357 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
308 rb = GTK_RADIO_BUTTON(gtk_radio_button_new_with_label_from_widget(rb, "48000")); 358 g_ptr_array_add (rblist, (gpointer) rb);
309 if(cfg.freq == 48000) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rb), TRUE); 359 rb =
310 gtk_container_add(GTK_CONTAINER(fvb), GTK_WIDGET(rb)); 360 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label_from_widget
311 g_ptr_array_add(rblist, (gpointer)rb); 361 (rb, "44100"));
362 if (cfg.freq == 44100)
363 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), TRUE);
364 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
365 g_ptr_array_add (rblist, (gpointer) rb);
366 rb =
367 GTK_RADIO_BUTTON (gtk_radio_button_new_with_label_from_widget
368 (rb, "48000"));
369 if (cfg.freq == 48000)
370 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rb), TRUE);
371 gtk_container_add (GTK_CONTAINER (fvb), GTK_WIDGET (rb));
372 g_ptr_array_add (rblist, (gpointer) rb);
312 } 373 }
313 374
314 // Add "Playback" section 375 // Add "Playback" section
315 { 376 {
316 GtkVBox *vb = GTK_VBOX(gtk_vbox_new(FALSE, 0)); 377 GtkVBox *vb = GTK_VBOX (gtk_vbox_new (FALSE, 0));
317 GtkCheckButton *cb; 378 GtkCheckButton *cb;
318 379
319 gtk_table_attach_defaults(table, make_framed(GTK_WIDGET(vb), "Playback"), 380 gtk_table_attach_defaults (table,
320 1, 2, 0, 1); 381 make_framed (GTK_WIDGET (vb), "Playback"), 1,
321 382 2, 0, 1);
322 cb = GTK_CHECK_BUTTON(gtk_check_button_new_with_label("Detect songend")); 383
323 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb), !cfg.endless); 384 cb =
324 gtk_container_add(GTK_CONTAINER(vb), GTK_WIDGET(cb)); 385 GTK_CHECK_BUTTON (gtk_check_button_new_with_label ("Detect songend"));
325 gtk_tooltips_set_tip(tooltips, GTK_WIDGET(cb), 386 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), !cfg.endless);
326 "If enabled, XMMS will detect a song's ending, stop " 387 gtk_container_add (GTK_CONTAINER (vb), GTK_WIDGET (cb));
327 "it and advance in the playlist. If disabled, XMMS " 388 gtk_tooltips_set_tip (tooltips, GTK_WIDGET (cb),
328 "won't take notice of a song's ending and loop it all " 389 "If enabled, XMMS will detect a song's ending, stop "
329 "over again and again.", NULL); 390 "it and advance in the playlist. If disabled, XMMS "
330 g_ptr_array_add(rblist, (gpointer)cb); 391 "won't take notice of a song's ending and loop it all "
392 "over again and again.", NULL);
393 g_ptr_array_add (rblist, (gpointer) cb);
331 } 394 }
332 395
333 /***** Page 2: Formats *****/ 396 /***** Page 2: Formats *****/
334 397
335 table = GTK_TABLE(gtk_table_new(1, 1, TRUE)); 398 table = GTK_TABLE (gtk_table_new (1, 1, TRUE));
336 gtk_notebook_append_page(notebook, GTK_WIDGET(table), print_left("Formats")); 399 gtk_notebook_append_page (notebook, GTK_WIDGET (table),
400 print_left ("Formats"));
337 401
338 // Add "Format selection" section 402 // Add "Format selection" section
339 { 403 {
340 GtkHBox *vb = GTK_HBOX(gtk_hbox_new(FALSE, 0)); 404 GtkHBox *vb = GTK_HBOX (gtk_hbox_new (FALSE, 0));
341 gtk_table_attach_defaults(table, make_framed(GTK_WIDGET(vb), "Format selection"), 405 gtk_table_attach_defaults (table,
342 0, 1, 0, 1); 406 make_framed (GTK_WIDGET (vb),
407 "Format selection"), 0, 1, 0, 1);
343 // Add scrollable list 408 // Add scrollable list
344 { 409 {
345 gchar *rowstr[] = {"Format", "Extension"}; 410 gchar *rowstr[] = { "Format", "Extension" };
346 GtkEventBox *eventbox = GTK_EVENT_BOX(gtk_event_box_new()); 411 GtkEventBox *eventbox = GTK_EVENT_BOX (gtk_event_box_new ());
347 GtkScrolledWindow *formatswnd = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); 412 GtkScrolledWindow *formatswnd =
348 GtkCList *fl = GTK_CLIST(gtk_clist_new_with_titles(2, rowstr)); 413 GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
414 GtkCList *fl = GTK_CLIST (gtk_clist_new_with_titles (2, rowstr));
349 CPlayers::const_iterator i; 415 CPlayers::const_iterator i;
350 unsigned int j; 416 unsigned int j;
351 gtk_clist_set_selection_mode(fl, GTK_SELECTION_MULTIPLE); 417 gtk_clist_set_selection_mode (fl, GTK_SELECTION_MULTIPLE);
352 418
353 // Build list 419 // Build list
354 for(i = CAdPlug::players.begin(); i != CAdPlug::players.end(); i++) { 420 for (i = CAdPlug::players.begin (); i != CAdPlug::players.end (); i++)
355 gint rownum; 421 {
356 422 gint rownum;
357 gchar *rws[2]; 423
358 rws[0] = g_strdup((*i)->filetype.c_str()); 424 gchar *rws[2];
359 rws[1] = g_strdup((*i)->get_extension(0)); 425 rws[0] = g_strdup ((*i)->filetype.c_str ());
360 for(j = 1; (*i)->get_extension(j); j++) 426 rws[1] = g_strdup ((*i)->get_extension (0));
361 rws[1] = g_strjoin(", ", rws[1], (*i)->get_extension(j), NULL); 427 for (j = 1; (*i)->get_extension (j); j++)
362 rownum = gtk_clist_append(fl, rws); 428 rws[1] = g_strjoin (", ", rws[1], (*i)->get_extension (j), NULL);
363 g_free(rws[0]); g_free(rws[1]); 429 rownum = gtk_clist_append (fl, rws);
364 gtk_clist_set_row_data(fl, rownum, (gpointer)(*i)); 430 g_free (rws[0]);
365 if(find(cfg.players.begin(), cfg.players.end(), *i) != cfg.players.end()) 431 g_free (rws[1]);
366 gtk_clist_select_row(fl, rownum, 0); 432 gtk_clist_set_row_data (fl, rownum, (gpointer) (*i));
433 if (find (cfg.players.begin (), cfg.players.end (), *i) !=
434 cfg.players.end ())
435 gtk_clist_select_row (fl, rownum, 0);
367 } 436 }
368 437
369 gtk_clist_columns_autosize(fl); 438 gtk_clist_columns_autosize (fl);
370 gtk_scrolled_window_set_policy(formatswnd, GTK_POLICY_AUTOMATIC, 439 gtk_scrolled_window_set_policy (formatswnd, GTK_POLICY_AUTOMATIC,
371 GTK_POLICY_AUTOMATIC); 440 GTK_POLICY_AUTOMATIC);
372 gpointer pl = (gpointer)new CPlayers(cfg.players); 441 gpointer pl = (gpointer) new CPlayers (cfg.players);
373 g_signal_connect(G_OBJECT(fl), "select-row", 442 g_signal_connect (G_OBJECT (fl), "select-row",
374 G_CALLBACK(config_fl_row_select), pl); 443 G_CALLBACK (config_fl_row_select), pl);
375 g_signal_connect(G_OBJECT(fl), "unselect-row", 444 g_signal_connect (G_OBJECT (fl), "unselect-row",
376 G_CALLBACK(config_fl_row_unselect), pl); 445 G_CALLBACK (config_fl_row_unselect), pl);
377 gtk_container_add(GTK_CONTAINER(formatswnd), GTK_WIDGET(fl)); 446 gtk_container_add (GTK_CONTAINER (formatswnd), GTK_WIDGET (fl));
378 gtk_container_add(GTK_CONTAINER(eventbox), GTK_WIDGET(formatswnd)); 447 gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (formatswnd));
379 gtk_container_add(GTK_CONTAINER(vb), GTK_WIDGET(eventbox)); 448 gtk_container_add (GTK_CONTAINER (vb), GTK_WIDGET (eventbox));
380 gtk_tooltips_set_tip(tooltips, GTK_WIDGET(eventbox), 449 gtk_tooltips_set_tip (tooltips, GTK_WIDGET (eventbox),
381 "Selected file types will be recognized and played " 450 "Selected file types will be recognized and played "
382 "back by this plugin. Deselected types will be " 451 "back by this plugin. Deselected types will be "
383 "ignored to make room for other plugins to play " 452 "ignored to make room for other plugins to play "
384 "these files.", NULL); 453 "these files.", NULL);
385 g_ptr_array_add(rblist, pl); 454 g_ptr_array_add (rblist, pl);
386 } 455 }
387 } 456 }
388 457
389 // Show window 458 // Show window
390 gtk_widget_show_all(GTK_WIDGET(config_dlg)); 459 gtk_widget_show_all (GTK_WIDGET (config_dlg));
391 } 460 }
392 461
393 static void add_instlist(GtkCList *instlist, const char *t1, const char *t2) 462 static void
463 add_instlist (GtkCList * instlist, const char *t1, const char *t2)
394 { 464 {
395 gchar *rowstr[2]; 465 gchar *rowstr[2];
396 466
397 rowstr[0] = g_strdup(t1); rowstr[1] = g_strdup(t2); 467 rowstr[0] = g_strdup (t1);
398 gtk_clist_append(instlist, rowstr); 468 rowstr[1] = g_strdup (t2);
399 g_free(rowstr[0]); g_free(rowstr[1]); 469 gtk_clist_append (instlist, rowstr);
400 } 470 g_free (rowstr[0]);
401 471 g_free (rowstr[1]);
402 static CPlayer *factory(VFSFile *fd, Copl *newopl) 472 }
403 { 473
404 CPlayers::const_iterator i; 474 static CPlayer *
405 475 factory (VFSFile * fd, Copl * newopl)
406 dbg_printf("factory(%p<%s>,opl): ", fd, fd->uri != NULL ? fd->uri : "unknown"); 476 {
407 return CAdPlug::factory(fd, newopl, cfg.players); 477 CPlayers::const_iterator i;
408 } 478
409 479 dbg_printf ("factory(%p<%s>,opl): ", fd,
410 static void adplug_stop(InputPlayback *data); 480 fd->uri != NULL ? fd->uri : "unknown");
411 static void adplug_play(InputPlayback *data); 481 return CAdPlug::factory (fd, newopl, cfg.players);
412 482 }
413 483
414 484 static void adplug_stop (InputPlayback * data);
415 static void subsong_slider(GtkAdjustment *adj) 485 static void adplug_play (InputPlayback * data);
416 { 486
417 adplug_stop(NULL); 487
418 plr.subsong = (unsigned int)adj->value - 1; 488
419 adplug_play(playback); 489 static void
420 } 490 subsong_slider (GtkAdjustment * adj)
421 491 {
422 static void close_infobox(GtkDialog *infodlg) 492 adplug_stop (NULL);
493 plr.subsong = (unsigned int) adj->value - 1;
494 adplug_play (playback);
495 }
496
497 static void
498 close_infobox (GtkDialog * infodlg)
423 { 499 {
424 // Forget our references to the instance of the "currently playing song" info 500 // Forget our references to the instance of the "currently playing song" info
425 // box. But only if we're really destroying that one... ;) 501 // box. But only if we're really destroying that one... ;)
426 if(infodlg == plr.infodlg) { 502 if (infodlg == plr.infodlg)
503 {
427 plr.infobox = NULL; 504 plr.infobox = NULL;
428 plr.infodlg = NULL; 505 plr.infodlg = NULL;
429 } 506 }
430 } 507 }
431 508
432 static void adplug_info_box(char *filename) 509 static void
510 adplug_info_box (char *filename)
433 { 511 {
434 CSilentopl tmpopl; 512 CSilentopl tmpopl;
435 VFSFile *fd = vfs_buffered_file_new_from_uri(filename); 513 VFSFile *fd = vfs_buffered_file_new_from_uri (filename);
436 514
437 if (!fd) return; 515 if (!fd)
438 516 return;
439 CPlayer *p = (strcmp(filename, plr.filename) || !plr.p) ? 517
440 factory(fd, &tmpopl) : plr.p; 518 CPlayer *p = (strcmp (filename, plr.filename) || !plr.p) ?
441 519 factory (fd, &tmpopl) : plr.p;
442 if(!p) return; // bail out if no player could be created 520
443 if(p == plr.p && plr.infodlg) return; // only one info box for active song 521 if (!p)
522 return; // bail out if no player could be created
523 if (p == plr.p && plr.infodlg)
524 return; // only one info box for active song
444 525
445 std::ostringstream infotext; 526 std::ostringstream infotext;
446 unsigned int i; 527 unsigned int i;
447 GtkDialog *infobox = GTK_DIALOG(gtk_dialog_new()); 528 GtkDialog *infobox = GTK_DIALOG (gtk_dialog_new ());
448 GtkButton *okay_button = GTK_BUTTON(gtk_button_new_with_label("Ok")); 529 GtkButton *okay_button = GTK_BUTTON (gtk_button_new_with_label ("Ok"));
449 530
450 GtkVBox *box = GTK_VBOX(gtk_vbox_new(TRUE,2)); 531 GtkVBox *box = GTK_VBOX (gtk_vbox_new (TRUE, 2));
451 GtkHBox *hbox = GTK_HBOX(gtk_hbox_new(TRUE, 2)); 532 GtkHBox *hbox = GTK_HBOX (gtk_hbox_new (TRUE, 2));
452 GtkHBox *hbox2 = GTK_HBOX(gtk_hbox_new(TRUE, 2)); 533 GtkHBox *hbox2 = GTK_HBOX (gtk_hbox_new (TRUE, 2));
453 534
454 // Build file info box 535 // Build file info box
455 gtk_window_set_title(GTK_WINDOW(infobox), "AdPlug :: File Info"); 536 gtk_window_set_title (GTK_WINDOW (infobox), "AdPlug :: File Info");
456 gtk_window_set_policy(GTK_WINDOW(infobox), FALSE, FALSE, TRUE); // Window is auto sized 537 gtk_window_set_policy (GTK_WINDOW (infobox), FALSE, FALSE, TRUE); // Window is auto sized
457 538
458 gtk_container_add(GTK_CONTAINER(infobox->vbox), GTK_WIDGET(box)); 539 gtk_container_add (GTK_CONTAINER (infobox->vbox), GTK_WIDGET (box));
459 // Former packer layout, for future reproduction 540 // Former packer layout, for future reproduction
460 // gtk_packer_set_default_border_width(packer, 2); 541 // gtk_packer_set_default_border_width(packer, 2);
461 542
462 gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE); 543 gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
463 g_signal_connect_swapped(G_OBJECT(okay_button), "clicked", 544 g_signal_connect_swapped (G_OBJECT (okay_button), "clicked",
464 G_CALLBACK(gtk_widget_destroy), 545 G_CALLBACK (gtk_widget_destroy),
465 GTK_OBJECT(infobox)); 546 GTK_OBJECT (infobox));
466 g_signal_connect(G_OBJECT(infobox), "destroy", 547 g_signal_connect (G_OBJECT (infobox), "destroy",
467 G_CALLBACK(close_infobox), 0); 548 G_CALLBACK (close_infobox), 0);
468 gtk_container_add(GTK_CONTAINER(infobox->action_area), GTK_WIDGET(okay_button)); 549 gtk_container_add (GTK_CONTAINER (infobox->action_area),
550 GTK_WIDGET (okay_button));
469 551
470 // Add filename section 552 // Add filename section
471 // Former packer layout, for future reproduction 553 // Former packer layout, for future reproduction
472 // gtk_packer_add_defaults(packer, make_framed(print_left(filename), "Filename"), 554 // gtk_packer_add_defaults(packer, make_framed(print_left(filename), "Filename"),
473 // GTK_SIDE_TOP, GTK_ANCHOR_CENTER, GTK_FILL_X); 555 // GTK_SIDE_TOP, GTK_ANCHOR_CENTER, GTK_FILL_X);
474 gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(hbox2), TRUE, TRUE, 2); 556 gtk_box_pack_end (GTK_BOX (box), GTK_WIDGET (hbox2), TRUE, TRUE, 2);
475 gtk_box_pack_end(GTK_BOX(box), make_framed(print_left(filename), "Filename"), TRUE, TRUE, 2); 557 gtk_box_pack_end (GTK_BOX (box),
558 make_framed (print_left (filename), "Filename"), TRUE,
559 TRUE, 2);
476 560
477 // Add "Song info" section 561 // Add "Song info" section
478 infotext << "Title: " << p->gettitle() << std::endl << 562 infotext << "Title: " << p->gettitle () << std::endl <<
479 "Author: " << p->getauthor() << std::endl << 563 "Author: " << p->getauthor () << std::endl <<
480 "File Type: " << p->gettype() << std::endl << 564 "File Type: " << p->gettype () << std::endl <<
481 "Subsongs: " << p->getsubsongs() << std::endl << 565 "Subsongs: " << p->getsubsongs () << std::endl <<
482 "Instruments: " << p->getinstruments(); 566 "Instruments: " << p->getinstruments ();
483 if(plr.p == p) 567 if (plr.p == p)
484 infotext << std::ends; 568 infotext << std::ends;
485 else { 569 else
486 infotext << std::endl << "Orders: " << p->getorders() << std::endl << 570 {
487 "Patterns: " << p->getpatterns() << std::ends; 571 infotext << std::endl << "Orders: " << p->getorders () << std::endl <<
488 } 572 "Patterns: " << p->getpatterns () << std::ends;
489 gtk_container_add(GTK_CONTAINER(hbox), 573 }
490 make_framed(print_left(infotext.str().c_str()), "Song")); 574 gtk_container_add (GTK_CONTAINER (hbox),
575 make_framed (print_left (infotext.str ().c_str ()),
576 "Song"));
491 577
492 // Add "Playback info" section if currently playing 578 // Add "Playback info" section if currently playing
493 if(plr.p == p) { 579 if (plr.p == p)
494 plr.infobox = GTK_LABEL(gtk_label_new("")); 580 {
495 gtk_label_set_justify(plr.infobox, GTK_JUSTIFY_LEFT); 581 plr.infobox = GTK_LABEL (gtk_label_new (""));
496 gtk_misc_set_padding(GTK_MISC(plr.infobox), 2, 2); 582 gtk_label_set_justify (plr.infobox, GTK_JUSTIFY_LEFT);
497 gtk_container_add(GTK_CONTAINER(hbox), 583 gtk_misc_set_padding (GTK_MISC (plr.infobox), 2, 2);
498 make_framed(GTK_WIDGET(plr.infobox), "Playback")); 584 gtk_container_add (GTK_CONTAINER (hbox),
585 make_framed (GTK_WIDGET (plr.infobox), "Playback"));
499 } 586 }
500 587
501 // Former packer layout, for future reproduction 588 // Former packer layout, for future reproduction
502 // gtk_packer_add_defaults(packer, GTK_WIDGET(hbox), GTK_SIDE_TOP, 589 // gtk_packer_add_defaults(packer, GTK_WIDGET(hbox), GTK_SIDE_TOP,
503 // GTK_ANCHOR_CENTER, GTK_FILL_X); 590 // GTK_ANCHOR_CENTER, GTK_FILL_X);
504 gtk_box_pack_end(GTK_BOX(hbox2), GTK_WIDGET(hbox), TRUE, TRUE, 2); 591 gtk_box_pack_end (GTK_BOX (hbox2), GTK_WIDGET (hbox), TRUE, TRUE, 2);
505 592
506 // Add instrument names section 593 // Add instrument names section
507 if(p->getinstruments()) { 594 if (p->getinstruments ())
508 GtkScrolledWindow *instwnd = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); 595 {
596 GtkScrolledWindow *instwnd =
597 GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
509 GtkCList *instnames; 598 GtkCList *instnames;
510 gchar tmpstr[10]; 599 gchar tmpstr[10];
511 600
512 { 601 {
513 gchar *rowstr[] = {"#","Instrument name"}; 602 gchar *rowstr[] = { "#", "Instrument name" };
514 instnames = GTK_CLIST(gtk_clist_new_with_titles(2, rowstr)); 603 instnames = GTK_CLIST (gtk_clist_new_with_titles (2, rowstr));
515 } 604 }
516 gtk_clist_set_column_justification(instnames, 0, GTK_JUSTIFY_RIGHT); 605 gtk_clist_set_column_justification (instnames, 0, GTK_JUSTIFY_RIGHT);
517 606
518 for(i=0;i<p->getinstruments();i++) { 607 for (i = 0; i < p->getinstruments (); i++)
519 sprintf(tmpstr, "%d", i + 1); 608 {
520 add_instlist(instnames, tmpstr, p->getinstrument(i).c_str()); 609 sprintf (tmpstr, "%d", i + 1);
610 add_instlist (instnames, tmpstr, p->getinstrument (i).c_str ());
521 } 611 }
522 612
523 gtk_clist_columns_autosize(instnames); 613 gtk_clist_columns_autosize (instnames);
524 gtk_scrolled_window_set_policy(instwnd, GTK_POLICY_AUTOMATIC, 614 gtk_scrolled_window_set_policy (instwnd, GTK_POLICY_AUTOMATIC,
525 GTK_POLICY_AUTOMATIC); 615 GTK_POLICY_AUTOMATIC);
526 gtk_container_add(GTK_CONTAINER(instwnd), GTK_WIDGET(instnames)); 616 gtk_container_add (GTK_CONTAINER (instwnd), GTK_WIDGET (instnames));
527 // Former packer layout, for future reproduction 617 // Former packer layout, for future reproduction
528 // gtk_packer_add(packer, GTK_WIDGET(instwnd), GTK_SIDE_TOP, 618 // gtk_packer_add(packer, GTK_WIDGET(instwnd), GTK_SIDE_TOP,
529 // GTK_ANCHOR_CENTER, GTK_FILL_X, 0, 0, 0, 0, 50); 619 // GTK_ANCHOR_CENTER, GTK_FILL_X, 0, 0, 0, 0, 50);
530 gtk_box_pack_end(GTK_BOX(hbox2), GTK_WIDGET(instwnd), TRUE, TRUE, 2); 620 gtk_box_pack_end (GTK_BOX (hbox2), GTK_WIDGET (instwnd), TRUE, TRUE, 2);
531 } 621 }
532 622
533 // Add "Song message" section 623 // Add "Song message" section
534 if(!p->getdesc().empty()) { 624 if (!p->getdesc ().empty ())
535 GtkScrolledWindow *msgwnd = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); 625 {
536 GtkTextView *msg = GTK_TEXT_VIEW(gtk_text_view_new()); 626 GtkScrolledWindow *msgwnd =
537 627 GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL));
538 gtk_scrolled_window_set_policy(msgwnd, GTK_POLICY_AUTOMATIC, 628 GtkTextView *msg = GTK_TEXT_VIEW (gtk_text_view_new ());
539 GTK_POLICY_AUTOMATIC); 629
540 gtk_text_view_set_editable(msg, FALSE); 630 gtk_scrolled_window_set_policy (msgwnd, GTK_POLICY_AUTOMATIC,
541 gtk_text_view_set_wrap_mode(msg, GTK_WRAP_WORD_CHAR); 631 GTK_POLICY_AUTOMATIC);
542 632 gtk_text_view_set_editable (msg, FALSE);
543 gtk_text_buffer_set_text(gtk_text_view_get_buffer(msg),p->getdesc().c_str(),p->getdesc().length()); 633 gtk_text_view_set_wrap_mode (msg, GTK_WRAP_WORD_CHAR);
544 gtk_container_add(GTK_CONTAINER(msgwnd), GTK_WIDGET(msg)); 634
545 635 gtk_text_buffer_set_text (gtk_text_view_get_buffer (msg),
636 p->getdesc ().c_str (),
637 p->getdesc ().length ());
638 gtk_container_add (GTK_CONTAINER (msgwnd), GTK_WIDGET (msg));
639
546 // Former packer layout, for future reproduction 640 // Former packer layout, for future reproduction
547 // gtk_packer_add(packer, make_framed(GTK_WIDGET(msgwnd), "Song message"), 641 // gtk_packer_add(packer, make_framed(GTK_WIDGET(msgwnd), "Song message"),
548 // GTK_SIDE_TOP, GTK_ANCHOR_CENTER, GTK_FILL_X, 2, 0, 0, 200, 50); 642 // GTK_SIDE_TOP, GTK_ANCHOR_CENTER, GTK_FILL_X, 2, 0, 0, 200, 50);
549 gtk_box_pack_end(GTK_BOX(hbox2), make_framed(GTK_WIDGET(msgwnd), "Song message"), TRUE, TRUE, 2); 643 gtk_box_pack_end (GTK_BOX (hbox2),
644 make_framed (GTK_WIDGET (msgwnd), "Song message"), TRUE,
645 TRUE, 2);
550 } 646 }
551 647
552 // Add subsong slider section 648 // Add subsong slider section
553 if(p == plr.p && p->getsubsongs() > 1) { 649 if (p == plr.p && p->getsubsongs () > 1)
554 GtkAdjustment *adj = GTK_ADJUSTMENT(gtk_adjustment_new(plr.subsong + 1, 1, 650 {
555 p->getsubsongs() + 1, 651 GtkAdjustment *adj =
556 1, 5, 1)); 652 GTK_ADJUSTMENT (gtk_adjustment_new (plr.subsong + 1, 1,
557 GtkHScale *slider = GTK_HSCALE(gtk_hscale_new(adj)); 653 p->getsubsongs () + 1,
558 654 1, 5, 1));
559 g_signal_connect(G_OBJECT(adj), "value_changed", 655 GtkHScale *slider = GTK_HSCALE (gtk_hscale_new (adj));
560 G_CALLBACK(subsong_slider), NULL); 656
561 gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DISCONTINUOUS); 657 g_signal_connect (G_OBJECT (adj), "value_changed",
562 gtk_scale_set_digits(GTK_SCALE(slider), 0); 658 G_CALLBACK (subsong_slider), NULL);
659 gtk_range_set_update_policy (GTK_RANGE (slider),
660 GTK_UPDATE_DISCONTINUOUS);
661 gtk_scale_set_digits (GTK_SCALE (slider), 0);
563 // Former packer layout, for future reproduction 662 // Former packer layout, for future reproduction
564 // gtk_packer_add_defaults(packer, make_framed(GTK_WIDGET(slider), "Subsong selection"), 663 // gtk_packer_add_defaults(packer, make_framed(GTK_WIDGET(slider), "Subsong selection"),
565 // GTK_SIDE_TOP, GTK_ANCHOR_CENTER, GTK_FILL_X); 664 // GTK_SIDE_TOP, GTK_ANCHOR_CENTER, GTK_FILL_X);
566 gtk_box_pack_end(GTK_BOX(hbox2), make_framed(GTK_WIDGET(slider), "Subsong selection"), TRUE, TRUE, 2); 665 gtk_box_pack_end (GTK_BOX (hbox2),
666 make_framed (GTK_WIDGET (slider), "Subsong selection"),
667 TRUE, TRUE, 2);
567 } 668 }
568 669
569 // Show dialog box 670 // Show dialog box
570 gtk_widget_show_all(GTK_WIDGET(infobox)); 671 gtk_widget_show_all (GTK_WIDGET (infobox));
571 if(p == plr.p) { // Remember widget, so we could destroy it later 672 if (p == plr.p)
673 { // Remember widget, so we could destroy it later
572 plr.infodlg = infobox; 674 plr.infodlg = infobox;
573 } else // Delete temporary player 675 }
676 else // Delete temporary player
574 delete p; 677 delete p;
575 } 678 }
576 679
577 /***** Main player (!! threaded !!) *****/ 680 /***** Main player (!! threaded !!) *****/
578 681
579 static void update_infobox(void) 682 static void
683 update_infobox (void)
580 { 684 {
581 std::ostringstream infotext; 685 std::ostringstream infotext;
582 686
583 // Recreate info string 687 // Recreate info string
584 infotext << "Order: " << plr.p->getorder() << " / " << plr.p->getorders() << 688 infotext << "Order: " << plr.p->getorder () << " / " << plr.p->
585 std::endl << "Pattern: " << plr.p->getpattern() << " / " << 689 getorders () << std::endl << "Pattern: " << plr.p->
586 plr.p->getpatterns() << std::endl << "Row: " << plr.p->getrow() << 690 getpattern () << " / " << plr.p->
587 std::endl << "Speed: " << plr.p->getspeed() << std::endl << "Timer: " << 691 getpatterns () << std::endl << "Row: " << plr.p->
588 plr.p->getrefresh() << "Hz" << std::ends; 692 getrow () << std::endl << "Speed: " << plr.p->
589 693 getspeed () << std::endl << "Timer: " << plr.p->
590 GDK_THREADS_ENTER(); 694 getrefresh () << "Hz" << std::ends;
591 gtk_label_set_text(plr.infobox, infotext.str().c_str()); 695
592 GDK_THREADS_LEAVE(); 696 GDK_THREADS_ENTER ();
697 gtk_label_set_text (plr.infobox, infotext.str ().c_str ());
698 GDK_THREADS_LEAVE ();
593 } 699 }
594 700
595 // Define sampsize macro (only usable inside play_loop()!) 701 // Define sampsize macro (only usable inside play_loop()!)
596 #define sampsize ((bit16 ? 2 : 1) * (stereo ? 2 : 1)) 702 #define sampsize ((bit16 ? 2 : 1) * (stereo ? 2 : 1))
597 703
598 static void *play_loop(void *data) 704 static void *
705 play_loop (void *data)
599 /* Main playback thread. Takes the filename to play as argument. */ 706 /* Main playback thread. Takes the filename to play as argument. */
600 { 707 {
601 InputPlayback *playback = (InputPlayback *) data; 708 InputPlayback *playback = (InputPlayback *) data;
602 char *filename = (char *) playback->filename; 709 char *filename = (char *) playback->filename;
603 dbg_printf("play_loop(\"%s\"): ", filename); 710 dbg_printf ("play_loop(\"%s\"): ", filename);
604 CEmuopl opl(cfg.freq, cfg.bit16, cfg.stereo); 711 CEmuopl opl (cfg.freq, cfg.bit16, cfg.stereo);
605 long toadd = 0, i, towrite; 712 long toadd = 0, i, towrite;
606 char *sndbuf, *sndbufpos; 713 char *sndbuf, *sndbufpos;
607 bool playing = true, // Song self-end indicator. 714 bool playing = true, // Song self-end indicator.
608 bit16 = cfg.bit16, // Duplicate config, so it doesn't affect us if 715 bit16 = cfg.bit16, // Duplicate config, so it doesn't affect us if
609 stereo = cfg.stereo; // the user changes it while we're playing. 716 stereo = cfg.stereo; // the user changes it while we're playing.
610 unsigned long freq = cfg.freq; 717 unsigned long freq = cfg.freq;
611 718
612 // we use VfsBufferedFile class here because adplug does a lot of 719 // we use VfsBufferedFile class here because adplug does a lot of
613 // probing. a short delay before probing begins is better than 720 // probing. a short delay before probing begins is better than
614 // a lot of delay during probing. 721 // a lot of delay during probing.
615 VFSFile *fd = vfs_buffered_file_new_from_uri(playback->filename); 722 VFSFile *fd = vfs_buffered_file_new_from_uri (playback->filename);
616 723
617 if (!fd) { plr.playing = false; g_thread_exit(NULL); } 724 if (!fd)
725 {
726 plr.playing = false;
727 g_thread_exit (NULL);
728 }
618 729
619 // Try to load module 730 // Try to load module
620 dbg_printf("factory, "); 731 dbg_printf ("factory, ");
621 if(!(plr.p = factory(fd, &opl))) { 732 if (!(plr.p = factory (fd, &opl)))
622 dbg_printf("error!\n"); 733 {
623 // MessageBox("AdPlug :: Error", "File could not be opened!", "Ok"); 734 dbg_printf ("error!\n");
735 // MessageBox("AdPlug :: Error", "File could not be opened!", "Ok");
624 plr.playing = false; 736 plr.playing = false;
625 g_thread_exit(NULL); 737 g_thread_exit (NULL);
626 } 738 }
627 739
628 // Cache song length 740 // Cache song length
629 dbg_printf("length, "); 741 dbg_printf ("length, ");
630 plr.songlength = plr.p->songlength(plr.subsong); 742 plr.songlength = plr.p->songlength (plr.subsong);
631 743
632 // cache song title 744 // cache song title
633 dbg_printf("title, "); 745 dbg_printf ("title, ");
634 if(!plr.p->gettitle().empty()) { 746 if (!plr.p->gettitle ().empty ())
635 plr.songtitle = (char *)malloc(plr.p->gettitle().length() + 1); 747 {
636 strcpy(plr.songtitle, plr.p->gettitle().c_str()); 748 plr.songtitle = (char *) malloc (plr.p->gettitle ().length () + 1);
749 strcpy (plr.songtitle, plr.p->gettitle ().c_str ());
637 } 750 }
638 751
639 // reset to first subsong on new file 752 // reset to first subsong on new file
640 dbg_printf("subsong, "); 753 dbg_printf ("subsong, ");
641 if(strcmp(filename, plr.filename)) { 754 if (strcmp (filename, plr.filename))
642 strcpy(plr.filename, filename); 755 {
756 strcpy (plr.filename, filename);
643 plr.subsong = 0; 757 plr.subsong = 0;
644 } 758 }
645 759
646 // Allocate audio buffer 760 // Allocate audio buffer
647 dbg_printf("buffer, "); 761 dbg_printf ("buffer, ");
648 sndbuf = (char *)malloc(SNDBUFSIZE * sampsize); 762 sndbuf = (char *) malloc (SNDBUFSIZE * sampsize);
649 763
650 // Set XMMS main window information 764 // Set XMMS main window information
651 dbg_printf("xmms, "); 765 dbg_printf ("xmms, ");
652 adplug_ip.set_info(plr.songtitle, plr.songlength, freq * sampsize * 8, 766 adplug_ip.set_info (plr.songtitle, plr.songlength, freq * sampsize * 8,
653 freq, stereo ? 2 : 1); 767 freq, stereo ? 2 : 1);
654 768
655 // Rewind player to right subsong 769 // Rewind player to right subsong
656 dbg_printf("rewind, "); 770 dbg_printf ("rewind, ");
657 plr.p->rewind(plr.subsong); 771 plr.p->rewind (plr.subsong);
658 772
659 // main playback loop 773 // main playback loop
660 dbg_printf("loop.\n"); 774 dbg_printf ("loop.\n");
661 while((playing || cfg.endless) && plr.playing) { 775 while ((playing || cfg.endless) && plr.playing)
776 {
662 // seek requested ? 777 // seek requested ?
663 if(plr.seek != -1) { 778 if (plr.seek != -1)
779 {
664 // backward seek ? 780 // backward seek ?
665 if(plr.seek < plr.time_ms) { 781 if (plr.seek < plr.time_ms)
666 plr.p->rewind(plr.subsong); 782 {
783 plr.p->rewind (plr.subsong);
667 plr.time_ms = 0.0f; 784 plr.time_ms = 0.0f;
668 } 785 }
669 786
670 // seek to requested position 787 // seek to requested position
671 while((plr.time_ms < plr.seek) && plr.p->update()) 788 while ((plr.time_ms < plr.seek) && plr.p->update ())
672 plr.time_ms += 1000 / plr.p->getrefresh(); 789 plr.time_ms += 1000 / plr.p->getrefresh ();
673 790
674 // Reset output plugin and some values 791 // Reset output plugin and some values
675 playback->output->flush((int)plr.time_ms); 792 playback->output->flush ((int) plr.time_ms);
676 plr.seek = -1; 793 plr.seek = -1;
677 } 794 }
678 795
679 // fill sound buffer 796 // fill sound buffer
680 towrite = SNDBUFSIZE; sndbufpos = sndbuf; 797 towrite = SNDBUFSIZE;
681 while (towrite > 0) { 798 sndbufpos = sndbuf;
682 while (toadd < 0) { 799 while (towrite > 0)
800 {
801 while (toadd < 0)
802 {
683 toadd += freq; 803 toadd += freq;
684 playing = plr.p->update(); 804 playing = plr.p->update ();
685 plr.time_ms += 1000 / plr.p->getrefresh(); 805 plr.time_ms += 1000 / plr.p->getrefresh ();
686 } 806 }
687 i = MIN(towrite, (long)(toadd / plr.p->getrefresh() + 4) & ~3); 807 i = MIN (towrite, (long) (toadd / plr.p->getrefresh () + 4) & ~3);
688 opl.update((short *)sndbufpos, i); 808 opl.update ((short *) sndbufpos, i);
689 sndbufpos += i * sampsize; towrite -= i; 809 sndbufpos += i * sampsize;
690 toadd -= (long)(plr.p->getrefresh() * i); 810 towrite -= i;
811 toadd -= (long) (plr.p->getrefresh () * i);
691 } 812 }
692 813
693 // write sound buffer 814 // write sound buffer
694 while(playback->output->buffer_free() < SNDBUFSIZE * sampsize) xmms_usleep(10000); 815 while (playback->output->buffer_free () < SNDBUFSIZE * sampsize)
695 produce_audio(playback->output->written_time(), 816 xmms_usleep (10000);
696 bit16 ? FORMAT_16 : FORMAT_8, 817 produce_audio (playback->output->written_time (),
697 stereo ? 2 : 1, SNDBUFSIZE * sampsize, sndbuf, NULL); 818 bit16 ? FORMAT_16 : FORMAT_8,
819 stereo ? 2 : 1, SNDBUFSIZE * sampsize, sndbuf, NULL);
698 820
699 // update infobox, if necessary 821 // update infobox, if necessary
700 if(plr.infobox && plr.playing) update_infobox(); 822 if (plr.infobox && plr.playing)
823 update_infobox ();
701 } 824 }
702 825
703 // playback finished - deinit 826 // playback finished - deinit
704 dbg_printf("play_loop(\"%s\"): ", filename); 827 dbg_printf ("play_loop(\"%s\"): ", filename);
705 if(!playing) { // wait for output plugin to finish if song has self-ended 828 if (!playing)
706 dbg_printf("wait, "); 829 { // wait for output plugin to finish if song has self-ended
707 while(playback->output->buffer_playing()) xmms_usleep(10000); 830 dbg_printf ("wait, ");
708 } else { // or else, flush its output buffers 831 while (playback->output->buffer_playing ())
709 dbg_printf("flush, "); 832 xmms_usleep (10000);
710 playback->output->buffer_free(); playback->output->buffer_free(); 833 }
834 else
835 { // or else, flush its output buffers
836 dbg_printf ("flush, ");
837 playback->output->buffer_free ();
838 playback->output->buffer_free ();
711 } 839 }
712 840
713 // free everything and exit 841 // free everything and exit
714 dbg_printf("free"); 842 dbg_printf ("free");
715 delete plr.p; plr.p = 0; 843 delete plr.p;
716 if(plr.songtitle) { free(plr.songtitle); plr.songtitle = NULL; } 844 plr.p = 0;
717 free(sndbuf); 845 if (plr.songtitle)
718 plr.playing = false; // important! XMMS won't get a self-ended song without it. 846 {
719 dbg_printf(".\n"); 847 free (plr.songtitle);
720 vfs_fclose(fd); 848 plr.songtitle = NULL;
721 g_thread_exit(NULL); 849 }
722 return(NULL); 850 free (sndbuf);
851 plr.playing = false; // important! XMMS won't get a self-ended song without it.
852 dbg_printf (".\n");
853 vfs_fclose (fd);
854 g_thread_exit (NULL);
855 return (NULL);
723 } 856 }
724 857
725 // sampsize macro not useful anymore. 858 // sampsize macro not useful anymore.
726 #undef sampsize 859 #undef sampsize
727 860
728 /***** Informational *****/ 861 /***** Informational *****/
729 862
730 static int adplug_is_our_fd(gchar *filename, VFSFile *fd) 863 static int
864 adplug_is_our_fd (gchar * filename, VFSFile * fd)
731 { 865 {
732 CSilentopl tmpopl; 866 CSilentopl tmpopl;
733 867
734 CPlayer *p = factory(fd,&tmpopl); 868 CPlayer *p = factory (fd, &tmpopl);
735 869
736 dbg_printf("adplug_is_our_file(\"%s\"): returned ",filename); 870 dbg_printf ("adplug_is_our_file(\"%s\"): returned ", filename);
737 871
738 if(p) { 872 if (p)
873 {
739 delete p; 874 delete p;
740 dbg_printf("TRUE\n"); 875 dbg_printf ("TRUE\n");
741 return TRUE; 876 return TRUE;
742 } 877 }
743 878
744 dbg_printf("FALSE\n"); 879 dbg_printf ("FALSE\n");
745 return FALSE; 880 return FALSE;
746 } 881 }
747 882
748 static int adplug_is_our_file(char *filename) 883 static int
884 adplug_is_our_file (char *filename)
749 { 885 {
750 CSilentopl tmpopl; 886 CSilentopl tmpopl;
751 VFSFile *fd = vfs_buffered_file_new_from_uri(filename); if (!fd) return FALSE; 887 VFSFile *fd = vfs_buffered_file_new_from_uri (filename);
752 888 if (!fd)
753 CPlayer *p = factory(fd,&tmpopl); 889 return FALSE;
754 890
755 dbg_printf("adplug_is_our_file(\"%s\"): returned ",filename); 891 CPlayer *p = factory (fd, &tmpopl);
756 892
757 if(p) { 893 dbg_printf ("adplug_is_our_file(\"%s\"): returned ", filename);
894
895 if (p)
896 {
758 delete p; 897 delete p;
759 dbg_printf("TRUE\n"); 898 dbg_printf ("TRUE\n");
760 return TRUE; 899 return TRUE;
761 } 900 }
762 901
763 dbg_printf("FALSE\n"); 902 dbg_printf ("FALSE\n");
764 return FALSE; 903 return FALSE;
765 } 904 }
766 905
767 static int adplug_get_time(InputPlayback *data) 906 static int
768 { 907 adplug_get_time (InputPlayback * data)
769 if(audio_error) { dbg_printf("adplug_get_time(): returned -2\n"); return -2; } 908 {
770 if(!plr.playing) { dbg_printf("adplug_get_time(): returned -1\n"); return -1; } 909 if (audio_error)
771 return playback->output->output_time(); 910 {
772 } 911 dbg_printf ("adplug_get_time(): returned -2\n");
773 912 return -2;
774 static void adplug_song_info(char *filename, char **title, int *length) 913 }
914 if (!plr.playing)
915 {
916 dbg_printf ("adplug_get_time(): returned -1\n");
917 return -1;
918 }
919 return playback->output->output_time ();
920 }
921
922 static void
923 adplug_song_info (char *filename, char **title, int *length)
775 { 924 {
776 CSilentopl tmpopl; 925 CSilentopl tmpopl;
777 VFSFile *fd = vfs_buffered_file_new_from_uri(filename); 926 VFSFile *fd = vfs_buffered_file_new_from_uri (filename);
778 927
779 if (!fd) return; 928 if (!fd)
780 929 return;
781 CPlayer *p = factory(fd, &tmpopl); 930
782 931 CPlayer *p = factory (fd, &tmpopl);
783 dbg_printf("adplug_song_info(\"%s\", \"%s\", %d): ", filename, *title, *length); 932
784 933 dbg_printf ("adplug_song_info(\"%s\", \"%s\", %d): ", filename, *title,
785 if(p) { 934 *length);
935
936 if (p)
937 {
786 // allocate and set title string 938 // allocate and set title string
787 if(p->gettitle().empty()) 939 if (p->gettitle ().empty ())
788 *title = 0; 940 *title = 0;
789 else { 941 else
790 *title = (char *)malloc(p->gettitle().length() + 1); 942 {
791 strcpy(*title, p->gettitle().c_str()); 943 *title = (char *) malloc (p->gettitle ().length () + 1);
944 strcpy (*title, p->gettitle ().c_str ());
792 } 945 }
793 946
794 // get song length 947 // get song length
795 *length = p->songlength(plr.subsong); 948 *length = p->songlength (plr.subsong);
796 949
797 // delete temporary player object 950 // delete temporary player object
798 delete p; 951 delete p;
799 } 952 }
800 953
801 dbg_printf("title = \"%s\", length = %d\n", *title, *length); 954 dbg_printf ("title = \"%s\", length = %d\n", *title, *length);
802 } 955 }
803 956
804 /***** Player control *****/ 957 /***** Player control *****/
805 958
806 static void adplug_play(InputPlayback *data) 959 static void
960 adplug_play (InputPlayback * data)
807 { 961 {
808 char *filename = data->filename; 962 char *filename = data->filename;
809 playback = data; 963 playback = data;
810 dbg_printf("adplug_play(\"%s\"): ", filename); 964 dbg_printf ("adplug_play(\"%s\"): ", filename);
811 audio_error = FALSE; 965 audio_error = FALSE;
812 966
813 // On new song, re-open "Song info" dialog, if open 967 // On new song, re-open "Song info" dialog, if open
814 dbg_printf("dialog, "); 968 dbg_printf ("dialog, ");
815 if(plr.infobox && strcmp(filename, plr.filename)) 969 if (plr.infobox && strcmp (filename, plr.filename))
816 gtk_widget_destroy(GTK_WIDGET(plr.infodlg)); 970 gtk_widget_destroy (GTK_WIDGET (plr.infodlg));
817 971
818 // open output plugin 972 // open output plugin
819 dbg_printf("open, "); 973 dbg_printf ("open, ");
820 if (!playback->output->open_audio(cfg.bit16 ? FORMAT_16 : FORMAT_8, cfg.freq, cfg.stereo ? 2 : 1)) { 974 if (!playback->output->
975 open_audio (cfg.bit16 ? FORMAT_16 : FORMAT_8, cfg.freq,
976 cfg.stereo ? 2 : 1))
977 {
821 audio_error = TRUE; 978 audio_error = TRUE;
822 return; 979 return;
823 } 980 }
824 981
825 // Initialize global player data (this is here to prevent a race condition 982 // Initialize global player data (this is here to prevent a race condition
826 // between adplug_get_time() returning the playback state and adplug_loop() 983 // between adplug_get_time() returning the playback state and adplug_loop()
827 // initializing the playback state) 984 // initializing the playback state)
828 dbg_printf("init, "); 985 dbg_printf ("init, ");
829 plr.playing = true; plr.time_ms = 0.0f; plr.seek = -1; 986 plr.playing = true;
987 plr.time_ms = 0.0f;
988 plr.seek = -1;
830 989
831 // start player thread 990 // start player thread
832 dbg_printf("create"); 991 dbg_printf ("create");
833 plr.play_thread = g_thread_create(play_loop, playback, TRUE, NULL); 992 plr.play_thread = g_thread_create (play_loop, playback, TRUE, NULL);
834 dbg_printf(".\n"); 993 dbg_printf (".\n");
835 } 994 }
836 995
837 static void adplug_stop(InputPlayback * playback) 996 static void
838 { 997 adplug_stop (InputPlayback * playback)
839 dbg_printf("adplug_stop(): join, "); 998 {
840 plr.playing = false; g_thread_join(plr.play_thread); // stop player thread 999 dbg_printf ("adplug_stop(): join, ");
841 dbg_printf("close"); playback->output->close_audio(); 1000 plr.playing = false;
842 dbg_printf(".\n"); 1001 g_thread_join (plr.play_thread); // stop player thread
843 } 1002 dbg_printf ("close");
844 1003 playback->output->close_audio ();
845 static void adplug_pause(InputPlayback * playback, short paused) 1004 dbg_printf (".\n");
846 { 1005 }
847 dbg_printf("adplug_pause(%d)\n", paused); 1006
848 playback->output->pause(paused); 1007 static void
849 } 1008 adplug_pause (InputPlayback * playback, short paused)
850 1009 {
851 static void adplug_seek(InputPlayback * data, int time) 1010 dbg_printf ("adplug_pause(%d)\n", paused);
852 { 1011 playback->output->pause (paused);
853 dbg_printf("adplug_seek(%d)\n", time); 1012 }
854 plr.seek = time * 1000; // time is in seconds, but we count in ms 1013
1014 static void
1015 adplug_seek (InputPlayback * data, int time)
1016 {
1017 dbg_printf ("adplug_seek(%d)\n", time);
1018 plr.seek = time * 1000; // time is in seconds, but we count in ms
855 } 1019 }
856 1020
857 /***** Configuration file handling *****/ 1021 /***** Configuration file handling *****/
858 1022
859 #define CFG_VERSION "AdPlug" 1023 #define CFG_VERSION "AdPlug"
860 1024
861 static void adplug_init(void) 1025 static void
862 { 1026 adplug_init (void)
863 dbg_printf("adplug_init(): open, "); 1027 {
864 ConfigDb *db = bmp_cfg_db_open(); 1028 dbg_printf ("adplug_init(): open, ");
1029 ConfigDb *db = bmp_cfg_db_open ();
865 1030
866 // Read configuration 1031 // Read configuration
867 dbg_printf("read, "); 1032 dbg_printf ("read, ");
868 bmp_cfg_db_get_bool(db, CFG_VERSION, "16bit", (gboolean *)&cfg.bit16); 1033 bmp_cfg_db_get_bool (db, CFG_VERSION, "16bit", (gboolean *) & cfg.bit16);
869 bmp_cfg_db_get_bool(db, CFG_VERSION, "Stereo", (gboolean *)&cfg.stereo); 1034 bmp_cfg_db_get_bool (db, CFG_VERSION, "Stereo", (gboolean *) & cfg.stereo);
870 bmp_cfg_db_get_int(db, CFG_VERSION, "Frequency", (gint *)&cfg.freq); 1035 bmp_cfg_db_get_int (db, CFG_VERSION, "Frequency", (gint *) & cfg.freq);
871 bmp_cfg_db_get_bool(db, CFG_VERSION, "Endless", (gboolean *)&cfg.endless); 1036 bmp_cfg_db_get_bool (db, CFG_VERSION, "Endless",
1037 (gboolean *) & cfg.endless);
872 1038
873 // Read file type exclusion list 1039 // Read file type exclusion list
874 dbg_printf("exclusion, "); 1040 dbg_printf ("exclusion, ");
875 { 1041 {
876 gchar *cfgstr = "", *exclude; 1042 gchar *cfgstr = "", *exclude;
877 gboolean cfgread; 1043 gboolean cfgread;
878 1044
879 cfgread = bmp_cfg_db_get_string(db, CFG_VERSION, "Exclude", &cfgstr); 1045 cfgread = bmp_cfg_db_get_string (db, CFG_VERSION, "Exclude", &cfgstr);
880 exclude = (char *)malloc(strlen(cfgstr) + 2); strcpy(exclude, cfgstr); 1046 exclude = (char *) malloc (strlen (cfgstr) + 2);
881 exclude[strlen(exclude) + 1] = '\0'; 1047 strcpy (exclude, cfgstr);
882 if(cfgread) free(cfgstr); 1048 exclude[strlen (exclude) + 1] = '\0';
883 g_strdelimit(exclude, ":", '\0'); 1049 if (cfgread)
884 for(gchar *p = exclude; *p; p += strlen(p) + 1) 1050 free (cfgstr);
885 cfg.players.remove(cfg.players.lookup_filetype(p)); 1051 g_strdelimit (exclude, ":", '\0');
886 free(exclude); 1052 for (gchar * p = exclude; *p; p += strlen (p) + 1)
887 } 1053 cfg.players.remove (cfg.players.lookup_filetype (p));
888 bmp_cfg_db_close(db); 1054 free (exclude);
1055 }
1056 bmp_cfg_db_close (db);
889 1057
890 // Load database from disk and hand it to AdPlug 1058 // Load database from disk and hand it to AdPlug
891 dbg_printf("database"); 1059 dbg_printf ("database");
892 plr.db = new CAdPlugDatabase; 1060 plr.db = new CAdPlugDatabase;
893 1061
894 { 1062 {
895 const char *homedir = getenv("HOME"); 1063 const char *homedir = getenv ("HOME");
896 1064
897 if(homedir) { 1065 if (homedir)
898 char *userdb = (char *)malloc(strlen(homedir) + strlen(ADPLUG_CONFDIR) + 1066 {
899 strlen(ADPLUGDB_FILE) + 3); 1067 char *userdb =
900 strcpy(userdb, homedir); strcat(userdb, "/" ADPLUG_CONFDIR "/"); 1068 (char *) malloc (strlen (homedir) + strlen (ADPLUG_CONFDIR) +
901 strcat(userdb, ADPLUGDB_FILE); 1069 strlen (ADPLUGDB_FILE) + 3);
902 plr.db->load(userdb); // load user's database 1070 strcpy (userdb, homedir);
903 dbg_printf(" (userdb=\"%s\")", userdb); 1071 strcat (userdb, "/" ADPLUG_CONFDIR "/");
904 free(userdb); 1072 strcat (userdb, ADPLUGDB_FILE);
1073 plr.db->load (userdb); // load user's database
1074 dbg_printf (" (userdb=\"%s\")", userdb);
1075 free (userdb);
905 } 1076 }
906 } 1077 }
907 CAdPlug::set_database(plr.db); 1078 CAdPlug::set_database (plr.db);
908 dbg_printf(".\n"); 1079 dbg_printf (".\n");
909 } 1080 }
910 1081
911 static void adplug_quit(void) 1082 static void
912 { 1083 adplug_quit (void)
913 dbg_printf("adplug_quit(): open, "); 1084 {
914 ConfigDb *db = bmp_cfg_db_open(); 1085 dbg_printf ("adplug_quit(): open, ");
1086 ConfigDb *db = bmp_cfg_db_open ();
915 1087
916 // Close database 1088 // Close database
917 dbg_printf("db, "); 1089 dbg_printf ("db, ");
918 if(plr.db) delete plr.db; 1090 if (plr.db)
1091 delete plr.db;
919 1092
920 // Write configuration 1093 // Write configuration
921 dbg_printf("write, "); 1094 dbg_printf ("write, ");
922 bmp_cfg_db_set_bool(db, CFG_VERSION, "16bit", cfg.bit16); 1095 bmp_cfg_db_set_bool (db, CFG_VERSION, "16bit", cfg.bit16);
923 bmp_cfg_db_set_bool(db, CFG_VERSION, "Stereo", cfg.stereo); 1096 bmp_cfg_db_set_bool (db, CFG_VERSION, "Stereo", cfg.stereo);
924 bmp_cfg_db_set_int(db, CFG_VERSION, "Frequency", cfg.freq); 1097 bmp_cfg_db_set_int (db, CFG_VERSION, "Frequency", cfg.freq);
925 bmp_cfg_db_set_bool(db, CFG_VERSION, "Endless", cfg.endless); 1098 bmp_cfg_db_set_bool (db, CFG_VERSION, "Endless", cfg.endless);
926 1099
927 dbg_printf("exclude, "); 1100 dbg_printf ("exclude, ");
928 std::string exclude; 1101 std::string exclude;
929 for(CPlayers::const_iterator i = CAdPlug::players.begin(); 1102 for (CPlayers::const_iterator i = CAdPlug::players.begin ();
930 i != CAdPlug::players.end(); i++) 1103 i != CAdPlug::players.end (); i++)
931 if(find(cfg.players.begin(), cfg.players.end(), *i) == cfg.players.end()) { 1104 if (find (cfg.players.begin (), cfg.players.end (), *i) ==
932 if(!exclude.empty()) exclude += ":"; 1105 cfg.players.end ())
1106 {
1107 if (!exclude.empty ())
1108 exclude += ":";
933 exclude += (*i)->filetype; 1109 exclude += (*i)->filetype;
934 } 1110 }
935 gchar *cfgval = g_strdup(exclude.c_str()); 1111 gchar *cfgval = g_strdup (exclude.c_str ());
936 bmp_cfg_db_set_string(db, CFG_VERSION, "Exclude", cfgval); 1112 bmp_cfg_db_set_string (db, CFG_VERSION, "Exclude", cfgval);
937 free(cfgval); 1113 free (cfgval);
938 1114
939 dbg_printf("close"); 1115 dbg_printf ("close");
940 bmp_cfg_db_close(db); 1116 bmp_cfg_db_close (db);
941 dbg_printf(".\n"); 1117 dbg_printf (".\n");
942 } 1118 }
943 1119
944 /***** Plugin (exported) *****/ 1120 /***** Plugin (exported) *****/
945 1121
946 InputPlugin adplug_ip = 1122 InputPlugin adplug_ip = {
947 { 1123 NULL, // handle (filled by XMMS)
948 NULL, // handle (filled by XMMS) 1124 NULL, // filename (filled by XMMS)
949 NULL, // filename (filled by XMMS) 1125 ADPLUG_NAME, // plugin description
950 ADPLUG_NAME, // plugin description 1126 adplug_init, // plugin functions...
951 adplug_init, // plugin functions... 1127 adplug_about,
952 adplug_about, 1128 adplug_config,
953 adplug_config, 1129 adplug_is_our_file,
954 adplug_is_our_file, 1130 NULL, // scan_dir (look in Input/cdaudio/cdaudio.c)
955 NULL, // scan_dir (look in Input/cdaudio/cdaudio.c) 1131 adplug_play,
956 adplug_play, 1132 adplug_stop,
957 adplug_stop, 1133 adplug_pause,
958 adplug_pause, 1134 adplug_seek,
959 adplug_seek, 1135 NULL, // set_eq
960 NULL, // set_eq 1136 adplug_get_time,
961 adplug_get_time, 1137 NULL, // get_volume (handled by output plugin)
962 NULL, // get_volume (handled by output plugin) 1138 NULL, // set_volume (...)
963 NULL, // set_volume (...) 1139 adplug_quit,
964 adplug_quit, 1140 NULL, // OBSOLETE - DO NOT USE!
965 NULL, // OBSOLETE - DO NOT USE! 1141 NULL, // add_vis_pcm (filled by XMMS)
966 NULL, // add_vis_pcm (filled by XMMS) 1142 NULL, // set_info (filled by XMMS)
967 NULL, // set_info (filled by XMMS) 1143 NULL, // set_info_text (filled by XMMS)
968 NULL, // set_info_text (filled by XMMS) 1144 adplug_song_info,
969 adplug_song_info, 1145 adplug_info_box, // adplug_info_box was here (but it used deprecated GTK+ functions)
970 adplug_info_box, // adplug_info_box was here (but it used deprecated GTK+ functions) 1146 NULL, // output plugin (filled by XMMS)
971 NULL, // output plugin (filled by XMMS) 1147 NULL,
972 NULL, 1148 NULL,
973 NULL, 1149 NULL,
974 NULL, 1150 adplug_is_our_fd,
975 adplug_is_our_fd, 1151 NULL,
976 NULL, 1152 };
977 }; 1153
978 1154 extern "C" InputPlugin *
979 extern "C" InputPlugin *get_iplugin_info(void) 1155 get_iplugin_info (void)
980 { 1156 {
981 return &adplug_ip; 1157 return &adplug_ip;
982 } 1158 }