Mercurial > hg > xmms-sid
diff src/xs_sidplay.h @ 92:2607683bc9eb
Improvements in length- and title handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 18 Nov 2003 18:30:02 +0000 |
parents | 94497283affa |
children | 63cf9b2ddadf |
line wrap: on
line diff
--- 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))