# HG changeset patch # User Matti Hamalainen # Date 1056993362 0 # Node ID bf6a524cf7cac5d635cc7b08e39a6ede81ecb46c # Parent 20695d61930079c5c0908f3b78115c48fa319564 Fixes, cleanups, etc. diff -r 20695d619300 -r bf6a524cf7ca src/xmms-sid.cc --- a/src/xmms-sid.cc Mon Jun 30 17:16:01 2003 +0000 +++ b/src/xmms-sid.cc Mon Jun 30 17:16:02 2003 +0000 @@ -135,8 +135,7 @@ #endif /* Read song-length database */ - if (xs_cfg.songlenDBEnable) - if (xs_songlen_init() < 0) + if (xs_cfg.songlenDBEnable && (xs_songlen_init() < 0)) { XSERR("Error initializing song-length database!\n"); } @@ -147,7 +146,7 @@ // FIXME FIXME FIx ME - XSDEBUG("xs_init() done\n"); + XSDEBUG("OK\n"); } @@ -190,8 +189,6 @@ if (pcFileName == NULL) return FALSE; - XSDEBUG("testFile('%s')\n", pcFileName); - /* Try to detect via libSIDPlay's detection routine, if required */ if (xs_cfg.detectMagic) { @@ -200,13 +197,11 @@ if (testTune->getStatus()) { delete testTune; - XSDEBUG("file = OK\n"); return TRUE; } /* We DON'T fall back to filename extension checking ... */ delete testTune; - XSDEBUG("file = kyrpe\n"); return FALSE; } @@ -222,7 +217,6 @@ if (!g_strcasecmp(pcExt, "info")) return TRUE; } - XSDEBUG("file was KYRPE\n"); return FALSE; } @@ -238,10 +232,15 @@ gint audioFreq, audioChannels, songLength; enum AFormat audioFmt; gchar audioBuffer[XS_BUFSIZE]; + gchar *tmpStr; - /* Check status */ + + pthread_mutex_lock(&xs_mutex); XSDEBUG("entering play thread\n"); - pthread_mutex_lock(&xs_mutex); + + /* No idea, if this is really required here, but better be + * careful since we're dealing with EVIL threads ... + */ if (!xs_status.allowNext) { pthread_mutex_unlock(&xs_mutex); @@ -254,6 +253,7 @@ memcpy(&myStatus, &xs_status, sizeof(t_xs_status)); pthread_mutex_unlock(&xs_mutex); + /* Copy and check audio options here (they might change in config while running) */ #ifdef HAVE_UNSIGNEDPCM audioFmt = (xs_cfg.fmtBitsPerSample == XS_RES_16BIT) ? FMT_U16_NE : FMT_U8; @@ -271,9 +271,11 @@ { pthread_mutex_lock(&xs_mutex); myStatus.currSong = xs_status.currSong; + myStatus.isPlaying = TRUE; pthread_mutex_unlock(&xs_mutex); - XSDEBUG("sub-song %i selected, initializing...\n", myStatus.currSong); + XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); + /* Get song length for current subtune */ songLength = xs_songlen_get(myStatus.currFileName, myStatus.currSong); @@ -287,15 +289,22 @@ if () #endif { - XSERR("Couldn't initialize SID-tune!\n"); - pthread_mutex_lock(&xs_mutex); - xs_status.isError = TRUE; - pthread_mutex_unlock(&xs_mutex); + XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", + myStatus.currFileName, myStatus.currSong); goto err_exit; } myStatus.currTune->getInfo(tuneInfo); + + /* Set information for current sub-tune */ + tmpStr = xs_filetitle_get(myStatus.currFileName, &tuneInfo, myStatus.currSong); + + xs_plugin_ip.set_info(tmpStr, (songLength > 0) ? songLength * 1000 : -1, + 1000 * (tuneInfo.songSpeed ? tuneInfo.songSpeed : (tuneInfo.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50), + audioFreq, audioChannels); + g_free(tmpStr); + /* Open the audio output */ if (!xs_plugin_ip.output->open_audio(audioFmt, audioFreq, audioChannels)) { @@ -308,24 +317,19 @@ audioOpen = TRUE; - /* Set some infoz */ - xs_plugin_ip.set_info(tuneInfo.infoString[0], (songLength > 0) ? songLength * 1000 : -1, - 1000 * (tuneInfo.songSpeed ? tuneInfo.songSpeed : (tuneInfo.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50), - audioFreq, audioChannels); - - XSDEBUG("rendering audio...\n"); - - /* Play the tune */ - while (xs_status.isPlaying && (xs_status.currSong == myStatus.currSong)) + /* + * Play the subtune + */ + while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong)) { + /* Render audio data */ #ifdef HAVE_SIDPLAY1 sidEmuFillBuffer(xs_emuEngine, *myStatus.currTune, audioBuffer, XS_BUFSIZE); #endif - #ifdef HAVE_SIDPLAY2 #endif - /* Visualice/haujobb */ + /* I <3 visualice/haujobb */ xs_plugin_ip.add_vis_pcm( xs_plugin_ip.output->written_time(), audioFmt, audioChannels, XS_BUFSIZE, audioBuffer); @@ -347,21 +351,21 @@ { if ((songLength == -1) && (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000))) - xs_status.isPlaying = FALSE; + myStatus.isPlaying = FALSE; } else { if (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000)) - xs_status.isPlaying = FALSE; + myStatus.isPlaying = FALSE; } } if (songLength > 0) { if (xs_plugin_ip.output->output_time() >= (songLength * 1000)) - xs_status.isPlaying = FALSE; + myStatus.isPlaying = FALSE; } } - XSDEBUG("tune ended/stopped\n"); + XSDEBUG("subtune ended/stopped\n"); /* Close audio */ if (audioOpen) @@ -370,6 +374,9 @@ xs_plugin_ip.output->close_audio(); audioOpen = FALSE; } + + /* Now determine if we continue by selecting other subtune or something */ + if (!myStatus.isPlaying) xs_status.isPlaying = FALSE; } /* When exiting, delete data */ @@ -394,6 +401,10 @@ /* Exit the playing thread */ XSDEBUG("exiting thread, bye.\n"); + + /* Last thing we do is set allowNext to TRUE to flag + * that we have ended all action in the thread + */ pthread_mutex_lock(&xs_mutex); xs_status.allowNext = TRUE; pthread_mutex_unlock(&xs_mutex); @@ -414,12 +425,9 @@ XSDEBUG("request to play '%s'\n", pcFileName); /* Try to get the tune */ - XSDEBUG("initializing tune from file\n"); newTune = new t_xs_tune(pcFileName); if (newTune == NULL) return; - XSDEBUG("status: allowNext=%i, isPlaying=%i\n", xs_status.allowNext, xs_status.isPlaying); - #ifdef HAVE_SIDPLAY1 /* Get current configuration */ xs_emuEngine.getConfig(xs_emuConf); @@ -641,13 +649,12 @@ */ void xs_seek(gint iTime) { + /* If we have song-position patch, check settings */ #ifdef HAVE_SONG_POSITION pthread_mutex_lock(&xs_mutex); if ((iTime > 0) && (iTime <= xs_status.nSongs) && xs_status.isPlaying) - { xs_status.currSong = iTime; - } pthread_mutex_unlock(&xs_mutex); #endif @@ -659,20 +666,22 @@ */ gint xs_get_time(void) { - XSDEBUG("kyrve? %i : %i\n", xs_status.isError, xs_status.isPlaying); + /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ if (xs_status.isError) return -2; - if (!xs_status.isPlaying) + /* If tune has ended, return -1 */ + if (xs_status.allowNext && !xs_status.isPlaying) return -1; - + /* Obsolete? */ #ifdef HAVE_SONG_POSITION pthread_mutex_lock(&xs_mutex); set_song_position(xs_status.currSong, 1, xs_status.nSongs); pthread_mutex_unlock(&xs_mutex); #endif + /* Else, return output time reported by audio output plugin */ return xs_plugin_ip.output->output_time(); } @@ -723,7 +732,7 @@ TitleInput *ptInput; #endif - // FIXME FIXME: get STIL-info + /* FIXME FIXME: get STIL-information */ /* Check the info strings */ diff -r 20695d619300 -r bf6a524cf7ca src/xs_config.c --- a/src/xs_config.c Mon Jun 30 17:16:01 2003 +0000 +++ b/src/xs_config.c Mon Jun 30 17:16:02 2003 +0000 @@ -79,12 +79,12 @@ t_xs_wid_item xs_widtable[] = { { WTYPE_BGROUP, CTYPE_INT, "cfg_res_16bit", &xs_cfg.fmtBitsPerSample, XS_RES_16BIT }, { WTYPE_BGROUP, CTYPE_INT, "cfg_res_8bit", &xs_cfg.fmtBitsPerSample, XS_RES_8BIT }, - { WTYPE_BGROUP, CTYPE_INT, "cfg_chn_mono", &xs_cfg.fmtChannels, XS_CHN_MONO }, { WTYPE_BGROUP, CTYPE_INT, "cfg_chn_stereo", &xs_cfg.fmtChannels, XS_CHN_STEREO }, { WTYPE_BGROUP, CTYPE_INT, "cfg_chn_autopan", &xs_cfg.fmtChannels, XS_CHN_AUTOPAN }, - { WTYPE_SPIN, CTYPE_INT, "cfg_samplerate", &xs_cfg.fmtFrequency, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_oversample", &xs_cfg.oversampleEnable, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_oversample_factor",&xs_cfg.oversampleFactor, 0 }, { WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_mos8580", &xs_cfg.mos8580, 0 }, { WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_filters", &xs_cfg.emulateFilters, 0 }, @@ -104,11 +104,14 @@ { WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_sidplay2_opt", &xs_cfg.optimiseLevel, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_sld_maxtime_enable",&xs_cfg.playMaxTimeEnable, 0 }, -{ WTYPE_SPIN, CTYPE_INT, "cfg_sld_maxtime", &xs_cfg.playMaxTime, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_sld_onlyunknown", &xs_cfg.playMaxTimeUnknown, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_maxtime_enable", &xs_cfg.playMaxTimeEnable, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_maxtime", &xs_cfg.playMaxTime, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_maxtime_unknown", &xs_cfg.playMaxTimeUnknown, 0 }, { WTYPE_BUTTON, CTYPE_BOOL, "cfg_sld_enable", &xs_cfg.songlenDBEnable, 0 }, { WTYPE_TEXT, CTYPE_STR, "cfg_sld_dbpath", &xs_cfg.songlenDBPath, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_silence_enable", &xs_cfg.silenceEnable, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_silence_min", &xs_cfg.silenceMinTime, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_silence_max", &xs_cfg.silenceMaxCheck, 0 }, { WTYPE_BUTTON, CTYPE_BOOL, "cfg_stil_enable", &xs_cfg.stilDBEnable, 0 }, { WTYPE_TEXT, CTYPE_STR, "cfg_stil_dbpath", &xs_cfg.stilDBPath, 0 }, diff -r 20695d619300 -r bf6a524cf7ca src/xs_config.h --- a/src/xs_config.h Mon Jun 30 17:16:01 2003 +0000 +++ b/src/xs_config.h Mon Jun 30 17:16:02 2003 +0000 @@ -69,6 +69,9 @@ gboolean songlenDBEnable; gchar *songlenDBPath; /* Path to Songlengths.txt */ + gboolean silenceEnable; /* Silence detection */ + gint silenceMinTime; + gint silenceMaxCheck; /* Miscellaneous settings */ gboolean stilDBEnable; diff -r 20695d619300 -r bf6a524cf7ca src/xs_length.c --- a/src/xs_length.c Mon Jun 30 17:16:01 2003 +0000 +++ b/src/xs_length.c Mon Jun 30 17:16:02 2003 +0000 @@ -576,8 +576,8 @@ iResult = dbNode->sLengths[subTune - 1]; /* Take off few last seconds */ - if (iResult > 2) - iResult -= 2; + if (iResult > 1) + iResult -= 1; } } }