Mercurial > hg > xmms-sid
comparison src/xmms-sid.cc @ 24:271be59be975
Lots of changes
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Jun 2003 12:42:05 +0000 |
parents | ac2972a7ccd5 |
children | 15250dd0c326 |
comparison
equal
deleted
inserted
replaced
23:469efc05e01e | 24:271be59be975 |
---|---|
22 */ | 22 */ |
23 | 23 |
24 #include "xmms-sid.h" | 24 #include "xmms-sid.h" |
25 #include "xs_config.h" | 25 #include "xs_config.h" |
26 #include "xs_length.h" | 26 #include "xs_length.h" |
27 #include "xs_title.h" | |
27 #include <sidplay/player.h> | 28 #include <sidplay/player.h> |
28 #include <sidplay/myendian.h> | 29 #include <sidplay/myendian.h> |
29 #include <sidplay/fformat.h> | 30 #include <sidplay/fformat.h> |
30 | 31 |
31 extern "C" { | 32 extern "C" { |
167 /* | 168 /* |
168 * Playing thread loop function | 169 * Playing thread loop function |
169 */ | 170 */ |
170 static void *xs_play_loop(void *argPointer) | 171 static void *xs_play_loop(void *argPointer) |
171 { | 172 { |
172 gchar plr_data[XMMS_SID_BUFSIZE]; | 173 gchar plr_data[XS_BUFSIZE]; |
173 struct sidTuneInfo plr_sidInf; | 174 struct sidTuneInfo plr_sidInf; |
174 gchar *plr_tune_title = NULL; | 175 gchar *plr_tune_title = NULL; |
175 gint plr_fxlen; | 176 gint plr_fxlen; |
176 enum AFormat plr_fmt; | 177 enum AFormat plr_fmt; |
177 gint plr_tune_num; | 178 gint plr_tune_num; |
204 // FIXME FIXME: FMT_S16_XXX -- different architechtures?? | 205 // FIXME FIXME: FMT_S16_XXX -- different architechtures?? |
205 // the patch may break something ... | 206 // the patch may break something ... |
206 plr_fmt = (xs_emuConf.bitsPerSample == 16) ? FMT_S16_NE : FMT_U8; | 207 plr_fmt = (xs_emuConf.bitsPerSample == 16) ? FMT_S16_NE : FMT_U8; |
207 | 208 |
208 | 209 |
209 if (!xmms_sid_ip.output->open_audio(plr_fmt, xs_emuConf.frequency, xs_emuConf.channels)) | 210 if (!xs_plugin_ip.output->open_audio(plr_fmt, xs_emuConf.frequency, xs_emuConf.channels)) |
210 { | 211 { |
211 pthread_mutex_lock(&xs_mutex); | 212 pthread_mutex_lock(&xs_mutex); |
212 xs_status.s_error = 1; | 213 xs_status.s_error = 1; |
213 if (plr_tune_title) g_free(plr_tune_title); | 214 if (plr_tune_title) g_free(plr_tune_title); |
214 if (xs_status.s_tune) delete xs_status.s_tune; | 215 if (xs_status.s_tune) delete xs_status.s_tune; |
228 goto pl_cleanup; | 229 goto pl_cleanup; |
229 } | 230 } |
230 | 231 |
231 | 232 |
232 /* Set song title information */ | 233 /* Set song title information */ |
233 xmms_sid_ip.set_info( | 234 xs_plugin_ip.set_info( |
234 plr_tune_title, | 235 plr_tune_title, |
235 (plr_tune_len * 1000), | 236 (plr_tune_len * 1000), |
236 (1000 * (plr_sidInf.songSpeed ? plr_sidInf.songSpeed : (plr_sidInf.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50)), | 237 (1000 * (plr_sidInf.songSpeed ? plr_sidInf.songSpeed : (plr_sidInf.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50)), |
237 xs_emuConf.frequency, | 238 xs_emuConf.frequency, |
238 xs_emuConf.channels); | 239 xs_emuConf.channels); |
239 | 240 |
240 | 241 |
241 /* Run playing loop: loop as long as xs_playing is same as current tune number */ | 242 /* Run playing loop: loop as long as xs_playing is same as current tune number */ |
242 while (xs_status.s_playing == plr_tune_num) | 243 while (xs_status.s_playing == plr_tune_num) |
243 { | 244 { |
244 plr_fxlen = XMMS_SID_BUFSIZE; | 245 plr_fxlen = XS_BUFSIZE; |
245 | 246 |
246 /* Run emulator to fill output buffer with audio data */ | 247 /* Run emulator to fill output buffer with audio data */ |
247 sidEmuFillBuffer(xs_emuEngine, *xs_status.s_tune, plr_data, plr_fxlen); | 248 sidEmuFillBuffer(xs_emuEngine, *xs_status.s_tune, plr_data, plr_fxlen); |
248 | 249 |
249 /* If Max Playtime option set, check playtime */ | 250 /* If Max Playtime option set, check playtime */ |
250 if (xs_cfg.playUseMaxTime) | 251 if (xs_cfg.playUseMaxTime) |
251 { | 252 { |
252 if ((xmms_sid_ip.output->output_time() / 1000) >= xs_cfg.playMaxTime) | 253 if ((xs_plugin_ip.output->output_time() / 1000) >= xs_cfg.playMaxTime) |
253 { | 254 { |
254 pthread_mutex_lock(&xs_mutex); | 255 pthread_mutex_lock(&xs_mutex); |
255 xs_status.s_playing = 0; | 256 xs_status.s_playing = 0; |
256 pthread_mutex_unlock(&xs_mutex); | 257 pthread_mutex_unlock(&xs_mutex); |
257 } | 258 } |
258 } | 259 } |
259 | 260 |
260 /* Check playtime against database */ | 261 /* Check playtime against database */ |
261 if (xs_cfg.playMethod == XMMS_SID_PMETHOD_DATABASE) | 262 if (xs_cfg.playMethod == XMMS_SID_PMETHOD_DATABASE) |
262 { | 263 { |
263 if ((xmms_sid_ip.output->output_time() / 1000) >= plr_tune_len) | 264 if ((xs_plugin_ip.output->output_time() / 1000) >= plr_tune_len) |
264 { | 265 { |
265 pthread_mutex_lock(&xs_mutex); | 266 pthread_mutex_lock(&xs_mutex); |
266 xs_status.s_playing = 0; | 267 xs_status.s_playing = 0; |
267 pthread_mutex_unlock(&xs_mutex); | 268 pthread_mutex_unlock(&xs_mutex); |
268 } | 269 } |
282 | 283 |
283 #endif | 284 #endif |
284 | 285 |
285 | 286 |
286 /* Send audio data to visualization plugin */ | 287 /* Send audio data to visualization plugin */ |
287 xmms_sid_ip.add_vis_pcm(xmms_sid_ip.output->written_time(), | 288 xs_plugin_ip.add_vis_pcm(xs_plugin_ip.output->written_time(), |
288 plr_fmt, xs_emuConf.channels, plr_fxlen, plr_data); | 289 plr_fmt, xs_emuConf.channels, plr_fxlen, plr_data); |
289 | 290 |
290 /* Wait for a while */ | 291 /* Wait for a while */ |
291 while ((xs_status.s_playing == plr_tune_num) && (xmms_sid_ip.output->buffer_free() < plr_fxlen)) | 292 while ((xs_status.s_playing == plr_tune_num) && (xs_plugin_ip.output->buffer_free() < plr_fxlen)) |
292 xmms_usleep(10000); | 293 xmms_usleep(10000); |
293 | 294 |
294 | 295 |
295 /* If playing, send final audio data to output plugin */ | 296 /* If playing, send final audio data to output plugin */ |
296 if (xs_status.s_playing == plr_tune_num) | 297 if (xs_status.s_playing == plr_tune_num) |
297 xmms_sid_ip.output->write_audio(plr_data, plr_fxlen); | 298 xs_plugin_ip.output->write_audio(plr_data, plr_fxlen); |
298 | 299 |
299 } /* End of playerloop */ | 300 } /* End of playerloop */ |
300 | 301 |
301 | 302 |
302 pl_cleanup: | 303 pl_cleanup: |
303 XSDEBUG("cleaning up...\n"); | 304 XSDEBUG("cleaning up...\n"); |
304 | 305 |
305 /* Cleanup & shutdown */ | 306 /* Cleanup & shutdown */ |
306 xmms_sid_ip.output->close_audio(); | 307 xs_plugin_ip.output->close_audio(); |
307 | 308 |
308 if (plr_tune_title) g_free(plr_tune_title); | 309 if (plr_tune_title) g_free(plr_tune_title); |
309 | 310 |
310 pthread_mutex_lock(&xs_mutex); | 311 pthread_mutex_lock(&xs_mutex); |
311 xs_status.s_playing = 0; | 312 xs_status.s_playing = 0; |
463 /* | 464 /* |
464 * Pause the playing | 465 * Pause the playing |
465 */ | 466 */ |
466 void xs_pause(short pauseState) | 467 void xs_pause(short pauseState) |
467 { | 468 { |
468 xmms_sid_ip.output->pause(pauseState); | 469 xs_plugin_ip.output->pause(pauseState); |
469 } | 470 } |
470 | 471 |
471 | 472 |
472 /* | 473 /* |
473 * Set the time-seek position | 474 * Set the time-seek position |
499 | 500 |
500 #ifdef HAVE_SONG_POSITION | 501 #ifdef HAVE_SONG_POSITION |
501 set_song_position(xs_status.s_playing, 1, xs_status.s_songs); | 502 set_song_position(xs_status.s_playing, 1, xs_status.s_songs); |
502 #endif | 503 #endif |
503 | 504 |
504 return xmms_sid_ip.output->output_time(); | 505 return xs_plugin_ip.output->output_time(); |
505 } | 506 } |
506 | 507 |
507 | 508 |
508 /* | 509 /* |
509 * Return song information | 510 * Return song information |