Mercurial > hg > xmms-sid
diff src/xs_title.c @ 402:f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
dynamic memory allocation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 01 Jun 2006 02:18:02 +0000 |
parents | b09d74eb71e6 |
children | 7f694e5a1493 |
line wrap: on
line diff
--- a/src/xs_title.c Wed May 31 22:52:00 2006 +0000 +++ b/src/xs_title.c Thu Jun 01 02:18:02 2006 +0000 @@ -43,36 +43,41 @@ } -gchar *xs_make_titlestring(gchar * pcFilename, gint iSubTune, gint nSubTunes, gint iSidModel, - const gchar * formatString, const gchar * infoString0, - const gchar * infoString1, const gchar * infoString2) +gchar *xs_make_titlestring(t_xs_tuneinfo *p, gint subTune) { - gchar *tmpFilename, *tmpFilePath, *tmpFileExt, *pcStr, - *pcResult, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; + gchar *tmpFilename, *tmpFilePath, *tmpFileExt, *pcStr, *pcResult, + tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; + t_xs_subtuneinfo *subInfo; gint iIndex; #ifdef HAVE_XMMSEXTRA TitleInput *ptInput; #endif /* Split the filename into path */ - tmpFilePath = g_strdup(pcFilename); + tmpFilePath = g_strdup(p->sidFilename); tmpFilename = xs_strrchr(tmpFilePath, '/'); if (tmpFilename) tmpFilename[1] = 0; /* Filename */ - tmpFilename = xs_strrchr(pcFilename, '/'); + tmpFilename = xs_strrchr(p->sidFilename, '/'); if (tmpFilename) tmpFilename = g_strdup(tmpFilename + 1); else - tmpFilename = g_strdup(pcFilename); + tmpFilename = g_strdup(p->sidFilename); tmpFileExt = xs_strrchr(tmpFilename, '.'); tmpFileExt[0] = 0; /* Extension */ - tmpFileExt = xs_strrchr(pcFilename, '.'); + tmpFileExt = xs_strrchr(p->sidFilename, '.'); + + /* Get sub-tune information */ + if ((subTune >= 0) && (subTune < p->nsubTunes)) { + subInfo = &(p->subTunes[subTune]); + } else + subInfo = NULL; #ifdef HAVE_XMMSEXTRA /* Check if the titles are overridden or not */ @@ -90,25 +95,20 @@ ptInput->file_ext = tmpFileExt; ptInput->file_path = tmpFilePath; - ptInput->track_name = g_strdup(infoString0); - ptInput->track_number = iSubTune; + ptInput->track_name = p->sidName; + ptInput->track_number = subTune + 1; ptInput->album_name = NULL; - ptInput->performer = g_strdup(infoString1); - ptInput->date = g_strdup((iSidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"); + ptInput->performer = p->sidComposer; + ptInput->date = (p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"; ptInput->year = 0; - ptInput->genre = g_strdup("SID-tune"); - ptInput->comment = g_strdup(infoString2); + ptInput->genre = "SID-tune"; + ptInput->comment = p->sidCopyright; /* Create the string */ pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput); /* Dispose all allocated memory */ - g_free(ptInput->track_name); - g_free(ptInput->performer); - g_free(ptInput->comment); - g_free(ptInput->date); - g_free(ptInput->genre); g_free(ptInput); } else #endif @@ -133,19 +133,19 @@ VPUTSTR(tmpFileExt); break; case 'p': - VPUTSTR(infoString1); + VPUTSTR(p->sidComposer); break; case 't': - VPUTSTR(infoString0); + VPUTSTR(p->sidName); break; case 'c': - VPUTSTR(infoString2); + VPUTSTR(p->sidCopyright); break; case 's': - VPUTSTR(formatString); + VPUTSTR(p->sidFormat); break; case 'm': - switch (iSidModel) { + switch (p->sidModel) { case XS_SIDMODEL_6581: VPUTSTR("6581"); break; @@ -153,16 +153,24 @@ VPUTSTR("8580"); break; default: - VPUTSTR("Unknown"); + VPUTSTR("?"); break; } break; + case 'S': + if (subInfo && (subInfo->tuneSpeed > 0)) { + g_snprintf(tmpStr, XS_BUF_SIZE, + "%i", subInfo->tuneSpeed); + VPUTSTR(tmpStr); + } else + VPUTSTR("?"); + break; case 'n': - snprintf(tmpStr, XS_BUF_SIZE, "%i", iSubTune); + g_snprintf(tmpStr, XS_BUF_SIZE, "%i", subTune + 1); VPUTSTR(tmpStr); break; case 'N': - snprintf(tmpStr, XS_BUF_SIZE, "%i", nSubTunes); + g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); VPUTSTR(tmpStr); break; }