Mercurial > hg > xmms-sid
view src/xs_sidplay.h @ 88:0cf08d137248
Some fixes for RPM-stuff
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 05 Oct 2003 12:38:02 +0000 |
parents | 94497283affa |
children | 2607683bc9eb |
line wrap: on
line source
/* * Here comes the really ugly code... * * Create the SID-tune description string from the tune's information * formatted by the user-specified format-string. */ #define VBUFSIZE (1024) #define VPUTCH(MCH) if (iIndex < VBUFSIZE) tmpBuf[iIndex++] = MCH; #define VPUTSTR(MSTR) {if (MSTR) {if ((iIndex + strlen(MSTR) + 1) < VBUFSIZE){strcpy(&tmpBuf[iIndex], MSTR);iIndex += strlen(MSTR); } else iIndex = VBUFSIZE;}} gchar * TFUNCTION1(gchar *pcFilename, TTUNEINFO *pfInfo, gint iSubTune) { gchar *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) { if (pfInfo->numberOfInfoStrings < 1) return 0; return g_strdup(pfInfo->infoString[0]); } #ifdef HAVE_XMMSEXTRA /* Check if the titles are overridden or not */ if (!xs_cfg.titleOverride) { /* Use generic XMMS titles */ /* XMMS_NEW_TITLEINPUT(ptInput); * We duplicate and add typecast to the code here due to XMMS's braindead headers */ ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput)); ptInput->__size = XMMS_TITLEINPUT_SIZE; 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->track_name = pfInfo->infoString[0]; ptInput->track_number = iSubTune; ptInput->album_name = NULL; ptInput->performer = pfInfo->infoString[1]; ptInput->date = g_strdup((pfInfo->sidModel == SIDTUNE_SIDMODEL_6581) ? "6581" : "8580"); ptInput->year = 0; ptInput->genre = g_strdup("SID-tune"); ptInput->comment = pfInfo->infoString[2]; /* Create the string */ pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput); /* Dispose all allocated memory */ g_free(ptInput->file_ext); g_free(ptInput->date); g_free(ptInput->genre); g_free(ptInput); } else #endif { /* Create the string */ pcStr = xs_cfg.titleFormat; iIndex = 0; while (*pcStr && (iIndex < VBUFSIZE)) { if (*pcStr == '%') { 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': snprintf(tmpStr, VBUFSIZE, "%i", iSubTune); VPUTSTR(tmpStr); break; } } else { VPUTCH(*pcStr); } pcStr++; } tmpBuf[iIndex] = 0; pcResult = g_strdup(tmpBuf); } return pcResult; } /* * Get all SID-tune information (for all sub-tunes) including name, length, etc. */ t_xs_tune * TFUNCTION2(gchar *pcFilename) { t_xs_sldb_node *tuneLen = NULL; t_xs_tune *pResult; TTUNEINFO tuneInfo; TTUNE *testTune; gint i; /* Check if the tune exists and is readable */ if ((testTune = new TTUNE(pcFilename)) == NULL) return NULL; if (!testTune->getStatus()) { delete testTune; return NULL; } /* Get general tune information */ testTune->getInfo(tuneInfo); /* Get length information (NOTE: Do not free this!) */ tuneLen = xs_songlen_get(pcFilename); /* Allocate tuneinfo structure */ if ((pResult = xs_tune_new(pcFilename, tuneInfo.songs, tuneInfo.startSong)) == NULL) { delete testTune; return NULL; } /* Get information for subtunes */ for (i = 0; i < pResult->nsubTunes; i++) { /* Make the title */ pResult->subTunes[i].tuneTitle = TFUNCTION1(pcFilename, &tuneInfo, i+1); /* Get song length */ if (tuneLen && (i < tuneLen->nLengths)) pResult->subTunes[i].tuneLength = tuneLen->sLengths[i]; else pResult->subTunes[i].tuneLength = -1; } delete testTune; return pResult; }