# HG changeset patch # User Matti Hamalainen # Date 1172029140 0 # Node ID 3e4901a89f3d03f8c09abb5bec36a412c6573d40 # Parent d837d2f064564e5546286083b710ceefd9f29bb5 Audacious kludging. diff -r d837d2f06456 -r 3e4901a89f3d src/xs_support.c --- a/src/xs_support.c Wed Feb 21 03:38:05 2007 +0000 +++ b/src/xs_support.c Wed Feb 21 03:39:00 2007 +0000 @@ -304,7 +304,7 @@ dp = (guint8 *) p; while (n--) - *dp = c; + *(dp++) = c; return p; } diff -r d837d2f06456 -r 3e4901a89f3d src/xs_title.c --- a/src/xs_title.c Wed Feb 21 03:38:05 2007 +0000 +++ b/src/xs_title.c Wed Feb 21 03:39:00 2007 +0000 @@ -23,7 +23,90 @@ #include "xs_title.h" #include "xs_support.h" #include "xs_config.h" +#ifdef AUDACIOUS_PLUGIN +#include +#else #include +#endif + + +static void xs_path_split(gchar *path, gchar **tmpFilename, gchar **tmpFilePath, gchar **tmpFileExt) +{ + gchar *tmpStr; + + /* Split the filename into path */ + *tmpFilePath = g_strdup(path); + tmpStr = xs_strrchr(*tmpFilePath, '/'); + if (tmpStr) tmpStr[1] = 0; + + /* Filename */ + *tmpFilename = xs_strrchr(path, '/'); + if (*tmpFilename) + *tmpFilename = g_strdup(*tmpFilename + 1); + else + *tmpFilename = g_strdup(path); + + tmpStr = xs_strrchr(*tmpFilename, '.'); + tmpStr[0] = 0; + + /* Extension */ + *tmpFileExt = xs_strrchr(path, '.'); +} + + +#if defined(HAVE_XMMSEXTRA) || defined(AUDACIOUS_PLUGIN) +/* Tuple support + */ +static TitleInput * xs_get_titletuple(gchar *tmpFilename, gchar *tmpFilePath, + gchar *tmpFileExt, t_xs_tuneinfo *p, gint subTune) +{ + TitleInput *pResult; + +#ifdef AUDACIOUS_PLUGIN + pResult = bmp_title_input_new(); +#else + pResult = (TitleInput *) g_malloc0(sizeof(TitleInput)); + pResult->__size = XMMS_TITLEINPUT_SIZE; + pResult->__version = XMMS_TITLEINPUT_VERSION; +#endif + + /* Create the input fields */ + pResult->file_name = tmpFilename; + pResult->file_ext = tmpFileExt; + pResult->file_path = tmpFilePath; + + pResult->track_name = p->sidName; + pResult->track_number = subTune; + pResult->album_name = NULL; + pResult->performer = p->sidComposer; + pResult->date = (p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"; + + pResult->year = 0; + pResult->genre = "SID-tune"; + pResult->comment = p->sidCopyright; + + return pResult; +} + +#ifdef AUDACIOUS_PLUGIN +TitleInput * xs_make_titletuple(t_xs_tuneinfo *p, gint subTune) +{ + TitleInput *pResult; + gchar *tmpFilename, *tmpFilePath, *tmpFileExt; + + xs_path_split(p->sidFilename, &tmpFilename, + &tmpFilePath, &tmpFileExt); + + pResult = xs_get_titletuple(tmpFilename, tmpFilePath, + tmpFileExt, p, subTune); + + g_free(tmpFilename); + g_free(tmpFilePath); + + return pResult; +} +#endif +#endif /* @@ -45,72 +128,31 @@ 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(p->sidFilename); - tmpFilename = xs_strrchr(tmpFilePath, '/'); - if (tmpFilename) - tmpFilename[1] = 0; - - /* Filename */ - tmpFilename = xs_strrchr(p->sidFilename, '/'); - if (tmpFilename) - tmpFilename = g_strdup(tmpFilename + 1); - else - tmpFilename = g_strdup(p->sidFilename); - - tmpFileExt = xs_strrchr(tmpFilename, '.'); - tmpFileExt[0] = 0; - - /* Extension */ - tmpFileExt = xs_strrchr(p->sidFilename, '.'); - - + /* Get filename parts */ + xs_path_split(p->sidFilename, &tmpFilename, + &tmpFilePath, &tmpFileExt); + /* Get sub-tune information */ if ((subTune > 0) && (subTune <= p->nsubTunes)) { subInfo = &(p->subTunes[subTune - 1]); } else subInfo = NULL; -#ifdef HAVE_XMMSEXTRA + /* Check if the titles are overridden or not */ +#if defined(HAVE_XMMSEXTRA) || defined(AUDACIOUS_PLUGIN) 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 = tmpFilename; - ptInput->file_ext = tmpFileExt; - ptInput->file_path = tmpFilePath; - - ptInput->track_name = p->sidName; - ptInput->track_number = subTune; - ptInput->album_name = NULL; - ptInput->performer = p->sidComposer; - ptInput->date = (p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"; - - ptInput->year = 0; - 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); - } else + TitleInput *pTuple = xs_get_titletuple( + tmpFilename, tmpFilePath, tmpFileExt, p, subTune); + + pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); + g_free(pTuple); + } else #endif { /* Create the string */ diff -r d837d2f06456 -r 3e4901a89f3d src/xs_title.h --- a/src/xs_title.h Wed Feb 21 03:38:05 2007 +0000 +++ b/src/xs_title.h Wed Feb 21 03:39:00 2007 +0000 @@ -8,6 +8,9 @@ #endif gchar *xs_make_titlestring(t_xs_tuneinfo *, gint); +#ifdef AUDACIOUS_PLUGIN +TitleInput * xs_make_titletuple(t_xs_tuneinfo *p, gint subTune); +#endif #ifdef __cplusplus }