# HG changeset patch # User Matti Hamalainen # Date 1069180202 0 # Node ID 2607683bc9eb80ed2c34558f1a220bc2649f8889 # Parent f9063960f04ed8204cbc94ef09da41e48cd34fc7 Improvements in length- and title handling. diff -r f9063960f04e -r 2607683bc9eb src/xmms-sid.h --- a/src/xmms-sid.h Sun Oct 05 14:22:04 2003 +0000 +++ b/src/xmms-sid.h Tue Nov 18 18:30:02 2003 +0000 @@ -20,17 +20,23 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef XMMS_SID_H -#define XMMS_SID_H +#ifndef _XMMS_SID_H +#define _XMMS_SID_H #ifdef __cplusplus extern "C" { #endif +#ifdef HAVE_CONFIG_H #include +#endif +#ifdef HAVE_ASSERT_H +#include +#else +#define assert(x) /* stub */ +#endif #include #include -#include /* * Some defines @@ -46,7 +52,7 @@ #define XS_CONFIG_IDENT "XMMS-SID" /* Configuration file identifier */ #define XS_CONFIG_FILE "/.xmms/xmms-sid" /* Use this configfile if autocyrpe fails */ -#define XS_STIL_MAXENTRY (48) /* Max number of sub-songs in STIL/SLDB node */ +#define XS_STIL_MAXENTRY (128) /* Max number of sub-songs in STIL/SLDB node */ #define XS_MIN_OVERSAMPLE (2) /* Minimum oversampling factor */ #define XS_MAX_OVERSAMPLE (8) /* Maximum oversampling factor */ @@ -113,4 +119,4 @@ #ifdef __cplusplus } #endif -#endif /* XMMS_SID_H */ +#endif /* _XMMS_SID_H */ diff -r f9063960f04e -r 2607683bc9eb src/xs_length.c --- a/src/xs_length.c Sun Oct 05 14:22:04 2003 +0000 +++ b/src/xs_length.c Tue Nov 18 18:30:02 2003 +0000 @@ -436,16 +436,16 @@ guint16 rd_be16(FILE *f) { - return (((guint16) fgetc(f)) * 256) + + return (((guint16) fgetc(f)) << 8) | ((guint16) fgetc(f)); } guint32 rd_be32(FILE *f) { - return (((guint32) fgetc(f)) * 16777216) + - (((guint32) fgetc(f)) * 65536) + - (((guint32) fgetc(f)) * 256) + + return (((guint32) fgetc(f)) << 24) | + (((guint32) fgetc(f)) << 16) | + (((guint32) fgetc(f)) << 8) | ((guint32) fgetc(f)); } diff -r f9063960f04e -r 2607683bc9eb src/xs_sidplay.h --- a/src/xs_sidplay.h Sun Oct 05 14:22:04 2003 +0000 +++ b/src/xs_sidplay.h Tue Nov 18 18:30:02 2003 +0000 @@ -10,14 +10,13 @@ gchar * TFUNCTION1(gchar *pcFilename, TTUNEINFO *pfInfo, gint iSubTune) { - gchar *pcStr, *pcResult, tmpStr[VBUFSIZE], tmpBuf[VBUFSIZE]; + gchar *sFileName, *sFilePath, *sFileExt, *pcStr, *pcResult, + tmpStr[VBUFSIZE], tmpBuf[VBUFSIZE]; gint iIndex; #ifdef HAVE_XMMSEXTRA TitleInput *ptInput; #endif - /* FIXME FIXME: get STIL-information */ - /* Check the info strings */ if (pfInfo->numberOfInfoStrings < 3) { @@ -27,6 +26,29 @@ return g_strdup(pfInfo->infoString[0]); } + /* Split the filename into path */ + sFilePath = g_strdup(songFilename); + sFileName = strrchr(sFilePath, '/'); + if (sFileName) + sFileName[1] = 0; + + /* Filename */ + sFileName = strrchr(songFilename, '/'); + if (sFileName) + sFileName = g_strdup(sFileName + 1); + else + sFileName = g_strdup(songFilename); + + sFileExt = strrchr(sFileName, '.'); + sFileExt[0] = 0; + + /* Extension */ + sFileExt = strrchr(songFilename, '.'); + + + /* FIXME FIXME: get STIL-information */ + + #ifdef HAVE_XMMSEXTRA /* Check if the titles are overridden or not */ if (!xs_cfg.titleOverride) @@ -40,9 +62,9 @@ ptInput->__version = XMMS_TITLEINPUT_VERSION; /* Create the input fields */ - ptInput->file_name = pfInfo->dataFileName; - ptInput->file_ext = g_strdup("sid"); - ptInput->file_path = pfInfo->path; + ptInput->file_name = sFileName; + ptInput->file_ext = sFileExt; + ptInput->file_path = sFilePath; ptInput->track_name = pfInfo->infoString[0]; ptInput->track_number = iSubTune; @@ -76,11 +98,14 @@ pcStr++; switch (*pcStr) { case '%': VPUTCH('%'); break; - case '1': VPUTSTR(pfInfo->infoString[1]); break; - case '2': VPUTSTR(pfInfo->infoString[0]); break; - case '3': VPUTSTR(pfInfo->infoString[2]); break; - case '4': VPUTSTR(pfInfo->formatString); break; - case '5': + case 'f': VPUTSTR(sFileName); break; + case 'F': VPUTSTR(sFilePath); break; + case 'e': VPUTSTR(sFileExt); break; + case 'p': VPUTSTR(pfInfo->infoString[1]); break; + case 't': VPUTSTR(pfInfo->infoString[0]); break; + case 'c': VPUTSTR(pfInfo->infoString[2]); break; + case 's': VPUTSTR(pfInfo->formatString); break; + case 'n': snprintf(tmpStr, VBUFSIZE, "%i", iSubTune); VPUTSTR(tmpStr); break; @@ -90,10 +115,17 @@ } pcStr++; } + tmpBuf[iIndex] = 0; + + /* Make resulting string */ pcResult = g_strdup(tmpBuf); } + /* Free temporary strings */ + g_free(sFileName); + g_free(sFilePath); + return pcResult; } @@ -107,6 +139,7 @@ t_xs_tune *pResult; TTUNEINFO tuneInfo; TTUNE *testTune; + gboolean haveInfo; gint i; /* Check if the tune exists and is readable */ @@ -120,7 +153,7 @@ } /* Get general tune information */ - testTune->getInfo(tuneInfo); + haveInfo = testTune->getInfo(tuneInfo); /* Get length information (NOTE: Do not free this!) */ tuneLen = xs_songlen_get(pcFilename); @@ -136,7 +169,11 @@ for (i = 0; i < pResult->nsubTunes; i++) { /* Make the title */ - pResult->subTunes[i].tuneTitle = TFUNCTION1(pcFilename, &tuneInfo, i+1); + if (haveInfo) + pResult->subTunes[i].tuneTitle = TFUNCTION1(pcFilename, &tuneInfo, i+1); + else + pResult->subTunes[i].tuneTitle = g_strdup(pcFilename); + /* Get song length */ if (tuneLen && (i < tuneLen->nLengths))