comparison src/xmms-sid.cc @ 28:15250dd0c326

Removed obsolete file
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 07 Jun 2003 22:52:00 +0000
parents 271be59be975
children 1788f4ce6a44
comparison
equal deleted inserted replaced
27:a5e583031c41 28:15250dd0c326
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) 2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
3 3
4 Main source file 4 Main source file
5 5
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org> 6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
7 (few bits may still be by Willem Monsuwe)
8 7
9 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version. 11 (at your option) any later version.
19 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */ 21 */
23 22
23 #include <pthread.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <stdio.h>
27 #include <errno.h>
28 #include <xmms/plugin.h>
29 #include <xmms/util.h>
24 #include "xmms-sid.h" 30 #include "xmms-sid.h"
25 #include "xs_config.h" 31 #include "xs_config.h"
26 #include "xs_length.h" 32 #include "xs_length.h"
27 #include "xs_title.h" 33 #include "xs_title.h"
34
35 extern "C++" {
28 #include <sidplay/player.h> 36 #include <sidplay/player.h>
29 #include <sidplay/myendian.h> 37 #include <sidplay/myendian.h>
30 #include <sidplay/fformat.h> 38 #include <sidplay/fformat.h>
31 39 }
32 extern "C" { 40
33 #include <pthread.h> 41
34 42 /*
35 #include <stdlib.h> 43 * Global variables
36 #include <string.h>
37 #include <stdio.h>
38 #include <errno.h>
39
40 #include <xmms/plugin.h>
41 #include <xmms/util.h>
42 }
43
44
45 /*
46 * Global variables
47 */ 44 */
48 static struct emuConfig xs_emuConf; 45 static struct emuConfig xs_emuConf;
49 static emuEngine xs_emuEngine; 46 static emuEngine xs_emuEngine;
50 static pthread_t xs_decode_thread; 47 static pthread_t xs_decode_thread;
51 struct t_xs_cfg xs_cfg; 48 struct t_xs_cfg xs_cfg;
64 */ 61 */
65 void xs_init(void) 62 void xs_init(void)
66 { 63 {
67 XSDEBUG("xs_init()\n"); 64 XSDEBUG("xs_init()\n");
68 65
69 /* Try to initialize libSIDPlay */
70 if (!xs_emuEngine)
71 {
72 XSERR("Couldn't start SIDPlay emulator engine!\n");
73 return;
74 }
75
76 if (!xs_emuEngine.verifyEndianess())
77 {
78 XSERR("Wrong hardware endianess (SIDPlay error)!\n");
79 return;
80 }
81
82 /* Initialize and get configuration */ 66 /* Initialize and get configuration */
83 memset(&xs_cfg, 0, sizeof(xs_cfg)); 67 memset(&xs_cfg, 0, sizeof(xs_cfg));
68
84 xs_get_configure(); 69 xs_get_configure();
85 70
86 xs_status.s_error = 0; 71 xs_status.s_error = 0;
87 xs_status.s_playing = 0; 72 xs_status.s_playing = 0;
88 xs_status.s_songs = 0; 73 xs_status.s_songs = 0;
89 xs_status.s_allownext = 1; // Initialize to TRUE to allow first song 74 xs_status.s_allownext = 1; // Initialize to TRUE to allow first song
90 xs_status.s_tune = NULL; 75 xs_status.s_tune = NULL;
91 xs_status.s_fname = NULL; 76 xs_status.s_fname = NULL;
92 77
78 /* Try to initialize libSIDPlay */
79 if (!xs_emuEngine)
80 {
81 XSERR("Couldn't start SIDPlay emulator engine!\n");
82 return;
83 }
84
85 if (!xs_emuEngine.verifyEndianess())
86 {
87 XSERR("Wrong hardware endianess (SIDPlay error)!\n");
88 return;
89 }
90
93 /* Read song-length database */ 91 /* Read song-length database */
94 if (xs_songlen_init() < 0) 92 if (xs_songlen_init() < 0)
95 { 93 {
96 XSERR("Error initializing song-length database!\n"); 94 XSERR("Error initializing song-length database!\n");
97 } 95 }
112 XSDEBUG("shutting down...\n"); 110 XSDEBUG("shutting down...\n");
113 111
114 /* Stop playing */ 112 /* Stop playing */
115 xs_plugin_ip.stop(); 113 xs_plugin_ip.stop();
116 114
115 /* Close sub-song control window */
116
117 /* Free allocated memory */ 117 /* Free allocated memory */
118 xs_songlen_close(); 118 xs_songlen_close();
119 119
120 // FIXME FIXME: STIL-entries, songlendb 120 // FIXME FIXME: STIL-entries
121 } 121 }
122 122
123 123
124 /* 124 /*
125 * Check whether the given file is handled by this plugin 125 * Check whether the given file is handled by this plugin
126 */ 126 */
127 gint xs_is_our_file(char *fileName) 127 gint xs_is_our_file(char *fileName)
128 { 128 {
129 char *pcExt; 129 char *pcExt;
130 130
131 /* Check the filename */ 131 /* Check the filename */
132 if (fileName == NULL) 132 if (fileName == NULL)
133 return FALSE; 133 return FALSE;
134 134
135 /* Try to detect via libSIDPlay's detection routine, if required */ 135 /* Try to detect via libSIDPlay's detection routine, if required */
136 if (xs_cfg.detectMagic) { 136 if (xs_cfg.detectMagic)
137 137 {
138 sidTune *testTune = new sidTune(fileName); 138 sidTune *testTune = new sidTune(fileName);
139 139
140 if (!testTune) return FALSE; 140 if (!testTune) return FALSE;
141 if (!testTune->getStatus()) 141 if (!testTune->getStatus())
142 { 142 {
164 return FALSE; 164 return FALSE;
165 } 165 }
166 166
167 167
168 /* 168 /*
169 * Playing thread loop function 169 * Main playing thread loop
170 */ 170 */
171 static void *xs_play_loop(void *argPointer) 171 static void *xs_play_loop(void *argPointer)
172 { 172 {
173 gchar plr_data[XS_BUFSIZE]; 173 guchar plr_data[XS_BUFSIZE];
174 struct sidTuneInfo plr_sidInf; 174 struct sidTuneInfo plr_sidInf;
175 gchar *plr_tune_title = NULL; 175 gchar *plr_tune_title = NULL;
176 gint plr_fxlen; 176 gint plr_fxlen;
177 enum AFormat plr_fmt; 177 enum AFormat plr_fmt;
178 gint plr_tune_num; 178 gint plr_tune_num;
179 gint32 plr_tune_len; 179 gint32 plr_tune_len;
180 180
181 181
182 /* Don't allow next song to be set yet */ 182 /* Don't allow next song to be set yet */
183 pthread_mutex_lock(&xs_mutex); 183 pthread_mutex_lock(&xs_mutex);
184 xs_status.s_allownext = 0; 184 xs_status.s_allownext = 0;
185 pthread_mutex_unlock(&xs_mutex); 185 pthread_mutex_unlock(&xs_mutex);
318 return NULL; 318 return NULL;
319 } 319 }
320 320
321 321
322 /* 322 /*
323 * Start playing the given file 323 * Start playing the given file
324 */ 324 */
325 void xs_play_file(char *fileName) 325 void xs_play_file(char *fileName)
326 { 326 {
327 sidTune *newTune; 327 sidTune *newTune;
328 struct sidTuneInfo sidInf; 328 struct sidTuneInfo sidInf;
336 /* Try to get the tune */ 336 /* Try to get the tune */
337 newTune = new sidTune(fileName); 337 newTune = new sidTune(fileName);
338 if (newTune == NULL) return; 338 if (newTune == NULL) return;
339 339
340 XSDEBUG("tune ok, status %i\n", xs_status.s_playing); 340 XSDEBUG("tune ok, status %i\n", xs_status.s_playing);
341
341 342
342 /* Get current configuration */ 343 /* Get current configuration */
343 xs_emuEngine.getConfig(xs_emuConf); 344 xs_emuEngine.getConfig(xs_emuConf);
344 345
345 346
368 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n"); 369 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n");
369 delete newTune; 370 delete newTune;
370 return; 371 return;
371 } 372 }
372 373
374
373 /* Memory mode settings */ 375 /* Memory mode settings */
374 switch (xs_cfg.memoryMode) { 376 switch (xs_cfg.memoryMode) {
375 case XMMS_SID_MPU_BANK_SWITCHING: 377 case XMMS_SID_MPU_BANK_SWITCHING:
376 xs_emuConf.memoryMode = MPU_BANK_SWITCHING; 378 xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
377 break; 379 break;
407 return; 409 return;
408 } 410 }
409 411
410 412
411 /* Configure rest of the emulation */ 413 /* Configure rest of the emulation */
412 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample; 414 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample;
413 xs_emuConf.frequency = xs_cfg.fmtFrequency; 415 xs_emuConf.frequency = xs_cfg.fmtFrequency;
414 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM; 416 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM;
415 xs_emuConf.mos8580 = xs_cfg.mos8580; 417 xs_emuConf.mos8580 = xs_cfg.mos8580;
416 xs_emuConf.emulateFilter = xs_cfg.emulateFilter; 418 xs_emuConf.emulateFilter = xs_cfg.emulateFilter;
417 xs_emuConf.filterFs = xs_cfg.filterFs; 419 xs_emuConf.filterFs = xs_cfg.filterFs;
418 xs_emuConf.filterFm = xs_cfg.filterFm; 420 xs_emuConf.filterFm = xs_cfg.filterFm;
419 xs_emuConf.filterFt = xs_cfg.filterFt; 421 xs_emuConf.filterFt = xs_cfg.filterFt;
420 422
421 XSDEBUG("configuring engine..\n"); 423 XSDEBUG("configuring engine..\n");
424
422 425
423 /* Now set the emulator configuration */ 426 /* Now set the emulator configuration */
424 xs_emuEngine.setConfig(xs_emuConf); 427 xs_emuEngine.setConfig(xs_emuConf);
425 newTune->getInfo(sidInf); 428 newTune->getInfo(sidInf);
429
430
431 /* Initialize status information */
432 XSDEBUG("starting thread!\n");
426 433
427 pthread_mutex_lock(&xs_mutex); 434 pthread_mutex_lock(&xs_mutex);
428 xs_status.s_error = 0; 435 xs_status.s_error = 0;
429 xs_status.s_playing = sidInf.startSong; 436 xs_status.s_playing = sidInf.startSong;
430 xs_status.s_songs = sidInf.songs; 437 xs_status.s_songs = sidInf.songs;
431 xs_status.s_tune = newTune; 438 xs_status.s_tune = newTune;
432 pthread_mutex_unlock(&xs_mutex); 439 pthread_mutex_unlock(&xs_mutex);
433 440
434 XSDEBUG("starting thread!\n");
435
436 /* Start the playing thread! */ 441 /* Start the playing thread! */
437 if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0) 442 if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0)
438 { 443 {
439 XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno)); 444 XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno));
440 delete newTune; 445 delete newTune;