# HG changeset patch # User Matti Hamalainen # Date 1207163405 -10800 # Node ID b0743dc9165d2f0e11e4b89833bc397dbbf765cb # Parent 04ea91a61225361d5776ad5aa4f6c7e896e81171 Change tabs to 4 spaces, everywhere. diff -r 04ea91a61225 -r b0743dc9165d src/xmms-sid.c --- a/src/xmms-sid.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xmms-sid.c Wed Apr 02 22:10:05 2008 +0300 @@ -58,24 +58,24 @@ */ static const xs_player_t xs_playerlist[] = { #ifdef HAVE_SIDPLAY1 - {XS_ENG_SIDPLAY1, - xs_sidplay1_probe, - xs_sidplay1_init, xs_sidplay1_close, - xs_sidplay1_initsong, xs_sidplay1_fillbuffer, - xs_sidplay1_load, xs_sidplay1_delete, - xs_sidplay1_getinfo, xs_sidplay1_updateinfo, - NULL - }, + {XS_ENG_SIDPLAY1, + xs_sidplay1_probe, + xs_sidplay1_init, xs_sidplay1_close, + xs_sidplay1_initsong, xs_sidplay1_fillbuffer, + xs_sidplay1_load, xs_sidplay1_delete, + xs_sidplay1_getinfo, xs_sidplay1_updateinfo, + NULL + }, #endif #ifdef HAVE_SIDPLAY2 - {XS_ENG_SIDPLAY2, - xs_sidplay2_probe, - xs_sidplay2_init, xs_sidplay2_close, - xs_sidplay2_initsong, xs_sidplay2_fillbuffer, - xs_sidplay2_load, xs_sidplay2_delete, - xs_sidplay2_getinfo, xs_sidplay2_updateinfo, - xs_sidplay2_flush - }, + {XS_ENG_SIDPLAY2, + xs_sidplay2_probe, + xs_sidplay2_init, xs_sidplay2_close, + xs_sidplay2_initsong, xs_sidplay2_fillbuffer, + xs_sidplay2_load, xs_sidplay2_delete, + xs_sidplay2_getinfo, xs_sidplay2_updateinfo, + xs_sidplay2_flush + }, #endif }; @@ -93,8 +93,8 @@ static GtkObject *xs_subctrl_adj = NULL; XS_MUTEX(xs_subctrl); -void xs_subctrl_close(void); -void xs_subctrl_update(void); +void xs_subctrl_close(void); +void xs_subctrl_update(void); /* @@ -102,22 +102,22 @@ */ void xs_error(const char *fmt, ...) { - va_list ap; - fprintf(stderr, "XMMS-SID: "); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); + va_list ap; + fprintf(stderr, "XMMS-SID: "); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); } #ifndef DEBUG_NP void XSDEBUG(const char *fmt, ...) { #ifdef DEBUG - va_list ap; - fprintf(stderr, "XSDEBUG: "); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); + va_list ap; + fprintf(stderr, "XSDEBUG: "); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); #endif } #endif @@ -128,92 +128,92 @@ */ void xs_reinit(void) { - gint iPlayer; - gboolean isInitialized; + gint iPlayer; + gboolean isInitialized; - /* Stop playing, if we are */ - XS_MUTEX_LOCK(xs_status); - if (xs_status.isPlaying) { - XS_MUTEX_UNLOCK(xs_status); - xs_stop(); - } else { - XS_MUTEX_UNLOCK(xs_status); - } + /* Stop playing, if we are */ + XS_MUTEX_LOCK(xs_status); + if (xs_status.isPlaying) { + XS_MUTEX_UNLOCK(xs_status); + xs_stop(); + } else { + XS_MUTEX_UNLOCK(xs_status); + } - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_cfg); + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_cfg); - /* Initialize status and sanitize configuration */ - memset(&xs_status, 0, sizeof(xs_status)); + /* Initialize status and sanitize configuration */ + memset(&xs_status, 0, sizeof(xs_status)); - if (xs_cfg.audioFrequency < 8000) - xs_cfg.audioFrequency = 8000; + if (xs_cfg.audioFrequency < 8000) + xs_cfg.audioFrequency = 8000; - if (xs_cfg.oversampleFactor < XS_MIN_OVERSAMPLE) - xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; - else if (xs_cfg.oversampleFactor > XS_MAX_OVERSAMPLE) - xs_cfg.oversampleFactor = XS_MAX_OVERSAMPLE; + if (xs_cfg.oversampleFactor < XS_MIN_OVERSAMPLE) + xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; + else if (xs_cfg.oversampleFactor > XS_MAX_OVERSAMPLE) + xs_cfg.oversampleFactor = XS_MAX_OVERSAMPLE; - if (xs_cfg.audioChannels != XS_CHN_MONO) - xs_cfg.oversampleEnable = FALSE; + if (xs_cfg.audioChannels != XS_CHN_MONO) + xs_cfg.oversampleEnable = FALSE; - xs_status.audioFrequency = xs_cfg.audioFrequency; - xs_status.audioBitsPerSample = xs_cfg.audioBitsPerSample; - xs_status.audioChannels = xs_cfg.audioChannels; - xs_status.audioFormat = -1; - xs_status.oversampleEnable = xs_cfg.oversampleEnable; - xs_status.oversampleFactor = xs_cfg.oversampleFactor; + xs_status.audioFrequency = xs_cfg.audioFrequency; + xs_status.audioBitsPerSample = xs_cfg.audioBitsPerSample; + xs_status.audioChannels = xs_cfg.audioChannels; + xs_status.audioFormat = -1; + xs_status.oversampleEnable = xs_cfg.oversampleEnable; + xs_status.oversampleFactor = xs_cfg.oversampleFactor; - /* Try to initialize emulator engine */ - XSDEBUG("initializing emulator engine #%i...\n", xs_cfg.playerEngine); + /* Try to initialize emulator engine */ + XSDEBUG("initializing emulator engine #%i...\n", xs_cfg.playerEngine); - iPlayer = 0; - isInitialized = FALSE; - while ((iPlayer < xs_nplayerlist) && !isInitialized) { - if (xs_playerlist[iPlayer].plrIdent == xs_cfg.playerEngine) { - if (xs_playerlist[iPlayer].plrInit(&xs_status)) { - isInitialized = TRUE; - xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[iPlayer]; - } - } - iPlayer++; - } + iPlayer = 0; + isInitialized = FALSE; + while ((iPlayer < xs_nplayerlist) && !isInitialized) { + if (xs_playerlist[iPlayer].plrIdent == xs_cfg.playerEngine) { + if (xs_playerlist[iPlayer].plrInit(&xs_status)) { + isInitialized = TRUE; + xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[iPlayer]; + } + } + iPlayer++; + } - XSDEBUG("init#1: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); + XSDEBUG("init#1: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); - iPlayer = 0; - while ((iPlayer < xs_nplayerlist) && !isInitialized) { - if (xs_playerlist[iPlayer].plrInit(&xs_status)) { - isInitialized = TRUE; - xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[iPlayer]; - xs_cfg.playerEngine = xs_playerlist[iPlayer].plrIdent; - } else - iPlayer++; - } + iPlayer = 0; + while ((iPlayer < xs_nplayerlist) && !isInitialized) { + if (xs_playerlist[iPlayer].plrInit(&xs_status)) { + isInitialized = TRUE; + xs_status.sidPlayer = (xs_player_t *) & xs_playerlist[iPlayer]; + xs_cfg.playerEngine = xs_playerlist[iPlayer].plrIdent; + } else + iPlayer++; + } - XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); + XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer); - /* Get settings back, in case the chosen emulator backend changed them */ - xs_cfg.audioFrequency = xs_status.audioFrequency; - xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; - xs_cfg.audioChannels = xs_status.audioChannels; - xs_cfg.oversampleEnable = xs_status.oversampleEnable; + /* Get settings back, in case the chosen emulator backend changed them */ + xs_cfg.audioFrequency = xs_status.audioFrequency; + xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; + xs_cfg.audioChannels = xs_status.audioChannels; + xs_cfg.oversampleEnable = xs_status.oversampleEnable; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_cfg); - /* Initialize song-length database */ - xs_songlen_close(); - if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { - xs_error("Error initializing song-length database!\n"); - } + /* Initialize song-length database */ + xs_songlen_close(); + if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) { + xs_error("Error initializing song-length database!\n"); + } - /* Initialize STIL database */ - xs_stil_close(); - if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { - xs_error("Error initializing STIL database!\n"); - } + /* Initialize STIL database */ + xs_stil_close(); + if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) { + xs_error("Error initializing STIL database!\n"); + } } @@ -223,16 +223,16 @@ */ void xs_init(void) { - XSDEBUG("xs_init()\n"); + XSDEBUG("xs_init()\n"); - /* Initialize and get configuration */ - xs_init_configuration(); - xs_read_configuration(); + /* Initialize and get configuration */ + xs_init_configuration(); + xs_read_configuration(); - /* Initialize subsystems */ - xs_reinit(); + /* Initialize subsystems */ + xs_reinit(); - XSDEBUG("OK\n"); + XSDEBUG("OK\n"); } @@ -241,20 +241,20 @@ */ void xs_close(void) { - XSDEBUG("xs_close(): shutting down...\n"); + XSDEBUG("xs_close(): shutting down...\n"); - /* Stop playing, free structures */ - xs_stop(); + /* Stop playing, free structures */ + xs_stop(); - xs_tuneinfo_free(xs_status.tuneInfo); - xs_status.tuneInfo = NULL; - xs_status.sidPlayer->plrDeleteSID(&xs_status); - xs_status.sidPlayer->plrClose(&xs_status); + xs_tuneinfo_free(xs_status.tuneInfo); + xs_status.tuneInfo = NULL; + xs_status.sidPlayer->plrDeleteSID(&xs_status); + xs_status.sidPlayer->plrClose(&xs_status); - xs_songlen_close(); - xs_stil_close(); + xs_songlen_close(); + xs_stil_close(); - XSDEBUG("shutdown finished.\n"); + XSDEBUG("shutdown finished.\n"); } @@ -263,45 +263,45 @@ */ gint xs_is_our_file(gchar *pcFilename) { - gchar *pcExt; - assert(xs_status.sidPlayer); + gchar *pcExt; + assert(xs_status.sidPlayer); - /* Check the filename */ - if (pcFilename == NULL) - return FALSE; + /* Check the filename */ + if (pcFilename == NULL) + return FALSE; - /* Try to detect via detection routine, if required */ - if (xs_cfg.detectMagic) { - xs_file_t *f; - if ((f = xs_fopen(pcFilename, "rb")) != NULL) { - if (xs_status.sidPlayer->plrProbe(f)) - return TRUE; - xs_fclose(f); - } - } + /* Try to detect via detection routine, if required */ + if (xs_cfg.detectMagic) { + xs_file_t *f; + if ((f = xs_fopen(pcFilename, "rb")) != NULL) { + if (xs_status.sidPlayer->plrProbe(f)) + return TRUE; + xs_fclose(f); + } + } - /* Detect just by checking filename extension */ - pcExt = xs_strrchr(pcFilename, '.'); - if (pcExt) { - pcExt++; - switch (xs_cfg.playerEngine) { - case XS_ENG_SIDPLAY1: - case XS_ENG_SIDPLAY2: - if (!g_strcasecmp(pcExt, "psid")) - return TRUE; - if (!g_strcasecmp(pcExt, "sid")) - return TRUE; - if (!g_strcasecmp(pcExt, "dat")) - return TRUE; - if (!g_strcasecmp(pcExt, "inf")) - return TRUE; - if (!g_strcasecmp(pcExt, "info")) - return TRUE; - break; - } - } + /* Detect just by checking filename extension */ + pcExt = xs_strrchr(pcFilename, '.'); + if (pcExt) { + pcExt++; + switch (xs_cfg.playerEngine) { + case XS_ENG_SIDPLAY1: + case XS_ENG_SIDPLAY2: + if (!g_strcasecmp(pcExt, "psid")) + return TRUE; + if (!g_strcasecmp(pcExt, "sid")) + return TRUE; + if (!g_strcasecmp(pcExt, "dat")) + return TRUE; + if (!g_strcasecmp(pcExt, "inf")) + return TRUE; + if (!g_strcasecmp(pcExt, "info")) + return TRUE; + break; + } + } - return FALSE; + return FALSE; } @@ -310,252 +310,252 @@ */ void *xs_playthread(void *argPointer) { - xs_status_t myStatus; - xs_tuneinfo_t *myTune; - gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE; - gint audioGot, songLength, i; - gchar *audioBuffer = NULL, *oversampleBuffer = NULL, *tmpTitle; + xs_status_t myStatus; + xs_tuneinfo_t *myTune; + gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE; + gint audioGot, songLength, i; + gchar *audioBuffer = NULL, *oversampleBuffer = NULL, *tmpTitle; - (void) argPointer; + (void) argPointer; - /* Initialize */ - XSDEBUG("entering player thread\n"); - XS_MUTEX_LOCK(xs_status); - memcpy(&myStatus, &xs_status, sizeof(xs_status_t)); - myTune = xs_status.tuneInfo; - for (i = 0; i <= myTune->nsubTunes; i++) - myTune->subTunes[i].tunePlayed = FALSE; - XS_MUTEX_UNLOCK(xs_status); + /* Initialize */ + XSDEBUG("entering player thread\n"); + XS_MUTEX_LOCK(xs_status); + memcpy(&myStatus, &xs_status, sizeof(xs_status_t)); + myTune = xs_status.tuneInfo; + for (i = 0; i <= myTune->nsubTunes; i++) + myTune->subTunes[i].tunePlayed = FALSE; + XS_MUTEX_UNLOCK(xs_status); - /* Allocate audio buffer */ - audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); - if (audioBuffer == NULL) { - xs_error("Couldn't allocate memory for audio data buffer!\n"); - goto xs_err_exit; - } + /* Allocate audio buffer */ + audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); + if (audioBuffer == NULL) { + xs_error("Couldn't allocate memory for audio data buffer!\n"); + goto xs_err_exit; + } - if (myStatus.oversampleEnable) { - oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor); - if (oversampleBuffer == NULL) { - xs_error("Couldn't allocate memory for audio oversampling buffer!\n"); - goto xs_err_exit; - } - } + if (myStatus.oversampleEnable) { + oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor); + if (oversampleBuffer == NULL) { + xs_error("Couldn't allocate memory for audio oversampling buffer!\n"); + goto xs_err_exit; + } + } - /* - * Main player loop: while not stopped, loop here - play subtunes - */ - audioOpen = FALSE; - doPlay = TRUE; - while (xs_status.isPlaying && doPlay) { - /* Automatic sub-tune change logic */ - XS_MUTEX_LOCK(xs_cfg); - XS_MUTEX_LOCK(xs_status); - myStatus.isPlaying = TRUE; - - if (xs_status.currSong < 1 || myStatus.currSong < 1) { - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_cfg); - goto xs_err_exit; - } - - if (xs_cfg.subAutoEnable && (myStatus.currSong == xs_status.currSong)) { - /* Check if currently selected sub-tune has been played already */ - if (myTune->subTunes[myStatus.currSong-1].tunePlayed) { - /* Find a tune that has not been played */ - XSDEBUG("tune #%i already played, finding next match ...\n", myStatus.currSong); - isFound = FALSE; - i = 0; - while (!isFound && (++i <= myTune->nsubTunes)) { - if (xs_cfg.subAutoMinOnly) { - /* A tune with minimum length must be found */ - if (!myTune->subTunes[i-1].tunePlayed && - myTune->subTunes[i-1].tuneLength >= xs_cfg.subAutoMinTime) - isFound = TRUE; - } else { - /* Any unplayed tune is okay */ - if (!myTune->subTunes[i-1].tunePlayed) - isFound = TRUE; - } - } + /* + * Main player loop: while not stopped, loop here - play subtunes + */ + audioOpen = FALSE; + doPlay = TRUE; + while (xs_status.isPlaying && doPlay) { + /* Automatic sub-tune change logic */ + XS_MUTEX_LOCK(xs_cfg); + XS_MUTEX_LOCK(xs_status); + myStatus.isPlaying = TRUE; + + if (xs_status.currSong < 1 || myStatus.currSong < 1) { + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_cfg); + goto xs_err_exit; + } + + if (xs_cfg.subAutoEnable && (myStatus.currSong == xs_status.currSong)) { + /* Check if currently selected sub-tune has been played already */ + if (myTune->subTunes[myStatus.currSong-1].tunePlayed) { + /* Find a tune that has not been played */ + XSDEBUG("tune #%i already played, finding next match ...\n", myStatus.currSong); + isFound = FALSE; + i = 0; + while (!isFound && (++i <= myTune->nsubTunes)) { + if (xs_cfg.subAutoMinOnly) { + /* A tune with minimum length must be found */ + if (!myTune->subTunes[i-1].tunePlayed && + myTune->subTunes[i-1].tuneLength >= xs_cfg.subAutoMinTime) + isFound = TRUE; + } else { + /* Any unplayed tune is okay */ + if (!myTune->subTunes[i-1].tunePlayed) + isFound = TRUE; + } + } - if (isFound) { - /* Set the new sub-tune */ - XSDEBUG("found #%i\n", i); - xs_status.currSong = i; - } else - /* This is the end */ - doPlay = FALSE; + if (isFound) { + /* Set the new sub-tune */ + XSDEBUG("found #%i\n", i); + xs_status.currSong = i; + } else + /* This is the end */ + doPlay = FALSE; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_cfg); - continue; /* This is ugly, but ... */ - } - } + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_cfg); + continue; /* This is ugly, but ... */ + } + } - /* Tell that we are initializing, update sub-tune controls */ - myStatus.currSong = xs_status.currSong; - myTune->subTunes[myStatus.currSong-1].tunePlayed = TRUE; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_cfg); + /* Tell that we are initializing, update sub-tune controls */ + myStatus.currSong = xs_status.currSong; + myTune->subTunes[myStatus.currSong-1].tunePlayed = TRUE; + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_cfg); - XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); + XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); - GDK_THREADS_ENTER(); - xs_subctrl_update(); - GDK_THREADS_LEAVE(); + GDK_THREADS_ENTER(); + xs_subctrl_update(); + GDK_THREADS_LEAVE(); - /* Check minimum playtime */ - songLength = myTune->subTunes[myStatus.currSong-1].tuneLength; - if (xs_cfg.playMinTimeEnable && (songLength >= 0)) { - if (songLength < xs_cfg.playMinTime) - songLength = xs_cfg.playMinTime; - } + /* Check minimum playtime */ + songLength = myTune->subTunes[myStatus.currSong-1].tuneLength; + if (xs_cfg.playMinTimeEnable && (songLength >= 0)) { + if (songLength < xs_cfg.playMinTime) + songLength = xs_cfg.playMinTime; + } - /* Initialize song */ - if (!myStatus.sidPlayer->plrInitSong(&myStatus)) { - xs_error("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", - myTune->sidFilename, myStatus.currSong); - goto xs_err_exit; - } - - /* Open the audio output */ - XSDEBUG("open audio output (%d, %d, %d)\n", - myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); - - if (!xs_plugin_ip.output-> - open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) { - xs_error("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n", - myStatus.audioFormat, - myStatus.audioFrequency, - myStatus.audioChannels); + /* Initialize song */ + if (!myStatus.sidPlayer->plrInitSong(&myStatus)) { + xs_error("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", + myTune->sidFilename, myStatus.currSong); + goto xs_err_exit; + } + + /* Open the audio output */ + XSDEBUG("open audio output (%d, %d, %d)\n", + myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); + + if (!xs_plugin_ip.output-> + open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) { + xs_error("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n", + myStatus.audioFormat, + myStatus.audioFrequency, + myStatus.audioChannels); - XS_MUTEX_LOCK(xs_status); - xs_status.isError = TRUE; - XS_MUTEX_UNLOCK(xs_status); - goto xs_err_exit; - } + XS_MUTEX_LOCK(xs_status); + xs_status.isError = TRUE; + XS_MUTEX_UNLOCK(xs_status); + goto xs_err_exit; + } - audioOpen = TRUE; + audioOpen = TRUE; - /* Set song information for current subtune */ - XSDEBUG("set tune info\n"); - myStatus.sidPlayer->plrUpdateSIDInfo(&myStatus); - tmpTitle = xs_make_titlestring(myTune, myStatus.currSong); - - xs_plugin_ip.set_info( - tmpTitle, - (songLength > 0) ? (songLength * 1000) : 0, - -1, - myStatus.audioFrequency, - myStatus.audioChannels); - - g_free(tmpTitle); - - XSDEBUG("playing\n"); + /* Set song information for current subtune */ + XSDEBUG("set tune info\n"); + myStatus.sidPlayer->plrUpdateSIDInfo(&myStatus); + tmpTitle = xs_make_titlestring(myTune, myStatus.currSong); + + xs_plugin_ip.set_info( + tmpTitle, + (songLength > 0) ? (songLength * 1000) : 0, + -1, + myStatus.audioFrequency, + myStatus.audioChannels); + + g_free(tmpTitle); + + XSDEBUG("playing\n"); - /* - * Play the subtune - */ - while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong)) { - /* Render audio data */ - if (myStatus.oversampleEnable) { - /* Perform oversampled rendering */ - audioGot = myStatus.sidPlayer->plrFillBuffer( - &myStatus, - oversampleBuffer, - (XS_AUDIOBUF_SIZE * myStatus.oversampleFactor)); + /* + * Play the subtune + */ + while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong)) { + /* Render audio data */ + if (myStatus.oversampleEnable) { + /* Perform oversampled rendering */ + audioGot = myStatus.sidPlayer->plrFillBuffer( + &myStatus, + oversampleBuffer, + (XS_AUDIOBUF_SIZE * myStatus.oversampleFactor)); - audioGot /= myStatus.oversampleFactor; + audioGot /= myStatus.oversampleFactor; - /* Execute rate-conversion with filtering */ - if (xs_filter_rateconv(audioBuffer, oversampleBuffer, - myStatus.audioFormat, myStatus.oversampleFactor, audioGot) < 0) { - xs_error("Oversampling rate-conversion pass failed.\n"); - XS_MUTEX_LOCK(xs_status); - xs_status.isError = TRUE; - XS_MUTEX_UNLOCK(xs_status); - goto xs_err_exit; - } - } else { - audioGot = myStatus.sidPlayer->plrFillBuffer( - &myStatus, audioBuffer, XS_AUDIOBUF_SIZE); - } + /* Execute rate-conversion with filtering */ + if (xs_filter_rateconv(audioBuffer, oversampleBuffer, + myStatus.audioFormat, myStatus.oversampleFactor, audioGot) < 0) { + xs_error("Oversampling rate-conversion pass failed.\n"); + XS_MUTEX_LOCK(xs_status); + xs_status.isError = TRUE; + XS_MUTEX_UNLOCK(xs_status); + goto xs_err_exit; + } + } else { + audioGot = myStatus.sidPlayer->plrFillBuffer( + &myStatus, audioBuffer, XS_AUDIOBUF_SIZE); + } - /* I <3 visualice/haujobb */ - xs_plugin_ip.add_vis_pcm( - xs_plugin_ip.output->written_time(), - myStatus.audioFormat, myStatus.audioChannels, - audioGot, audioBuffer); + /* I <3 visualice/haujobb */ + xs_plugin_ip.add_vis_pcm( + xs_plugin_ip.output->written_time(), + myStatus.audioFormat, myStatus.audioChannels, + audioGot, audioBuffer); - /* Wait a little */ - while (xs_status.isPlaying && - (xs_status.currSong == myStatus.currSong) && - (xs_plugin_ip.output->buffer_free() < audioGot)) - xmms_usleep(500); + /* Wait a little */ + while (xs_status.isPlaying && + (xs_status.currSong == myStatus.currSong) && + (xs_plugin_ip.output->buffer_free() < audioGot)) + xmms_usleep(500); - /* Output audio */ - if (xs_status.isPlaying && (xs_status.currSong == myStatus.currSong)) - xs_plugin_ip.output->write_audio(audioBuffer, audioGot); + /* Output audio */ + if (xs_status.isPlaying && (xs_status.currSong == myStatus.currSong)) + xs_plugin_ip.output->write_audio(audioBuffer, audioGot); - /* Check if we have played enough */ - if (xs_cfg.playMaxTimeEnable) { - if (xs_cfg.playMaxTimeUnknown) { - if ((songLength < 0) && - (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000))) - myStatus.isPlaying = FALSE; - } else { - if (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000)) - myStatus.isPlaying = FALSE; - } - } + /* Check if we have played enough */ + if (xs_cfg.playMaxTimeEnable) { + if (xs_cfg.playMaxTimeUnknown) { + if ((songLength < 0) && + (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000))) + myStatus.isPlaying = FALSE; + } else { + if (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000)) + myStatus.isPlaying = FALSE; + } + } - if (songLength >= 0) { - if (xs_plugin_ip.output->output_time() >= (songLength * 1000)) - myStatus.isPlaying = FALSE; - } - } + if (songLength >= 0) { + if (xs_plugin_ip.output->output_time() >= (songLength * 1000)) + myStatus.isPlaying = FALSE; + } + } - XSDEBUG("subtune ended/stopped\n"); + XSDEBUG("subtune ended/stopped\n"); - /* Close audio output plugin */ - if (audioOpen) { - XSDEBUG("close audio #1\n"); - xs_plugin_ip.output->close_audio(); - audioOpen = FALSE; - XSDEBUG("closed\n"); - } + /* Close audio output plugin */ + if (audioOpen) { + XSDEBUG("close audio #1\n"); + xs_plugin_ip.output->close_audio(); + audioOpen = FALSE; + XSDEBUG("closed\n"); + } - /* Now determine if we continue by selecting other subtune or something */ - if (!myStatus.isPlaying && !xs_cfg.subAutoEnable) - doPlay = FALSE; - } + /* Now determine if we continue by selecting other subtune or something */ + if (!myStatus.isPlaying && !xs_cfg.subAutoEnable) + doPlay = FALSE; + } xs_err_exit: - XSDEBUG("out of playing loop\n"); - - /* Close audio output plugin */ - if (audioOpen) { - XSDEBUG("close audio #2\n"); - xs_plugin_ip.output->close_audio(); - XSDEBUG("closed\n"); - } + XSDEBUG("out of playing loop\n"); + + /* Close audio output plugin */ + if (audioOpen) { + XSDEBUG("close audio #2\n"); + xs_plugin_ip.output->close_audio(); + XSDEBUG("closed\n"); + } - g_free(audioBuffer); - g_free(oversampleBuffer); + g_free(audioBuffer); + g_free(oversampleBuffer); - /* Set playing status to false (stopped), thus when - * XMMS next calls xs_get_time(), it can return appropriate - * value "not playing" status and XMMS knows to move to - * next entry in the playlist .. or whatever it wishes. - */ - XS_MUTEX_LOCK(xs_status); - xs_status.isPlaying = FALSE; - XS_MUTEX_UNLOCK(xs_status); + /* Set playing status to false (stopped), thus when + * XMMS next calls xs_get_time(), it can return appropriate + * value "not playing" status and XMMS knows to move to + * next entry in the playlist .. or whatever it wishes. + */ + XS_MUTEX_LOCK(xs_status); + xs_status.isPlaying = FALSE; + XS_MUTEX_UNLOCK(xs_status); - /* Exit the playing thread */ - XSDEBUG("exiting thread, bye.\n"); - XS_THREAD_EXIT(NULL); + /* Exit the playing thread */ + XSDEBUG("exiting thread, bye.\n"); + XS_THREAD_EXIT(NULL); } @@ -567,41 +567,41 @@ */ void xs_play_file(gchar * pcFilename) { - assert(xs_status.sidPlayer); + assert(xs_status.sidPlayer); - XSDEBUG("play '%s'\n", pcFilename); + XSDEBUG("play '%s'\n", pcFilename); - /* Get tune information */ - if ((xs_status.tuneInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) - return; + /* Get tune information */ + if ((xs_status.tuneInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) + return; - /* Initialize the tune */ - if (!xs_status.sidPlayer->plrLoadSID(&xs_status, pcFilename)) { - xs_tuneinfo_free(xs_status.tuneInfo); - xs_status.tuneInfo = NULL; - return; - } + /* Initialize the tune */ + if (!xs_status.sidPlayer->plrLoadSID(&xs_status, pcFilename)) { + xs_tuneinfo_free(xs_status.tuneInfo); + xs_status.tuneInfo = NULL; + return; + } - XSDEBUG("load ok\n"); + XSDEBUG("load ok\n"); - /* Set general status information */ - xs_status.isPlaying = TRUE; - xs_status.isError = FALSE; - xs_status.currSong = xs_status.tuneInfo->startTune; + /* Set general status information */ + xs_status.isPlaying = TRUE; + xs_status.isError = FALSE; + xs_status.currSong = xs_status.tuneInfo->startTune; - /* Start the playing thread! */ - if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) { - xs_error("Couldn't create playing thread!\n"); - xs_tuneinfo_free(xs_status.tuneInfo); - xs_status.tuneInfo = NULL; - xs_status.sidPlayer->plrDeleteSID(&xs_status); - } + /* Start the playing thread! */ + if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) { + xs_error("Couldn't create playing thread!\n"); + xs_tuneinfo_free(xs_status.tuneInfo); + xs_status.tuneInfo = NULL; + xs_status.sidPlayer->plrDeleteSID(&xs_status); + } - /* Okay, here the playing thread has started up and we - * return from here to XMMS. Rest is up to XMMS's GUI - * and playing thread. - */ - XSDEBUG("systems should be up?\n"); + /* Okay, here the playing thread has started up and we + * return from here to XMMS. Rest is up to XMMS's GUI + * and playing thread. + */ + XSDEBUG("systems should be up?\n"); } @@ -617,36 +617,36 @@ */ void xs_stop(void) { - XSDEBUG("stop requested\n"); + XSDEBUG("stop requested\n"); - /* Close the sub-tune control window, if any */ - xs_subctrl_close(); + /* Close the sub-tune control window, if any */ + xs_subctrl_close(); - /* Lock xs_status and stop playing thread */ - XS_MUTEX_LOCK(xs_status); - if (xs_status.isPlaying) { - XSDEBUG("stopping...\n"); - xs_status.isPlaying = FALSE; - XS_MUTEX_UNLOCK(xs_status); - XS_THREAD_JOIN(xs_decode_thread); - } else { - XS_MUTEX_UNLOCK(xs_status); - } + /* Lock xs_status and stop playing thread */ + XS_MUTEX_LOCK(xs_status); + if (xs_status.isPlaying) { + XSDEBUG("stopping...\n"); + xs_status.isPlaying = FALSE; + XS_MUTEX_UNLOCK(xs_status); + XS_THREAD_JOIN(xs_decode_thread); + } else { + XS_MUTEX_UNLOCK(xs_status); + } - XSDEBUG("done, updating status\n"); - - /* Status is now stopped, update the sub-tune - * controller in fileinfo window (if open) - */ - xs_fileinfo_update(); + XSDEBUG("done, updating status\n"); + + /* Status is now stopped, update the sub-tune + * controller in fileinfo window (if open) + */ + xs_fileinfo_update(); - /* Free tune information */ - XS_MUTEX_LOCK(xs_status); - xs_status.sidPlayer->plrDeleteSID(&xs_status); - xs_tuneinfo_free(xs_status.tuneInfo); - xs_status.tuneInfo = NULL; - XS_MUTEX_UNLOCK(xs_status); - XSDEBUG("ok\n"); + /* Free tune information */ + XS_MUTEX_LOCK(xs_status); + xs_status.sidPlayer->plrDeleteSID(&xs_status); + xs_tuneinfo_free(xs_status.tuneInfo); + xs_status.tuneInfo = NULL; + XS_MUTEX_UNLOCK(xs_status); + XSDEBUG("ok\n"); } @@ -655,13 +655,13 @@ */ void xs_pause(short pauseState) { - XS_MUTEX_LOCK(xs_status); - /* FIXME FIX ME todo: pause should disable sub-tune controls */ - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_LOCK(xs_status); + /* FIXME FIX ME todo: pause should disable sub-tune controls */ + XS_MUTEX_UNLOCK(xs_status); - xs_subctrl_close(); - xs_fileinfo_update(); - xs_plugin_ip.output->pause(pauseState); + xs_subctrl_close(); + xs_fileinfo_update(); + xs_plugin_ip.output->pause(pauseState); } @@ -670,170 +670,170 @@ */ void xs_subctrl_setsong(void) { - gint n; + gint n; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_subctrl); + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_subctrl); - if (xs_status.tuneInfo && xs_status.isPlaying) { - n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value; - if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes)) - xs_status.currSong = n; - } + if (xs_status.tuneInfo && xs_status.isPlaying) { + n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value; + if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes)) + xs_status.currSong = n; + } - XS_MUTEX_UNLOCK(xs_subctrl); - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_subctrl); + XS_MUTEX_UNLOCK(xs_status); } void xs_subctrl_prevsong(void) { - XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_status); - if (xs_status.tuneInfo && xs_status.isPlaying) { - if (xs_status.currSong > 1) - xs_status.currSong--; - } + if (xs_status.tuneInfo && xs_status.isPlaying) { + if (xs_status.currSong > 1) + xs_status.currSong--; + } - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_status); - xs_subctrl_update(); + xs_subctrl_update(); } void xs_subctrl_nextsong(void) { - XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_status); - if (xs_status.tuneInfo && xs_status.isPlaying) { - if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) - xs_status.currSong++; - } + if (xs_status.tuneInfo && xs_status.isPlaying) { + if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) + xs_status.currSong++; + } - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_status); - xs_subctrl_update(); + xs_subctrl_update(); } void xs_subctrl_update(void) { - GtkAdjustment *tmpAdj; + GtkAdjustment *tmpAdj; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_subctrl); + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_subctrl); - /* Check if control window exists, we are currently playing and have a tune */ - if (xs_subctrl) { - if (xs_status.tuneInfo && xs_status.isPlaying) { - tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj); + /* Check if control window exists, we are currently playing and have a tune */ + if (xs_subctrl) { + if (xs_status.tuneInfo && xs_status.isPlaying) { + tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj); - tmpAdj->value = xs_status.currSong; - tmpAdj->lower = 1; - tmpAdj->upper = xs_status.tuneInfo->nsubTunes; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_subctrl); - gtk_adjustment_value_changed(tmpAdj); - } else { - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_subctrl); - xs_subctrl_close(); - } - } else { - XS_MUTEX_UNLOCK(xs_subctrl); - XS_MUTEX_UNLOCK(xs_status); - } + tmpAdj->value = xs_status.currSong; + tmpAdj->lower = 1; + tmpAdj->upper = xs_status.tuneInfo->nsubTunes; + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_subctrl); + gtk_adjustment_value_changed(tmpAdj); + } else { + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_subctrl); + xs_subctrl_close(); + } + } else { + XS_MUTEX_UNLOCK(xs_subctrl); + XS_MUTEX_UNLOCK(xs_status); + } - xs_fileinfo_update(); + xs_fileinfo_update(); } void xs_subctrl_close(void) { - XS_MUTEX_LOCK(xs_subctrl); + XS_MUTEX_LOCK(xs_subctrl); - if (xs_subctrl) { - gtk_widget_destroy(xs_subctrl); - xs_subctrl = NULL; - } + if (xs_subctrl) { + gtk_widget_destroy(xs_subctrl); + xs_subctrl = NULL; + } - XS_MUTEX_UNLOCK(xs_subctrl); + XS_MUTEX_UNLOCK(xs_subctrl); } gboolean xs_subctrl_keypress(GtkWidget * win, GdkEventKey * ev) { - (void) win; + (void) win; - if (ev->keyval == GDK_Escape) - xs_subctrl_close(); + if (ev->keyval == GDK_Escape) + xs_subctrl_close(); - return FALSE; + return FALSE; } void xs_subctrl_open(void) { - GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next; + GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next; - XS_MUTEX_LOCK(xs_subctrl); - if (!xs_status.tuneInfo || !xs_status.isPlaying || - xs_subctrl || (xs_status.tuneInfo->nsubTunes <= 1)) { - XS_MUTEX_UNLOCK(xs_subctrl); - return; - } + XS_MUTEX_LOCK(xs_subctrl); + if (!xs_status.tuneInfo || !xs_status.isPlaying || + xs_subctrl || (xs_status.tuneInfo->nsubTunes <= 1)) { + XS_MUTEX_UNLOCK(xs_subctrl); + return; + } - /* Create the pop-up window */ - xs_subctrl = gtk_window_new(GTK_WINDOW_DIALOG); - gtk_widget_set_name(xs_subctrl, "xs_subctrl"); - gtk_object_set_data(GTK_OBJECT(xs_subctrl), "xs_subctrl", xs_subctrl); + /* Create the pop-up window */ + xs_subctrl = gtk_window_new(GTK_WINDOW_DIALOG); + gtk_widget_set_name(xs_subctrl, "xs_subctrl"); + gtk_object_set_data(GTK_OBJECT(xs_subctrl), "xs_subctrl", xs_subctrl); - gtk_window_set_title(GTK_WINDOW(xs_subctrl), _("Subtune Control")); - gtk_window_set_position(GTK_WINDOW(xs_subctrl), GTK_WIN_POS_MOUSE); - gtk_container_set_border_width(GTK_CONTAINER(xs_subctrl), 0); - gtk_window_set_policy(GTK_WINDOW(xs_subctrl), FALSE, FALSE, FALSE); + gtk_window_set_title(GTK_WINDOW(xs_subctrl), _("Subtune Control")); + gtk_window_set_position(GTK_WINDOW(xs_subctrl), GTK_WIN_POS_MOUSE); + gtk_container_set_border_width(GTK_CONTAINER(xs_subctrl), 0); + gtk_window_set_policy(GTK_WINDOW(xs_subctrl), FALSE, FALSE, FALSE); - XS_SIGNAL_CONNECT(xs_subctrl, "destroy", gtk_widget_destroyed, &xs_subctrl); - XS_SIGNAL_CONNECT(xs_subctrl, "focus_out_event", xs_subctrl_close, NULL); + XS_SIGNAL_CONNECT(xs_subctrl, "destroy", gtk_widget_destroyed, &xs_subctrl); + XS_SIGNAL_CONNECT(xs_subctrl, "focus_out_event", xs_subctrl_close, NULL); - gtk_widget_realize(xs_subctrl); - gdk_window_set_decorations(xs_subctrl->window, (GdkWMDecoration) 0); + gtk_widget_realize(xs_subctrl); + gdk_window_set_decorations(xs_subctrl->window, (GdkWMDecoration) 0); - /* Create the control widgets */ - frame25 = gtk_frame_new(NULL); - gtk_container_add(GTK_CONTAINER(xs_subctrl), frame25); - gtk_container_set_border_width(GTK_CONTAINER(frame25), 2); - gtk_frame_set_shadow_type(GTK_FRAME(frame25), GTK_SHADOW_OUT); + /* Create the control widgets */ + frame25 = gtk_frame_new(NULL); + gtk_container_add(GTK_CONTAINER(xs_subctrl), frame25); + gtk_container_set_border_width(GTK_CONTAINER(frame25), 2); + gtk_frame_set_shadow_type(GTK_FRAME(frame25), GTK_SHADOW_OUT); - hbox15 = gtk_hbox_new(FALSE, 4); - gtk_container_add(GTK_CONTAINER(frame25), hbox15); + hbox15 = gtk_hbox_new(FALSE, 4); + gtk_container_add(GTK_CONTAINER(frame25), hbox15); - subctrl_prev = gtk_button_new_with_label(" < "); - gtk_widget_set_name(subctrl_prev, "subctrl_prev"); - gtk_box_pack_start(GTK_BOX(hbox15), subctrl_prev, FALSE, FALSE, 0); + subctrl_prev = gtk_button_new_with_label(" < "); + gtk_widget_set_name(subctrl_prev, "subctrl_prev"); + gtk_box_pack_start(GTK_BOX(hbox15), subctrl_prev, FALSE, FALSE, 0); - xs_subctrl_adj = gtk_adjustment_new(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes, 1, 1, 0); - XS_SIGNAL_CONNECT(xs_subctrl_adj, "value_changed", xs_subctrl_setsong, NULL); + xs_subctrl_adj = gtk_adjustment_new(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes, 1, 1, 0); + XS_SIGNAL_CONNECT(xs_subctrl_adj, "value_changed", xs_subctrl_setsong, NULL); - subctrl_current = gtk_hscale_new(GTK_ADJUSTMENT(xs_subctrl_adj)); - gtk_widget_set_name(subctrl_current, "subctrl_current"); - gtk_box_pack_start(GTK_BOX(hbox15), subctrl_current, FALSE, TRUE, 0); - gtk_scale_set_digits(GTK_SCALE(subctrl_current), 0); - gtk_range_set_update_policy(GTK_RANGE(subctrl_current), GTK_UPDATE_DELAYED); - gtk_widget_grab_focus(subctrl_current); + subctrl_current = gtk_hscale_new(GTK_ADJUSTMENT(xs_subctrl_adj)); + gtk_widget_set_name(subctrl_current, "subctrl_current"); + gtk_box_pack_start(GTK_BOX(hbox15), subctrl_current, FALSE, TRUE, 0); + gtk_scale_set_digits(GTK_SCALE(subctrl_current), 0); + gtk_range_set_update_policy(GTK_RANGE(subctrl_current), GTK_UPDATE_DELAYED); + gtk_widget_grab_focus(subctrl_current); - subctrl_next = gtk_button_new_with_label(" > "); - gtk_widget_set_name(subctrl_next, "subctrl_next"); - gtk_box_pack_start(GTK_BOX(hbox15), subctrl_next, FALSE, FALSE, 0); + subctrl_next = gtk_button_new_with_label(" > "); + gtk_widget_set_name(subctrl_next, "subctrl_next"); + gtk_box_pack_start(GTK_BOX(hbox15), subctrl_next, FALSE, FALSE, 0); - XS_SIGNAL_CONNECT(subctrl_prev, "clicked", xs_subctrl_prevsong, NULL); - XS_SIGNAL_CONNECT(subctrl_next, "clicked", xs_subctrl_nextsong, NULL); - XS_SIGNAL_CONNECT(xs_subctrl, "key_press_event", xs_subctrl_keypress, NULL); + XS_SIGNAL_CONNECT(subctrl_prev, "clicked", xs_subctrl_prevsong, NULL); + XS_SIGNAL_CONNECT(subctrl_next, "clicked", xs_subctrl_nextsong, NULL); + XS_SIGNAL_CONNECT(xs_subctrl, "key_press_event", xs_subctrl_keypress, NULL); - gtk_widget_show_all(xs_subctrl); + gtk_widget_show_all(xs_subctrl); - XS_MUTEX_UNLOCK(xs_subctrl); + XS_MUTEX_UNLOCK(xs_subctrl); } @@ -848,39 +848,39 @@ */ void xs_seek(gint iTime) { - /* Check status */ - XS_MUTEX_LOCK(xs_status); - if (!xs_status.tuneInfo || !xs_status.isPlaying) { - XS_MUTEX_UNLOCK(xs_status); - return; - } + /* Check status */ + XS_MUTEX_LOCK(xs_status); + if (!xs_status.tuneInfo || !xs_status.isPlaying) { + XS_MUTEX_UNLOCK(xs_status); + return; + } - /* Act according to settings */ - switch (xs_cfg.subsongControl) { - case XS_SSC_SEEK: - if (iTime < xs_status.lastTime) { - if (xs_status.currSong > 1) - xs_status.currSong--; - } else if (iTime > xs_status.lastTime) { - if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) - xs_status.currSong++; - } - break; + /* Act according to settings */ + switch (xs_cfg.subsongControl) { + case XS_SSC_SEEK: + if (iTime < xs_status.lastTime) { + if (xs_status.currSong > 1) + xs_status.currSong--; + } else if (iTime > xs_status.lastTime) { + if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) + xs_status.currSong++; + } + break; - case XS_SSC_POPUP: - xs_subctrl_open(); - break; + case XS_SSC_POPUP: + xs_subctrl_open(); + break; - /* If we have song-position patch, check settings */ + /* If we have song-position patch, check settings */ #ifdef HAVE_SONG_POSITION - case XS_SSC_PATCH: - if ((iTime > 0) && (iTime <= xs_status.tuneInfo->nsubTunes)) - xs_status.currSong = iTime; - break; + case XS_SSC_PATCH: + if ((iTime > 0) && (iTime <= xs_status.tuneInfo->nsubTunes)) + xs_status.currSong = iTime; + break; #endif - } + } - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_status); } @@ -893,42 +893,42 @@ */ gint xs_get_time(void) { - /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ - XS_MUTEX_LOCK(xs_status); - if (xs_status.isError) { - XS_MUTEX_UNLOCK(xs_status); - return -2; - } + /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ + XS_MUTEX_LOCK(xs_status); + if (xs_status.isError) { + XS_MUTEX_UNLOCK(xs_status); + return -2; + } - /* If there is no tune, return -1 */ - if (!xs_status.tuneInfo) { - XS_MUTEX_UNLOCK(xs_status); - return -1; - } + /* If there is no tune, return -1 */ + if (!xs_status.tuneInfo) { + XS_MUTEX_UNLOCK(xs_status); + return -1; + } - /* If tune has ended, return -1 */ - if (!xs_status.isPlaying) { - XS_MUTEX_UNLOCK(xs_status); - return -1; - } + /* If tune has ended, return -1 */ + if (!xs_status.isPlaying) { + XS_MUTEX_UNLOCK(xs_status); + return -1; + } - /* Let's see what we do */ - switch (xs_cfg.subsongControl) { - case XS_SSC_SEEK: - xs_status.lastTime = (xs_plugin_ip.output->output_time() / 1000); - break; + /* Let's see what we do */ + switch (xs_cfg.subsongControl) { + case XS_SSC_SEEK: + xs_status.lastTime = (xs_plugin_ip.output->output_time() / 1000); + break; #ifdef HAVE_SONG_POSITION - case XS_SSC_PATCH: - set_song_position(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes); - break; + case XS_SSC_PATCH: + set_song_position(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes); + break; #endif - } + } - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_status); - /* Return output time reported by audio output plugin */ - return xs_plugin_ip.output->output_time(); + /* Return output time reported by audio output plugin */ + return xs_plugin_ip.output->output_time(); } @@ -938,32 +938,32 @@ */ void xs_get_song_info(gchar * songFilename, gchar ** songTitle, gint * songLength) { - xs_tuneinfo_t *pInfo; - - XS_MUTEX_LOCK(xs_status); + xs_tuneinfo_t *pInfo; + + XS_MUTEX_LOCK(xs_status); - /* Get tune information from emulation engine */ - pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename); - if (!pInfo) { - XS_MUTEX_UNLOCK(xs_status); - return; - } + /* Get tune information from emulation engine */ + pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename); + if (!pInfo) { + XS_MUTEX_UNLOCK(xs_status); + return; + } - /* Get sub-tune information, if available */ - if ((pInfo->startTune > 0) && (pInfo->startTune <= pInfo->nsubTunes)) { - gint tmpInt; - - (*songTitle) = xs_make_titlestring(pInfo, pInfo->startTune); + /* Get sub-tune information, if available */ + if ((pInfo->startTune > 0) && (pInfo->startTune <= pInfo->nsubTunes)) { + gint tmpInt; + + (*songTitle) = xs_make_titlestring(pInfo, pInfo->startTune); - tmpInt = pInfo->subTunes[pInfo->startTune-1].tuneLength; - if (tmpInt < 0) - (*songLength) = -1; - else - (*songLength) = (tmpInt * 1000); - } + tmpInt = pInfo->subTunes[pInfo->startTune-1].tuneLength; + if (tmpInt < 0) + (*songLength) = -1; + else + (*songLength) = (tmpInt * 1000); + } - /* Free tune information */ - xs_tuneinfo_free(pInfo); - XS_MUTEX_UNLOCK(xs_status); + /* Free tune information */ + xs_tuneinfo_free(pInfo); + XS_MUTEX_UNLOCK(xs_status); } diff -r 04ea91a61225 -r b0743dc9165d src/xmms-sid.h --- a/src/xmms-sid.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xmms-sid.h Wed Apr 02 22:10:05 2008 +0300 @@ -54,7 +54,7 @@ #undef HAVE_HARDSID_BUILDER /* Size for some small buffers (always static variables) */ -#define XS_BUF_SIZE (1024) +#define XS_BUF_SIZE (1024) /* If defined, some dynamically allocated temp. buffers are used. * Static (#undef) might give slight performance gain, @@ -63,130 +63,130 @@ /* Configuration section identifier */ -#define XS_PACKAGE_STRING PACKAGE_STRING -#define XS_CONFIG_IDENT "XMMS-SID" +#define XS_PACKAGE_STRING PACKAGE_STRING +#define XS_CONFIG_IDENT "XMMS-SID" /* Default audio rendering frequency in Hz */ -#define XS_AUDIO_FREQ (44100) +#define XS_AUDIO_FREQ (44100) /* Size of audio buffer. If you are experiencing lots of audio * "underruns" or clicks/gaps in output, try increasing this value. * Do notice, however, that it also affects the update frequency of * XMMS's visualization plugins... */ -#define XS_AUDIOBUF_SIZE (2*1024) +#define XS_AUDIOBUF_SIZE (2*1024) /* Size of data buffer used for SID-tune MD5 hash calculation. * If this is too small, the computed hash will be incorrect. * Largest SID files I've seen are ~70kB. */ -#define XS_SIDBUF_SIZE (80*1024) +#define XS_SIDBUF_SIZE (80*1024) /* libSIDPlay1/2 constants (copied from internal headers/source) * For some stupid reason these are not available in public * headers, so we have to duplicate them here... */ -#define XS_SIDPLAY1_FS (400.0f) -#define XS_SIDPLAY1_FM (60.0f) -#define XS_SIDPLAY1_FT (0.05f) +#define XS_SIDPLAY1_FS (400.0f) +#define XS_SIDPLAY1_FM (60.0f) +#define XS_SIDPLAY1_FT (0.05f) -#define XS_SIDPLAY2_NFPOINTS (0x800) -#define XS_SIDPLAY2_FMAX (24000) +#define XS_SIDPLAY2_NFPOINTS (0x800) +#define XS_SIDPLAY2_FMAX (24000) /* Limits for oversampling */ -#define XS_MIN_OVERSAMPLE (2) -#define XS_MAX_OVERSAMPLE (8) +#define XS_MIN_OVERSAMPLE (2) +#define XS_MAX_OVERSAMPLE (8) /* Macros for mutexes and threads. These exist to be able to * easily change from pthreads to glib threads, etc, if necessary. */ -#define XS_THREAD_T pthread_t -#define XS_THREAD_EXIT(M) pthread_exit(M) -#define XS_THREAD_JOIN(M) pthread_join(M, NULL) -#define XS_MPP(M) M ## _mutex +#define XS_THREAD_T pthread_t +#define XS_THREAD_EXIT(M) pthread_exit(M) +#define XS_THREAD_JOIN(M) pthread_join(M, NULL) +#define XS_MPP(M) M ## _mutex #ifdef XS_MUTEX_DEBUG # ifndef __USE_GNU # define __USE_GNU # endif -# define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; gint M ## _qq -# define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M); extern gint M ## _qq -# define XS_MUTEX_LOCK(M) { M ## _qq = pthread_mutex_lock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_LOCK(" #M ") == %i\n", M ## _qq); } -# define XS_MUTEX_UNLOCK(M) { M ## _qq = pthread_mutex_unlock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_UNLOCK(" #M ") == %i\n", M ## _qq); } +# define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; gint M ## _qq +# define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M); extern gint M ## _qq +# define XS_MUTEX_LOCK(M) { M ## _qq = pthread_mutex_lock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_LOCK(" #M ") == %i\n", M ## _qq); } +# define XS_MUTEX_UNLOCK(M) { M ## _qq = pthread_mutex_unlock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_UNLOCK(" #M ") == %i\n", M ## _qq); } #else -# define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER -# define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M) -# define XS_MUTEX_LOCK(M) pthread_mutex_lock(&XS_MPP(M)) -# define XS_MUTEX_UNLOCK(M) pthread_mutex_unlock(&XS_MPP(M)) +# define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER +# define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M) +# define XS_MUTEX_LOCK(M) pthread_mutex_lock(&XS_MPP(M)) +# define XS_MUTEX_UNLOCK(M) pthread_mutex_unlock(&XS_MPP(M)) #endif #include /* Character set conversion helper macros */ -#define XS_CS_FILENAME(M) g_strdup(M) -#define XS_CS_SID(M) g_strdup(M) -#define XS_CS_STIL(M) M +#define XS_CS_FILENAME(M) g_strdup(M) +#define XS_CS_SID(M) g_strdup(M) +#define XS_CS_STIL(M) M #define XS_CS_FREE(M) /* Shorthands for linked lists */ -#define LPREV (node->prev) -#define LTHIS (node) -#define LNEXT (node->next) +#define LPREV (node->prev) +#define LTHIS (node) +#define LNEXT (node->next) /* Plugin-wide typedefs */ typedef struct { - gint tuneSpeed, - tuneLength; - gboolean tunePlayed; + gint tuneSpeed, + tuneLength; + gboolean tunePlayed; } xs_subtuneinfo_t; typedef struct { - gchar *sidFilename, - *sidName, - *sidComposer, - *sidCopyright, - *sidFormat; - gint loadAddr, - initAddr, - playAddr, - dataFileLen, - sidModel; - gint nsubTunes, startTune; - xs_subtuneinfo_t *subTunes; + gchar *sidFilename, + *sidName, + *sidComposer, + *sidCopyright, + *sidFormat; + gint loadAddr, + initAddr, + playAddr, + dataFileLen, + sidModel; + gint nsubTunes, startTune; + xs_subtuneinfo_t *subTunes; } xs_tuneinfo_t; /* Global variables */ -extern InputPlugin xs_plugin_ip; +extern InputPlugin xs_plugin_ip; /* Plugin function prototypes */ -void xs_init(void); -void xs_reinit(void); -void xs_close(void); -gint xs_is_our_file(gchar *); -void xs_play_file(gchar *); -void xs_stop(void); -void xs_pause(short); -void xs_seek(gint); -gint xs_get_time(void); -void xs_get_song_info(gchar *, gchar **, gint *); -void xs_about(void); +void xs_init(void); +void xs_reinit(void); +void xs_close(void); +gint xs_is_our_file(gchar *); +void xs_play_file(gchar *); +void xs_stop(void); +void xs_pause(short); +void xs_seek(gint); +gint xs_get_time(void); +void xs_get_song_info(gchar *, gchar **, gint *); +void xs_about(void); -void xs_error(const char *, ...); +void xs_error(const char *, ...); /* Debugging */ #ifndef DEBUG_NP -void XSDEBUG(const char *, ...); +void XSDEBUG(const char *, ...); #else # ifdef DEBUG # define XSDEBUG(...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); } @@ -198,25 +198,25 @@ /* And even some Gtk+ macro crap here, yay. */ -#define XS_DEF_WINDOW_DELETE(ME, MV) \ -gboolean xs_ ## ME ## _delete(GtkWidget *w, GdkEvent *e, gpointer d) { \ - (void) w; (void) e; (void) d; \ - if (xs_ ## MV ) { \ - gtk_widget_destroy(xs_ ## MV ); \ - xs_ ## MV = NULL; \ - } \ - return FALSE; \ +#define XS_DEF_WINDOW_DELETE(ME, MV) \ +gboolean xs_ ## ME ## _delete(GtkWidget *w, GdkEvent *e, gpointer d) { \ + (void) w; (void) e; (void) d; \ + if (xs_ ## MV ) { \ + gtk_widget_destroy(xs_ ## MV ); \ + xs_ ## MV = NULL; \ + } \ + return FALSE; \ } -#define XS_DEF_WINDOW_CLOSE(ME, MV) \ -void xs_ ## ME (GtkButton *b, gpointer d) { \ - (void) b; (void) d; \ - gtk_widget_destroy(xs_ ## MV ); \ - xs_ ## MV = NULL; \ +#define XS_DEF_WINDOW_CLOSE(ME, MV) \ +void xs_ ## ME (GtkButton *b, gpointer d) { \ + (void) b; (void) d; \ + gtk_widget_destroy(xs_ ## MV ); \ + xs_ ## MV = NULL; \ } -#define XS_SIGNAL_CONNECT(SOBJ, SNAME, SFUNC, SDATA) \ - gtk_signal_connect(GTK_OBJECT(SOBJ), SNAME, GTK_SIGNAL_FUNC(SFUNC), SDATA) +#define XS_SIGNAL_CONNECT(SOBJ, SNAME, SFUNC, SDATA) \ + gtk_signal_connect(GTK_OBJECT(SOBJ), SNAME, GTK_SIGNAL_FUNC(SFUNC), SDATA) #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_about.c --- a/src/xs_about.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_about.c Wed Apr 02 22:10:05 2008 +0300 @@ -37,16 +37,16 @@ */ gint xs_about_theme(void) { - const gint iSession = 0; /* Assume session 0 */ - gint iPos; + const gint iSession = 0; /* Assume session 0 */ + gint iPos; - /* Stop current song, add theme to playlist, play. */ - xmms_remote_stop(iSession); - iPos = xmms_remote_get_playlist_length(iSession); - xmms_remote_playlist_add_url_string(iSession, THEMETUNE_FILE); - xmms_remote_set_playlist_pos(iSession, iPos); - xmms_remote_play(iSession); - return 0; + /* Stop current song, add theme to playlist, play. */ + xmms_remote_stop(iSession); + iPos = xmms_remote_get_playlist_length(iSession); + xmms_remote_playlist_add_url_string(iSession, THEMETUNE_FILE); + xmms_remote_set_playlist_pos(iSession, iPos); + xmms_remote_play(iSession); + return 0; } #endif @@ -60,164 +60,164 @@ */ void xs_about(void) { - GtkWidget *about_vbox1; - GtkWidget *about_frame; - GtkWidget *about_logo; - GdkPixmap *about_logo_pixmap = NULL, *about_logo_mask = NULL; - GtkWidget *about_scrwin; - GtkWidget *about_text; - GtkWidget *alignment6; - GtkWidget *about_close; - gchar tmpStr[64]; + GtkWidget *about_vbox1; + GtkWidget *about_frame; + GtkWidget *about_logo; + GdkPixmap *about_logo_pixmap = NULL, *about_logo_mask = NULL; + GtkWidget *about_scrwin; + GtkWidget *about_text; + GtkWidget *alignment6; + GtkWidget *about_close; + gchar tmpStr[64]; - /* Check if there already is an open about window */ - if (xs_aboutwin != NULL) { - gdk_window_raise(xs_aboutwin->window); - return; - } + /* Check if there already is an open about window */ + if (xs_aboutwin != NULL) { + gdk_window_raise(xs_aboutwin->window); + return; + } - /* No, create one ... */ - xs_aboutwin = gtk_window_new(GTK_WINDOW_DIALOG); - gtk_widget_set_name(xs_aboutwin, "xs_aboutwin"); - gtk_object_set_data(GTK_OBJECT(xs_aboutwin), "xs_aboutwin", xs_aboutwin); - g_snprintf(tmpStr, sizeof(tmpStr), _("About %s"), XS_PACKAGE_STRING); - gtk_window_set_title(GTK_WINDOW(xs_aboutwin), tmpStr); - gtk_window_set_default_size(GTK_WINDOW(xs_aboutwin), 350, -1); + /* No, create one ... */ + xs_aboutwin = gtk_window_new(GTK_WINDOW_DIALOG); + gtk_widget_set_name(xs_aboutwin, "xs_aboutwin"); + gtk_object_set_data(GTK_OBJECT(xs_aboutwin), "xs_aboutwin", xs_aboutwin); + g_snprintf(tmpStr, sizeof(tmpStr), _("About %s"), XS_PACKAGE_STRING); + gtk_window_set_title(GTK_WINDOW(xs_aboutwin), tmpStr); + gtk_window_set_default_size(GTK_WINDOW(xs_aboutwin), 350, -1); - XS_SIGNAL_CONNECT(xs_aboutwin, "delete_event", xs_about_delete, NULL); + XS_SIGNAL_CONNECT(xs_aboutwin, "delete_event", xs_about_delete, NULL); - about_vbox1 = gtk_vbox_new(FALSE, 0); - gtk_widget_set_name(about_vbox1, "about_vbox1"); - gtk_widget_ref(about_vbox1); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_vbox1", about_vbox1, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(about_vbox1); - gtk_container_add(GTK_CONTAINER(xs_aboutwin), about_vbox1); + about_vbox1 = gtk_vbox_new(FALSE, 0); + gtk_widget_set_name(about_vbox1, "about_vbox1"); + gtk_widget_ref(about_vbox1); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_vbox1", about_vbox1, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(about_vbox1); + gtk_container_add(GTK_CONTAINER(xs_aboutwin), about_vbox1); #ifdef HAVE_THEMETUNE - about_frame = gtk_button_new(); + about_frame = gtk_button_new(); #else - about_frame = gtk_frame_new(NULL); + about_frame = gtk_frame_new(NULL); #endif - gtk_widget_set_name(about_frame, "about_frame"); - gtk_widget_ref(about_frame); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_frame", about_frame, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(about_frame); - gtk_box_pack_start(GTK_BOX(about_vbox1), about_frame, FALSE, FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(about_frame), 4); + gtk_widget_set_name(about_frame, "about_frame"); + gtk_widget_ref(about_frame); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_frame", about_frame, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(about_frame); + gtk_box_pack_start(GTK_BOX(about_vbox1), about_frame, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(about_frame), 4); #ifdef HAVE_THEMETUNE - gtk_signal_connect(GTK_OBJECT(about_frame), "clicked", GTK_SIGNAL_FUNC(xs_about_theme), NULL); + gtk_signal_connect(GTK_OBJECT(about_frame), "clicked", GTK_SIGNAL_FUNC(xs_about_theme), NULL); #else - gtk_frame_set_shadow_type(GTK_FRAME(about_frame), GTK_SHADOW_OUT); + gtk_frame_set_shadow_type(GTK_FRAME(about_frame), GTK_SHADOW_OUT); #endif - /* Create the Gdk data for logo pixmap */ - gtk_widget_realize(xs_aboutwin); - about_logo_pixmap = gdk_pixmap_create_from_xpm_d( - xs_aboutwin->window, &about_logo_mask, - NULL, (gchar **) xmms_sid_logo_xpm); + /* Create the Gdk data for logo pixmap */ + gtk_widget_realize(xs_aboutwin); + about_logo_pixmap = gdk_pixmap_create_from_xpm_d( + xs_aboutwin->window, &about_logo_mask, + NULL, (gchar **) xmms_sid_logo_xpm); - about_logo = gtk_pixmap_new(about_logo_pixmap, about_logo_mask); + about_logo = gtk_pixmap_new(about_logo_pixmap, about_logo_mask); - /* Create logo widget */ - gtk_widget_set_name(about_logo, "about_logo"); - gtk_widget_ref(about_logo); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_logo", about_logo, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(about_logo); - gtk_container_add(GTK_CONTAINER(about_frame), about_logo); - gtk_misc_set_padding(GTK_MISC(about_logo), 0, 6); + /* Create logo widget */ + gtk_widget_set_name(about_logo, "about_logo"); + gtk_widget_ref(about_logo); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_logo", about_logo, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(about_logo); + gtk_container_add(GTK_CONTAINER(about_frame), about_logo); + gtk_misc_set_padding(GTK_MISC(about_logo), 0, 6); - about_scrwin = gtk_scrolled_window_new(NULL, NULL); - gtk_widget_set_name(about_scrwin, "about_scrwin"); - gtk_widget_ref(about_scrwin); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_scrwin", about_scrwin, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(about_scrwin); - gtk_box_pack_start(GTK_BOX(about_vbox1), about_scrwin, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(about_scrwin), 8); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(about_scrwin), - GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); + about_scrwin = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_set_name(about_scrwin, "about_scrwin"); + gtk_widget_ref(about_scrwin); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_scrwin", about_scrwin, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(about_scrwin); + gtk_box_pack_start(GTK_BOX(about_vbox1), about_scrwin, TRUE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(about_scrwin), 8); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(about_scrwin), + GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - about_text = gtk_text_new(NULL, NULL); - gtk_widget_set_name(about_text, "about_text"); - gtk_widget_ref(about_text); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_text", about_text, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(about_text); - gtk_container_add(GTK_CONTAINER(about_scrwin), about_text); - gtk_widget_set_usize(about_text, -2, 100); - gtk_text_insert(GTK_TEXT(about_text), NULL, NULL, NULL, - "\n" - "This release of XMMS-SID is dedicated to\n" - " Richard Joseph\n" - " and\n" - " Lauri Sipilä (aka Xaztur/PWP)\n" - " - Now gone, but forever in our hearts -\n" - "\n" - "\n" - "(C) Copyright 1999-2008\n" - "\tTecnic Software productions (TNSP)\n" - "\n" - "Programming and design\n" - "\tMatti 'ccr' Hämäläinen\n" - "\n" + about_text = gtk_text_new(NULL, NULL); + gtk_widget_set_name(about_text, "about_text"); + gtk_widget_ref(about_text); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_text", about_text, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(about_text); + gtk_container_add(GTK_CONTAINER(about_scrwin), about_text); + gtk_widget_set_usize(about_text, -2, 100); + gtk_text_insert(GTK_TEXT(about_text), NULL, NULL, NULL, + "\n" + "This release of XMMS-SID is dedicated to\n" + " Richard Joseph\n" + " and\n" + " Lauri Sipilä (aka Xaztur/PWP)\n" + " - Now gone, but forever in our hearts -\n" + "\n" + "\n" + "(C) Copyright 1999-2008\n" + "\tTecnic Software productions (TNSP)\n" + "\n" + "Programming and design\n" + "\tMatti 'ccr' Hämäläinen\n" + "\n" #ifdef HAVE_SIDPLAY1 - "libSIDPlay1 created by\n" - "\tMichael Schwendt\n" "\n" + "libSIDPlay1 created by\n" + "\tMichael Schwendt\n" "\n" #endif #ifdef HAVE_SIDPLAY2 - "libSIDPlay2 and reSID created by\n" - "\tSimon White, Dag Lem,\n" - "\tMichael Schwendt and rest.\n" - "\n" + "libSIDPlay2 and reSID created by\n" + "\tSimon White, Dag Lem,\n" + "\tMichael Schwendt and rest.\n" + "\n" #endif #ifdef HAVE_THEMETUNE - "\"Kummatti City\", theme of XMMS-SID 0.8\n" - "\tby Ari 'Agemixer' Yliaho\n" - "\t(C) Copyright 1998 Scallop\n" - "\t(Refer to README for license)\n" "\n" + "\"Kummatti City\", theme of XMMS-SID 0.8\n" + "\tby Ari 'Agemixer' Yliaho\n" + "\t(C) Copyright 1998 Scallop\n" + "\t(Refer to README for license)\n" "\n" #endif - "Original XMMS-SID (v0.4) by\n" "\tWillem Monsuwe\n" "\n" + "Original XMMS-SID (v0.4) by\n" "\tWillem Monsuwe\n" "\n" - "Greetings fly out to ...\n" - "\tEveryone at #Linux.Fi, #Fireball,\n" - "\t#TNSP and #c-64 of IRCNet, #xmms\n" - "\tof Freenode.net.\n" - "\n" - "\tDekadence, PWP, Byterapers,\n" - "\tmfx, Unique, Fairlight, iSO,\n" - "\tWrath Designs, Padua, Extend,\n" - "\tPHn, Creators, Cosine, tAAt,\n" - "\tViruz, Crest and Skalaria.\n" "\n" + "Greetings fly out to ...\n" + "\tEveryone at #Linux.Fi, #Fireball,\n" + "\t#TNSP and #c-64 of IRCNet, #xmms\n" + "\tof Freenode.net.\n" + "\n" + "\tDekadence, PWP, Byterapers,\n" + "\tmfx, Unique, Fairlight, iSO,\n" + "\tWrath Designs, Padua, Extend,\n" + "\tPHn, Creators, Cosine, tAAt,\n" + "\tViruz, Crest and Skalaria.\n" "\n" - "Special thanks\n" - "\tGerfried 'Alfie' Fuchs\n" - "\tAndreas 'mrsid' Varga\n" - "\tAll the betatesters.\n" - "\tAll the users!\n", -1); + "Special thanks\n" + "\tGerfried 'Alfie' Fuchs\n" + "\tAndreas 'mrsid' Varga\n" + "\tAll the betatesters.\n" + "\tAll the users!\n", -1); - alignment6 = gtk_alignment_new(0.5, 0.5, 0.18, 1); - gtk_widget_set_name(alignment6, "alignment6"); - gtk_widget_ref(alignment6); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "alignment6", alignment6, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(alignment6); - gtk_box_pack_start(GTK_BOX(about_vbox1), alignment6, FALSE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(alignment6), 8); + alignment6 = gtk_alignment_new(0.5, 0.5, 0.18, 1); + gtk_widget_set_name(alignment6, "alignment6"); + gtk_widget_ref(alignment6); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "alignment6", alignment6, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(alignment6); + gtk_box_pack_start(GTK_BOX(about_vbox1), alignment6, FALSE, TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(alignment6), 8); - about_close = gtk_button_new_with_label(_("Close")); - gtk_widget_set_name(about_close, "about_close"); - gtk_widget_ref(about_close); - gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_close", about_close, - (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(about_close); - gtk_container_add(GTK_CONTAINER(alignment6), about_close); - GTK_WIDGET_SET_FLAGS(about_close, GTK_CAN_DEFAULT); + about_close = gtk_button_new_with_label(_("Close")); + gtk_widget_set_name(about_close, "about_close"); + gtk_widget_ref(about_close); + gtk_object_set_data_full(GTK_OBJECT(xs_aboutwin), "about_close", about_close, + (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(about_close); + gtk_container_add(GTK_CONTAINER(alignment6), about_close); + GTK_WIDGET_SET_FLAGS(about_close, GTK_CAN_DEFAULT); - XS_SIGNAL_CONNECT(about_close, "clicked", xs_about_ok, NULL); + XS_SIGNAL_CONNECT(about_close, "clicked", xs_about_ok, NULL); - gtk_widget_show(xs_aboutwin); + gtk_widget_show(xs_aboutwin); } diff -r 04ea91a61225 -r b0743dc9165d src/xs_config.c --- a/src/xs_config.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_config.c Wed Apr 02 22:10:05 2008 +0300 @@ -24,32 +24,32 @@ #ifdef AUDACIOUS_PLUGIN #include -#define XS_CONFIG_FILE ConfigDb -#define XS_CONFIG_OPEN aud_cfg_db_open -#define XS_CONFIG_FREE aud_cfg_db_close +#define XS_CONFIG_FILE ConfigDb +#define XS_CONFIG_OPEN aud_cfg_db_open +#define XS_CONFIG_FREE aud_cfg_db_close -#define XS_CFG_SET_STRING aud_cfg_db_set_string -#define XS_CFG_SET_FLOAT aud_cfg_db_set_float -#define XS_CFG_SET_INT aud_cfg_db_set_int -#define XS_CFG_SET_BOOL aud_cfg_db_set_bool -#define XS_CFG_GET_STRING aud_cfg_db_get_string -#define XS_CFG_GET_FLOAT aud_cfg_db_get_float -#define XS_CFG_GET_INT aud_cfg_db_get_int -#define XS_CFG_GET_BOOL aud_cfg_db_get_bool +#define XS_CFG_SET_STRING aud_cfg_db_set_string +#define XS_CFG_SET_FLOAT aud_cfg_db_set_float +#define XS_CFG_SET_INT aud_cfg_db_set_int +#define XS_CFG_SET_BOOL aud_cfg_db_set_bool +#define XS_CFG_GET_STRING aud_cfg_db_get_string +#define XS_CFG_GET_FLOAT aud_cfg_db_get_float +#define XS_CFG_GET_INT aud_cfg_db_get_int +#define XS_CFG_GET_BOOL aud_cfg_db_get_bool #else #include -#define XS_CONFIG_FILE ConfigFile -#define XS_CONFIG_OPEN xmms_cfg_open_default_file -#define XS_CONFIG_FREE xmms_cfg_free +#define XS_CONFIG_FILE ConfigFile +#define XS_CONFIG_OPEN xmms_cfg_open_default_file +#define XS_CONFIG_FREE xmms_cfg_free -#define XS_CFG_SET_STRING xmms_cfg_write_string -#define XS_CFG_SET_FLOAT xmms_cfg_write_float -#define XS_CFG_SET_INT xmms_cfg_write_int -#define XS_CFG_SET_BOOL xmms_cfg_write_boolean -#define XS_CFG_GET_STRING xmms_cfg_read_string -#define XS_CFG_GET_FLOAT xmms_cfg_read_float -#define XS_CFG_GET_INT xmms_cfg_read_int -#define XS_CFG_GET_BOOL xmms_cfg_read_boolean +#define XS_CFG_SET_STRING xmms_cfg_write_string +#define XS_CFG_SET_FLOAT xmms_cfg_write_float +#define XS_CFG_SET_INT xmms_cfg_write_int +#define XS_CFG_SET_BOOL xmms_cfg_write_boolean +#define XS_CFG_GET_STRING xmms_cfg_read_string +#define XS_CFG_GET_FLOAT xmms_cfg_read_float +#define XS_CFG_GET_INT xmms_cfg_read_int +#define XS_CFG_GET_BOOL xmms_cfg_read_boolean #endif #include #include @@ -62,20 +62,20 @@ * Global widgets */ static GtkWidget *xs_configwin = NULL, - *xs_sldb_fileselector = NULL, - *xs_stil_fileselector = NULL, - *xs_hvsc_selector = NULL, - *xs_filt_importselector = NULL, - *xs_filt_exportselector = NULL; + *xs_sldb_fileselector = NULL, + *xs_stil_fileselector = NULL, + *xs_hvsc_selector = NULL, + *xs_filt_importselector = NULL, + *xs_filt_exportselector = NULL; -#define LUW(x) lookup_widget(xs_configwin, x) +#define LUW(x) lookup_widget(xs_configwin, x) /* Samplerates */ static const gchar *xs_samplerates_table[] = { - "8000", "11025", "22050", - "44100", "48000", "64000", - "96000" + "8000", "11025", "22050", + "44100", "48000", "64000", + "96000" }; static const gint xs_nsamplerates_table = (sizeof(xs_samplerates_table) / sizeof(xs_samplerates_table[0])); @@ -87,116 +87,116 @@ struct t_xs_cfg xs_cfg; static t_xs_cfg_item xs_cfgtable[] = { -{ CTYPE_INT, &xs_cfg.audioBitsPerSample, "audioBitsPerSample" }, -{ CTYPE_INT, &xs_cfg.audioChannels, "audioChannels" }, -{ CTYPE_INT, &xs_cfg.audioFrequency, "audioFrequency" }, +{ CTYPE_INT, &xs_cfg.audioBitsPerSample, "audioBitsPerSample" }, +{ CTYPE_INT, &xs_cfg.audioChannels, "audioChannels" }, +{ CTYPE_INT, &xs_cfg.audioFrequency, "audioFrequency" }, -{ CTYPE_BOOL, &xs_cfg.mos8580, "mos8580" }, -{ CTYPE_BOOL, &xs_cfg.forceModel, "forceModel" }, -{ CTYPE_BOOL, &xs_cfg.emulateFilters, "emulateFilters" }, -{ CTYPE_FLOAT, &xs_cfg.sid1FilterFs, "filterFs" }, -{ CTYPE_FLOAT, &xs_cfg.sid1FilterFm, "filterFm" }, -{ CTYPE_FLOAT, &xs_cfg.sid1FilterFt, "filterFt" }, -{ CTYPE_INT, &xs_cfg.memoryMode, "memoryMode" }, -{ CTYPE_INT, &xs_cfg.clockSpeed, "clockSpeed" }, -{ CTYPE_BOOL, &xs_cfg.forceSpeed, "forceSpeed" }, +{ CTYPE_BOOL, &xs_cfg.mos8580, "mos8580" }, +{ CTYPE_BOOL, &xs_cfg.forceModel, "forceModel" }, +{ CTYPE_BOOL, &xs_cfg.emulateFilters, "emulateFilters" }, +{ CTYPE_FLOAT, &xs_cfg.sid1FilterFs, "filterFs" }, +{ CTYPE_FLOAT, &xs_cfg.sid1FilterFm, "filterFm" }, +{ CTYPE_FLOAT, &xs_cfg.sid1FilterFt, "filterFt" }, +{ CTYPE_INT, &xs_cfg.memoryMode, "memoryMode" }, +{ CTYPE_INT, &xs_cfg.clockSpeed, "clockSpeed" }, +{ CTYPE_BOOL, &xs_cfg.forceSpeed, "forceSpeed" }, -{ CTYPE_INT, &xs_cfg.playerEngine, "playerEngine" }, +{ CTYPE_INT, &xs_cfg.playerEngine, "playerEngine" }, -{ CTYPE_INT, &xs_cfg.sid2Builder, "sid2Builder" }, -{ CTYPE_INT, &xs_cfg.sid2OptLevel, "sid2OptLevel" }, -{ CTYPE_INT, &xs_cfg.sid2NFilterPresets, "sid2NFilterPresets" }, +{ CTYPE_INT, &xs_cfg.sid2Builder, "sid2Builder" }, +{ CTYPE_INT, &xs_cfg.sid2OptLevel, "sid2OptLevel" }, +{ CTYPE_INT, &xs_cfg.sid2NFilterPresets, "sid2NFilterPresets" }, -{ CTYPE_BOOL, &xs_cfg.oversampleEnable, "oversampleEnable" }, -{ CTYPE_INT, &xs_cfg.oversampleFactor, "oversampleFactor" }, +{ CTYPE_BOOL, &xs_cfg.oversampleEnable, "oversampleEnable" }, +{ CTYPE_INT, &xs_cfg.oversampleFactor, "oversampleFactor" }, -{ CTYPE_BOOL, &xs_cfg.playMaxTimeEnable, "playMaxTimeEnable" }, -{ CTYPE_BOOL, &xs_cfg.playMaxTimeUnknown, "playMaxTimeUnknown" }, -{ CTYPE_INT, &xs_cfg.playMaxTime, "playMaxTime" }, -{ CTYPE_BOOL, &xs_cfg.playMinTimeEnable, "playMinTimeEnable" }, -{ CTYPE_INT, &xs_cfg.playMinTime, "playMinTime" }, -{ CTYPE_BOOL, &xs_cfg.songlenDBEnable, "songlenDBEnable" }, -{ CTYPE_STR, &xs_cfg.songlenDBPath, "songlenDBPath" }, +{ CTYPE_BOOL, &xs_cfg.playMaxTimeEnable, "playMaxTimeEnable" }, +{ CTYPE_BOOL, &xs_cfg.playMaxTimeUnknown, "playMaxTimeUnknown" }, +{ CTYPE_INT, &xs_cfg.playMaxTime, "playMaxTime" }, +{ CTYPE_BOOL, &xs_cfg.playMinTimeEnable, "playMinTimeEnable" }, +{ CTYPE_INT, &xs_cfg.playMinTime, "playMinTime" }, +{ CTYPE_BOOL, &xs_cfg.songlenDBEnable, "songlenDBEnable" }, +{ CTYPE_STR, &xs_cfg.songlenDBPath, "songlenDBPath" }, -{ CTYPE_BOOL, &xs_cfg.stilDBEnable, "stilDBEnable" }, -{ CTYPE_STR, &xs_cfg.stilDBPath, "stilDBPath" }, -{ CTYPE_STR, &xs_cfg.hvscPath, "hvscPath" }, +{ CTYPE_BOOL, &xs_cfg.stilDBEnable, "stilDBEnable" }, +{ CTYPE_STR, &xs_cfg.stilDBPath, "stilDBPath" }, +{ CTYPE_STR, &xs_cfg.hvscPath, "hvscPath" }, #ifndef AUDACIOUS_PLUGIN -{ CTYPE_INT, &xs_cfg.subsongControl, "subsongControl" }, -{ CTYPE_BOOL, &xs_cfg.detectMagic, "detectMagic" }, +{ CTYPE_INT, &xs_cfg.subsongControl, "subsongControl" }, +{ CTYPE_BOOL, &xs_cfg.detectMagic, "detectMagic" }, #endif -{ CTYPE_BOOL, &xs_cfg.titleOverride, "titleOverride" }, -{ CTYPE_STR, &xs_cfg.titleFormat, "titleFormat" }, +{ CTYPE_BOOL, &xs_cfg.titleOverride, "titleOverride" }, +{ CTYPE_STR, &xs_cfg.titleFormat, "titleFormat" }, -{ CTYPE_BOOL, &xs_cfg.subAutoEnable, "subAutoEnable" }, -{ CTYPE_BOOL, &xs_cfg.subAutoMinOnly, "subAutoMinOnly" }, -{ CTYPE_INT, &xs_cfg.subAutoMinTime, "subAutoMinTime" }, +{ CTYPE_BOOL, &xs_cfg.subAutoEnable, "subAutoEnable" }, +{ CTYPE_BOOL, &xs_cfg.subAutoMinOnly, "subAutoMinOnly" }, +{ CTYPE_INT, &xs_cfg.subAutoMinTime, "subAutoMinTime" }, }; static const gint xs_cfgtable_max = (sizeof(xs_cfgtable) / sizeof(t_xs_cfg_item)); static t_xs_wid_item xs_widtable[] = { -{ WTYPE_BGROUP, CTYPE_INT, "cfg_res_16bit", &xs_cfg.audioBitsPerSample, XS_RES_16BIT }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_res_8bit", &xs_cfg.audioBitsPerSample, XS_RES_8BIT }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_chn_mono", &xs_cfg.audioChannels, XS_CHN_MONO }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_chn_stereo", &xs_cfg.audioChannels, XS_CHN_STEREO }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_chn_autopan", &xs_cfg.audioChannels, XS_CHN_AUTOPAN }, -{ WTYPE_COMBO, CTYPE_INT, "cfg_samplerate", &xs_cfg.audioFrequency, XS_AUDIO_FREQ }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_oversample", &xs_cfg.oversampleEnable, 0 }, -{ WTYPE_SPIN, CTYPE_INT, "cfg_oversample_factor",&xs_cfg.oversampleFactor, 0 }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_res_16bit", &xs_cfg.audioBitsPerSample, XS_RES_16BIT }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_res_8bit", &xs_cfg.audioBitsPerSample, XS_RES_8BIT }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_chn_mono", &xs_cfg.audioChannels, XS_CHN_MONO }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_chn_stereo", &xs_cfg.audioChannels, XS_CHN_STEREO }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_chn_autopan", &xs_cfg.audioChannels, XS_CHN_AUTOPAN }, +{ WTYPE_COMBO, CTYPE_INT, "cfg_samplerate", &xs_cfg.audioFrequency, XS_AUDIO_FREQ }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_oversample", &xs_cfg.oversampleEnable, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_oversample_factor",&xs_cfg.oversampleFactor, 0 }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sidplay1", &xs_cfg.playerEngine, XS_ENG_SIDPLAY1 }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sidplay2", &xs_cfg.playerEngine, XS_ENG_SIDPLAY2 }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_real", &xs_cfg.memoryMode, XS_MPU_REAL }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_banksw", &xs_cfg.memoryMode, XS_MPU_BANK_SWITCHING }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_transrom", &xs_cfg.memoryMode, XS_MPU_TRANSPARENT_ROM }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_playsid", &xs_cfg.memoryMode, XS_MPU_PLAYSID_ENVIRONMENT }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sidplay1", &xs_cfg.playerEngine, XS_ENG_SIDPLAY1 }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sidplay2", &xs_cfg.playerEngine, XS_ENG_SIDPLAY2 }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_real", &xs_cfg.memoryMode, XS_MPU_REAL }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_banksw", &xs_cfg.memoryMode, XS_MPU_BANK_SWITCHING }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_transrom", &xs_cfg.memoryMode, XS_MPU_TRANSPARENT_ROM }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_mem_playsid", &xs_cfg.memoryMode, XS_MPU_PLAYSID_ENVIRONMENT }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_mos8580", &xs_cfg.mos8580, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_sid_force", &xs_cfg.forceModel, 0 }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_clock_ntsc", &xs_cfg.clockSpeed, XS_CLOCK_NTSC }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_clock_pal", &xs_cfg.clockSpeed, XS_CLOCK_PAL }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_clock_force", &xs_cfg.forceSpeed, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_sp2_opt", &xs_cfg.sid2OptLevel, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_mos8580", &xs_cfg.mos8580, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_sid_force", &xs_cfg.forceModel, 0 }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_clock_ntsc", &xs_cfg.clockSpeed, XS_CLOCK_NTSC }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_clock_pal", &xs_cfg.clockSpeed, XS_CLOCK_PAL }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_clock_force", &xs_cfg.forceSpeed, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_sp2_opt", &xs_cfg.sid2OptLevel, 0 }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sp2_resid", &xs_cfg.sid2Builder, XS_BLD_RESID }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sp2_hardsid", &xs_cfg.sid2Builder, XS_BLD_HARDSID }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sp2_resid", &xs_cfg.sid2Builder, XS_BLD_RESID }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_emu_sp2_hardsid", &xs_cfg.sid2Builder, XS_BLD_HARDSID }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_filters", &xs_cfg.emulateFilters, 0 }, -{ WTYPE_SCALE, CTYPE_FLOAT, "cfg_sp1_filter_fs", &xs_cfg.sid1FilterFs, 0 }, -{ WTYPE_SCALE, CTYPE_FLOAT, "cfg_sp1_filter_fm", &xs_cfg.sid1FilterFm, 0 }, -{ WTYPE_SCALE, CTYPE_FLOAT, "cfg_sp1_filter_ft", &xs_cfg.sid1FilterFt, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_emu_filters", &xs_cfg.emulateFilters, 0 }, +{ WTYPE_SCALE, CTYPE_FLOAT, "cfg_sp1_filter_fs", &xs_cfg.sid1FilterFs, 0 }, +{ WTYPE_SCALE, CTYPE_FLOAT, "cfg_sp1_filter_fm", &xs_cfg.sid1FilterFm, 0 }, +{ WTYPE_SCALE, CTYPE_FLOAT, "cfg_sp1_filter_ft", &xs_cfg.sid1FilterFt, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_maxtime_enable", &xs_cfg.playMaxTimeEnable, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_maxtime_unknown", &xs_cfg.playMaxTimeUnknown, 0 }, -{ WTYPE_SPIN, CTYPE_INT, "cfg_maxtime", &xs_cfg.playMaxTime, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_mintime_enable", &xs_cfg.playMinTimeEnable, 0 }, -{ WTYPE_SPIN, CTYPE_INT, "cfg_mintime", &xs_cfg.playMinTime, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_sld_enable", &xs_cfg.songlenDBEnable, 0 }, -{ WTYPE_TEXT, CTYPE_STR, "cfg_sld_dbpath", &xs_cfg.songlenDBPath, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_maxtime_enable", &xs_cfg.playMaxTimeEnable, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_maxtime_unknown", &xs_cfg.playMaxTimeUnknown, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_maxtime", &xs_cfg.playMaxTime, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_mintime_enable", &xs_cfg.playMinTimeEnable, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_mintime", &xs_cfg.playMinTime, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_sld_enable", &xs_cfg.songlenDBEnable, 0 }, +{ WTYPE_TEXT, CTYPE_STR, "cfg_sld_dbpath", &xs_cfg.songlenDBPath, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_stil_enable", &xs_cfg.stilDBEnable, 0 }, -{ WTYPE_TEXT, CTYPE_STR, "cfg_stil_dbpath", &xs_cfg.stilDBPath, 0 }, -{ WTYPE_TEXT, CTYPE_STR, "cfg_hvsc_path", &xs_cfg.hvscPath, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_stil_enable", &xs_cfg.stilDBEnable, 0 }, +{ WTYPE_TEXT, CTYPE_STR, "cfg_stil_dbpath", &xs_cfg.stilDBPath, 0 }, +{ WTYPE_TEXT, CTYPE_STR, "cfg_hvsc_path", &xs_cfg.hvscPath, 0 }, #ifndef AUDACIOUS_PLUGIN -{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_none", &xs_cfg.subsongControl, XS_SSC_NONE }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_seek", &xs_cfg.subsongControl, XS_SSC_SEEK }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_popup", &xs_cfg.subsongControl, XS_SSC_POPUP }, -{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_patch", &xs_cfg.subsongControl, XS_SSC_PATCH }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_none", &xs_cfg.subsongControl, XS_SSC_NONE }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_seek", &xs_cfg.subsongControl, XS_SSC_SEEK }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_popup", &xs_cfg.subsongControl, XS_SSC_POPUP }, +{ WTYPE_BGROUP, CTYPE_INT, "cfg_subctrl_patch", &xs_cfg.subsongControl, XS_SSC_PATCH }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_detectmagic", &xs_cfg.detectMagic, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_detectmagic", &xs_cfg.detectMagic, 0 }, #endif -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_ftitle_override", &xs_cfg.titleOverride, 0 }, -{ WTYPE_TEXT, CTYPE_STR, "cfg_ftitle_format", &xs_cfg.titleFormat, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_ftitle_override", &xs_cfg.titleOverride, 0 }, +{ WTYPE_TEXT, CTYPE_STR, "cfg_ftitle_format", &xs_cfg.titleFormat, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_subauto_enable", &xs_cfg.subAutoEnable, 0 }, -{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_subauto_min_only", &xs_cfg.subAutoMinOnly, 0 }, -{ WTYPE_SPIN, CTYPE_INT, "cfg_subauto_mintime", &xs_cfg.subAutoMinTime, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_subauto_enable", &xs_cfg.subAutoEnable, 0 }, +{ WTYPE_BUTTON, CTYPE_BOOL, "cfg_subauto_min_only", &xs_cfg.subAutoMinOnly, 0 }, +{ WTYPE_SPIN, CTYPE_INT, "cfg_subauto_mintime", &xs_cfg.subAutoMinTime, 0 }, }; static const gint xs_widtable_max = (sizeof(xs_widtable) / sizeof(t_xs_wid_item)); @@ -206,49 +206,49 @@ */ void xs_init_configuration(void) { - /* Lock configuration mutex */ - XSDEBUG("initializing configuration ...\n"); - XS_MUTEX_LOCK(xs_cfg); + /* Lock configuration mutex */ + XSDEBUG("initializing configuration ...\n"); + XS_MUTEX_LOCK(xs_cfg); - memset(&xs_cfg, 0, sizeof(xs_cfg)); - - /* Initialize values with sensible defaults */ - xs_cfg.audioBitsPerSample = XS_RES_16BIT; - xs_cfg.audioChannels = XS_CHN_MONO; - xs_cfg.audioFrequency = XS_AUDIO_FREQ; + memset(&xs_cfg, 0, sizeof(xs_cfg)); + + /* Initialize values with sensible defaults */ + xs_cfg.audioBitsPerSample = XS_RES_16BIT; + xs_cfg.audioChannels = XS_CHN_MONO; + xs_cfg.audioFrequency = XS_AUDIO_FREQ; - xs_cfg.mos8580 = FALSE; - xs_cfg.forceModel = FALSE; + xs_cfg.mos8580 = FALSE; + xs_cfg.forceModel = FALSE; - /* Filter values */ - xs_cfg.emulateFilters = TRUE; - xs_cfg.sid1FilterFs = XS_SIDPLAY1_FS; - xs_cfg.sid1FilterFm = XS_SIDPLAY1_FM; - xs_cfg.sid1FilterFt = XS_SIDPLAY1_FT; + /* Filter values */ + xs_cfg.emulateFilters = TRUE; + xs_cfg.sid1FilterFs = XS_SIDPLAY1_FS; + xs_cfg.sid1FilterFm = XS_SIDPLAY1_FM; + xs_cfg.sid1FilterFt = XS_SIDPLAY1_FT; #ifdef HAVE_SIDPLAY2 - xs_cfg.playerEngine = XS_ENG_SIDPLAY2; - xs_cfg.memoryMode = XS_MPU_REAL; + xs_cfg.playerEngine = XS_ENG_SIDPLAY2; + xs_cfg.memoryMode = XS_MPU_REAL; #else #ifdef HAVE_SIDPLAY1 - xs_cfg.playerEngine = XS_ENG_SIDPLAY1; - xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; + xs_cfg.playerEngine = XS_ENG_SIDPLAY1; + xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; #else #error This should not happen! No emulator engines configured in! #endif #endif - xs_cfg.clockSpeed = XS_CLOCK_PAL; - xs_cfg.forceSpeed = FALSE; + xs_cfg.clockSpeed = XS_CLOCK_PAL; + xs_cfg.forceSpeed = FALSE; - xs_cfg.sid2OptLevel = 0; - xs_cfg.sid2NFilterPresets = 0; + xs_cfg.sid2OptLevel = 0; + xs_cfg.sid2NFilterPresets = 0; #ifdef HAVE_RESID_BUILDER - xs_cfg.sid2Builder = XS_BLD_RESID; + xs_cfg.sid2Builder = XS_BLD_RESID; #else #ifdef HAVE_HARDSID_BUILDER - xs_cfg.sid2Builder = XS_BLD_HARDSID; + xs_cfg.sid2Builder = XS_BLD_HARDSID; #else #ifdef HAVE_SIDPLAY2 #error This should not happen! No supported SIDPlay2 builders configured in! @@ -256,47 +256,47 @@ #endif #endif - xs_cfg.oversampleEnable = FALSE; - xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; + xs_cfg.oversampleEnable = FALSE; + xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; - xs_cfg.playMaxTimeEnable = FALSE; - xs_cfg.playMaxTimeUnknown = FALSE; - xs_cfg.playMaxTime = 150; + xs_cfg.playMaxTimeEnable = FALSE; + xs_cfg.playMaxTimeUnknown = FALSE; + xs_cfg.playMaxTime = 150; - xs_cfg.playMinTimeEnable = FALSE; - xs_cfg.playMinTime = 15; + xs_cfg.playMinTimeEnable = FALSE; + xs_cfg.playMinTime = 15; - xs_cfg.songlenDBEnable = FALSE; - xs_pstrcpy(&xs_cfg.songlenDBPath, "~/C64Music/Songlengths.txt"); + xs_cfg.songlenDBEnable = FALSE; + xs_pstrcpy(&xs_cfg.songlenDBPath, "~/C64Music/Songlengths.txt"); - xs_cfg.stilDBEnable = FALSE; - xs_pstrcpy(&xs_cfg.stilDBPath, "~/C64Music/DOCUMENTS/STIL.txt"); - xs_pstrcpy(&xs_cfg.hvscPath, "~/C64Music"); + xs_cfg.stilDBEnable = FALSE; + xs_pstrcpy(&xs_cfg.stilDBPath, "~/C64Music/DOCUMENTS/STIL.txt"); + xs_pstrcpy(&xs_cfg.hvscPath, "~/C64Music"); #if defined(HAVE_SONG_POSITION) && !defined(AUDACIOUS_PLUGIN) - xs_cfg.subsongControl = XS_SSC_PATCH; + xs_cfg.subsongControl = XS_SSC_PATCH; #else - xs_cfg.subsongControl = XS_SSC_POPUP; + xs_cfg.subsongControl = XS_SSC_POPUP; #endif - xs_cfg.detectMagic = FALSE; + xs_cfg.detectMagic = FALSE; #ifndef HAVE_XMMSEXTRA - xs_cfg.titleOverride = TRUE; + xs_cfg.titleOverride = TRUE; #endif #ifdef AUDACIOUS_PLUGIN - xs_pstrcpy(&xs_cfg.titleFormat, "${artist} - ${title} (${copyright}) <${subsong-id}/${subsong-num}> [${sid-model}/${sid-speed}]"); + xs_pstrcpy(&xs_cfg.titleFormat, "${artist} - ${title} (${copyright}) <${subsong-id}/${subsong-num}> [${sid-model}/${sid-speed}]"); #else - xs_pstrcpy(&xs_cfg.titleFormat, "%p - %t (%c) <%n/%N> [%m/%C]"); + xs_pstrcpy(&xs_cfg.titleFormat, "%p - %t (%c) <%n/%N> [%m/%C]"); #endif - xs_cfg.subAutoEnable = FALSE; - xs_cfg.subAutoMinOnly = TRUE; - xs_cfg.subAutoMinTime = 15; + xs_cfg.subAutoEnable = FALSE; + xs_cfg.subAutoMinOnly = TRUE; + xs_cfg.subAutoMinTime = 15; - /* Unlock the configuration */ - XS_MUTEX_UNLOCK(xs_cfg); + /* Unlock the configuration */ + XS_MUTEX_UNLOCK(xs_cfg); } @@ -306,84 +306,84 @@ static gboolean xs_filter_load_into(XS_CONFIG_FILE *cfg, gint nFilter, t_xs_sid2_filter *pResult) { - gchar tmpKey[64], *tmpStr; - gint i, j; + gchar tmpKey[64], *tmpStr; + gint i, j; - /* Get fields from config */ - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dNPoints", nFilter); - if (!XS_CFG_GET_INT(cfg, XS_CONFIG_IDENT, tmpKey, &(pResult->npoints))) - return FALSE; - - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dName", nFilter); - if (!XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, &tmpStr)) - return FALSE; - - pResult->name = g_strdup(tmpStr); - if (pResult->name == NULL) { - g_free(pResult); - return FALSE; - } - - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dPoints", nFilter); - if (!XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, &tmpStr)) - return FALSE; - - for (i = 0, j = 0; i < pResult->npoints; i++, j += XS_FITEM) { - if (sscanf(&tmpStr[j], "%4x%4x", - &(pResult->points[i].x), - &(pResult->points[i].y)) != 2) - return FALSE; - } - - return TRUE; + /* Get fields from config */ + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dNPoints", nFilter); + if (!XS_CFG_GET_INT(cfg, XS_CONFIG_IDENT, tmpKey, &(pResult->npoints))) + return FALSE; + + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dName", nFilter); + if (!XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, &tmpStr)) + return FALSE; + + pResult->name = g_strdup(tmpStr); + if (pResult->name == NULL) { + g_free(pResult); + return FALSE; + } + + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dPoints", nFilter); + if (!XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, &tmpStr)) + return FALSE; + + for (i = 0, j = 0; i < pResult->npoints; i++, j += XS_FITEM) { + if (sscanf(&tmpStr[j], "%4x%4x", + &(pResult->points[i].x), + &(pResult->points[i].y)) != 2) + return FALSE; + } + + return TRUE; } static t_xs_sid2_filter * xs_filter_load(XS_CONFIG_FILE *cfg, gint nFilter) { - t_xs_sid2_filter *pResult; - - /* Allocate filter struct */ - if ((pResult = g_malloc0(sizeof(t_xs_sid2_filter))) == NULL) - return NULL; - - if (!xs_filter_load_into(cfg, nFilter, pResult)) { - g_free(pResult); - return NULL; - } else - return pResult; + t_xs_sid2_filter *pResult; + + /* Allocate filter struct */ + if ((pResult = g_malloc0(sizeof(t_xs_sid2_filter))) == NULL) + return NULL; + + if (!xs_filter_load_into(cfg, nFilter, pResult)) { + g_free(pResult); + return NULL; + } else + return pResult; } #if 0 static gboolean xs_filter_save(XS_CONFIG_FILE *cfg, t_xs_sid2_filter *pFilter, gint nFilter) { - gchar *tmpValue, tmpKey[64]; - gint i, j; - - /* Allocate memory for value string */ - tmpValue = g_malloc(sizeof(gchar) * XS_FITEM * (pFilter->npoints + 1)); - if (tmpValue == NULL) - return FALSE; - - /* Make value string */ - for (i = 0, j = 0; i < pFilter->npoints; i++, j += XS_FITEM) { - g_snprintf(&tmpValue[j], XS_FITEM+1, "%04x%04x", - pFilter->points[i].x, - pFilter->points[i].y); - } - - /* Write into the configuration */ - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dName", nFilter); - XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, pFilter->name); - - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dNPoints", nFilter); - XS_CFG_SET_INT(cfg, XS_CONFIG_IDENT, tmpKey, pFilter->npoints); + gchar *tmpValue, tmpKey[64]; + gint i, j; + + /* Allocate memory for value string */ + tmpValue = g_malloc(sizeof(gchar) * XS_FITEM * (pFilter->npoints + 1)); + if (tmpValue == NULL) + return FALSE; + + /* Make value string */ + for (i = 0, j = 0; i < pFilter->npoints; i++, j += XS_FITEM) { + g_snprintf(&tmpValue[j], XS_FITEM+1, "%04x%04x", + pFilter->points[i].x, + pFilter->points[i].y); + } + + /* Write into the configuration */ + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dName", nFilter); + XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, pFilter->name); + + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dNPoints", nFilter); + XS_CFG_SET_INT(cfg, XS_CONFIG_IDENT, tmpKey, pFilter->npoints); - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dPoints", nFilter); - XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, tmpValue); - - g_free(tmpValue); - return TRUE; + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dPoints", nFilter); + XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT, tmpKey, tmpValue); + + g_free(tmpValue); + return TRUE; } #endif @@ -392,203 +392,203 @@ */ static gboolean xs_fgetitem(gchar *inLine, size_t *linePos, gchar sep, gchar *tmpStr, size_t tmpMax) { - size_t i; - for (i = 0; i < tmpMax && inLine[*linePos] && - !isspace(inLine[*linePos]) && - inLine[*linePos] != sep; i++, (*linePos)++) - tmpStr[i] = inLine[*linePos]; - tmpStr[i] = 0; - xs_findnext(inLine, linePos); - return (inLine[*linePos] == sep); + size_t i; + for (i = 0; i < tmpMax && inLine[*linePos] && + !isspace(inLine[*linePos]) && + inLine[*linePos] != sep; i++, (*linePos)++) + tmpStr[i] = inLine[*linePos]; + tmpStr[i] = 0; + xs_findnext(inLine, linePos); + return (inLine[*linePos] == sep); } static gboolean xs_filters_import(const gchar *pcFilename, t_xs_sid2_filter **pFilters, gint *nFilters) { - FILE *inFile; - gchar inLine[XS_BUF_SIZE], tmpStr[XS_BUF_SIZE]; - gchar *sectName = NULL; - gboolean sectBegin; - size_t lineNum, i; - t_xs_sid2_filter *tmpFilter; + FILE *inFile; + gchar inLine[XS_BUF_SIZE], tmpStr[XS_BUF_SIZE]; + gchar *sectName = NULL; + gboolean sectBegin; + size_t lineNum, i; + t_xs_sid2_filter *tmpFilter; fprintf(stderr, "xs_filters_import(%s)\n", pcFilename); - if ((inFile = fopen(pcFilename, "ra")) == NULL) - return FALSE; + if ((inFile = fopen(pcFilename, "ra")) == NULL) + return FALSE; fprintf(stderr, "importing...\n"); - - sectBegin = FALSE; - lineNum = 0; - while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { - size_t linePos = 0; - lineNum++; - - xs_findnext(inLine, &linePos); - if (isalpha(inLine[linePos]) && sectBegin) { - /* A new key/value pair */ - if (!xs_fgetitem(inLine, &linePos, '=', tmpStr, XS_BUF_SIZE)) { - fprintf(stderr, "invalid line: %s [expect =']'", inLine); - } else { - linePos++; - xs_findnext(inLine, &linePos); - if (!strncmp(tmpStr, "points", 6)) { - fprintf(stderr, "points=%s\n", &inLine[linePos]); - } else if (!strncmp(tmpStr, "point", 5)) { - } else if (!strncmp(tmpStr, "type", 4)) { - } else { - fprintf(stderr, "warning: ukn def: %s @ %s\n", - tmpStr, sectName); - } - } - } else if (inLine[linePos] == '[') { - /* Check for existing section */ - if (sectBegin) { - /* Submit definition */ - fprintf(stderr, "filter ends: %s\n", sectName); - if ((tmpFilter = g_malloc0(sizeof(t_xs_sid2_filter))) == NULL) { - fprintf(stderr, "could not allocate ..\n"); - } else { - - } - g_free(sectName); - } - - /* New filter(?) section starts */ - linePos++; - for (i = 0; i < XS_BUF_SIZE && inLine[linePos] && inLine[linePos] != ']'; i++, linePos++) - tmpStr[i] = inLine[linePos]; - tmpStr[i] = 0; - - if (inLine[linePos] != ']') { - fprintf(stderr, "invalid! expected ']': %s\n", inLine); - } else { - sectName = strdup(tmpStr); - fprintf(stderr, "filter: %s\n", sectName); - sectBegin = TRUE; - } - } else if ((inLine[linePos] != ';') && (inLine[linePos] != 0)) { - /* Syntax error */ - fprintf(stderr, "syntax error: %s\n", inLine); - } - } - - fclose(inFile); - return TRUE; + + sectBegin = FALSE; + lineNum = 0; + while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { + size_t linePos = 0; + lineNum++; + + xs_findnext(inLine, &linePos); + if (isalpha(inLine[linePos]) && sectBegin) { + /* A new key/value pair */ + if (!xs_fgetitem(inLine, &linePos, '=', tmpStr, XS_BUF_SIZE)) { + fprintf(stderr, "invalid line: %s [expect =']'", inLine); + } else { + linePos++; + xs_findnext(inLine, &linePos); + if (!strncmp(tmpStr, "points", 6)) { + fprintf(stderr, "points=%s\n", &inLine[linePos]); + } else if (!strncmp(tmpStr, "point", 5)) { + } else if (!strncmp(tmpStr, "type", 4)) { + } else { + fprintf(stderr, "warning: ukn def: %s @ %s\n", + tmpStr, sectName); + } + } + } else if (inLine[linePos] == '[') { + /* Check for existing section */ + if (sectBegin) { + /* Submit definition */ + fprintf(stderr, "filter ends: %s\n", sectName); + if ((tmpFilter = g_malloc0(sizeof(t_xs_sid2_filter))) == NULL) { + fprintf(stderr, "could not allocate ..\n"); + } else { + + } + g_free(sectName); + } + + /* New filter(?) section starts */ + linePos++; + for (i = 0; i < XS_BUF_SIZE && inLine[linePos] && inLine[linePos] != ']'; i++, linePos++) + tmpStr[i] = inLine[linePos]; + tmpStr[i] = 0; + + if (inLine[linePos] != ']') { + fprintf(stderr, "invalid! expected ']': %s\n", inLine); + } else { + sectName = strdup(tmpStr); + fprintf(stderr, "filter: %s\n", sectName); + sectBegin = TRUE; + } + } else if ((inLine[linePos] != ';') && (inLine[linePos] != 0)) { + /* Syntax error */ + fprintf(stderr, "syntax error: %s\n", inLine); + } + } + + fclose(inFile); + return TRUE; } static gboolean xs_filters_export(const gchar *pcFilename, t_xs_sid2_filter **pFilters, gint nFilters) { - FILE *outFile; - t_xs_sid2_filter *f; - gint n; - - /* Open/create the file */ - if ((outFile = fopen(pcFilename, "wa")) == NULL) - return FALSE; - - /* Header */ - fprintf(outFile, - "; SIDPlay2 compatible filter definition file\n" - "; Exported by " PACKAGE_STRING "\n\n"); - - /* Write each filter spec in "INI"-style format */ - for (n = 0; n < nFilters; n++) { - gint i; - f = pFilters[n]; - - fprintf(outFile, - "[%s]\n" - "type=1\n" - "points=%d\n", - f->name, f->npoints); - - for (i = 0; i < f->npoints; i++) { - fprintf(outFile, - "point%d=%d,%d\n", - i + 1, - f->points[i].x, - f->points[i].y); - } - - fprintf(outFile, "\n"); - f++; - } - - fclose(outFile); - return TRUE; + FILE *outFile; + t_xs_sid2_filter *f; + gint n; + + /* Open/create the file */ + if ((outFile = fopen(pcFilename, "wa")) == NULL) + return FALSE; + + /* Header */ + fprintf(outFile, + "; SIDPlay2 compatible filter definition file\n" + "; Exported by " PACKAGE_STRING "\n\n"); + + /* Write each filter spec in "INI"-style format */ + for (n = 0; n < nFilters; n++) { + gint i; + f = pFilters[n]; + + fprintf(outFile, + "[%s]\n" + "type=1\n" + "points=%d\n", + f->name, f->npoints); + + for (i = 0; i < f->npoints; i++) { + fprintf(outFile, + "point%d=%d,%d\n", + i + 1, + f->points[i].x, + f->points[i].y); + } + + fprintf(outFile, "\n"); + f++; + } + + fclose(outFile); + return TRUE; } /* Get the configuration (from file or default) */ void xs_read_configuration(void) { - XS_CONFIG_FILE *cfg; - gint i; - gchar *tmpStr; + XS_CONFIG_FILE *cfg; + gint i; + gchar *tmpStr; - /* Try to open the XMMS configuration file */ - XS_MUTEX_LOCK(xs_cfg); - XSDEBUG("loading from config-file ...\n"); + /* Try to open the XMMS configuration file */ + XS_MUTEX_LOCK(xs_cfg); + XSDEBUG("loading from config-file ...\n"); - cfg = XS_CONFIG_OPEN(); + cfg = XS_CONFIG_OPEN(); - if (cfg == NULL) { - XSDEBUG("Could not open configuration, trying to write defaults...\n"); - xs_write_configuration(); - return; - } + if (cfg == NULL) { + XSDEBUG("Could not open configuration, trying to write defaults...\n"); + xs_write_configuration(); + return; + } - /* Read the new settings from XMMS configuration file */ - for (i = 0; i < xs_cfgtable_max; i++) { - switch (xs_cfgtable[i].itemType) { - case CTYPE_INT: - XS_CFG_GET_INT(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - (gint *) xs_cfgtable[i].itemData); - break; + /* Read the new settings from XMMS configuration file */ + for (i = 0; i < xs_cfgtable_max; i++) { + switch (xs_cfgtable[i].itemType) { + case CTYPE_INT: + XS_CFG_GET_INT(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + (gint *) xs_cfgtable[i].itemData); + break; - case CTYPE_BOOL: - XS_CFG_GET_BOOL(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - (gboolean *) xs_cfgtable[i].itemData); - break; + case CTYPE_BOOL: + XS_CFG_GET_BOOL(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + (gboolean *) xs_cfgtable[i].itemData); + break; - case CTYPE_FLOAT: - XS_CFG_GET_FLOAT(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - (gfloat *) xs_cfgtable[i].itemData); - break; - - case CTYPE_STR: - if (XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, (gchar **) &tmpStr)) { - xs_pstrcpy((gchar **) xs_cfgtable[i].itemData, tmpStr); - g_free(tmpStr); - } - break; - } - } - - /* Filters and presets are a special case */ - xs_filter_load_into(cfg, 0, &xs_cfg.sid2Filter); - - if (xs_cfg.sid2NFilterPresets > 0) { - xs_cfg.sid2FilterPresets = g_malloc0(xs_cfg.sid2NFilterPresets * sizeof(t_xs_sid2_filter *)); - if (!xs_cfg.sid2FilterPresets) { - xs_error(_("Allocation of sid2FilterPresets structure failed!\n")); - } else { - for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { - xs_cfg.sid2FilterPresets[i] = xs_filter_load(cfg, i); - } - } - } + case CTYPE_FLOAT: + XS_CFG_GET_FLOAT(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + (gfloat *) xs_cfgtable[i].itemData); + break; + + case CTYPE_STR: + if (XS_CFG_GET_STRING(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, (gchar **) &tmpStr)) { + xs_pstrcpy((gchar **) xs_cfgtable[i].itemData, tmpStr); + g_free(tmpStr); + } + break; + } + } + + /* Filters and presets are a special case */ + xs_filter_load_into(cfg, 0, &xs_cfg.sid2Filter); + + if (xs_cfg.sid2NFilterPresets > 0) { + xs_cfg.sid2FilterPresets = g_malloc0(xs_cfg.sid2NFilterPresets * sizeof(t_xs_sid2_filter *)); + if (!xs_cfg.sid2FilterPresets) { + xs_error(_("Allocation of sid2FilterPresets structure failed!\n")); + } else { + for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { + xs_cfg.sid2FilterPresets[i] = xs_filter_load(cfg, i); + } + } + } - XS_CONFIG_FREE(cfg); + XS_CONFIG_FREE(cfg); - XS_MUTEX_UNLOCK(xs_cfg); - XSDEBUG("OK\n"); + XS_MUTEX_UNLOCK(xs_cfg); + XSDEBUG("OK\n"); } @@ -596,58 +596,58 @@ */ gint xs_write_configuration(void) { - XS_CONFIG_FILE *cfg; - gint i; + XS_CONFIG_FILE *cfg; + gint i; - XSDEBUG("writing configuration ...\n"); - XS_MUTEX_LOCK(xs_cfg); + XSDEBUG("writing configuration ...\n"); + XS_MUTEX_LOCK(xs_cfg); - /* Try to open the XMMS configuration file */ - cfg = XS_CONFIG_OPEN(); + /* Try to open the XMMS configuration file */ + cfg = XS_CONFIG_OPEN(); #ifndef AUDACIOUS_PLUGIN - if (!cfg) cfg = xmms_cfg_new(); - if (!cfg) return -1; + if (!cfg) cfg = xmms_cfg_new(); + if (!cfg) return -1; #endif - /* Write the new settings to XMMS configuration file */ - for (i = 0; i < xs_cfgtable_max; i++) { - switch (xs_cfgtable[i].itemType) { - case CTYPE_INT: - XS_CFG_SET_INT(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - *(gint *) xs_cfgtable[i].itemData); - break; + /* Write the new settings to XMMS configuration file */ + for (i = 0; i < xs_cfgtable_max; i++) { + switch (xs_cfgtable[i].itemType) { + case CTYPE_INT: + XS_CFG_SET_INT(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + *(gint *) xs_cfgtable[i].itemData); + break; - case CTYPE_BOOL: - XS_CFG_SET_BOOL(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - *(gboolean *) xs_cfgtable[i].itemData); - break; + case CTYPE_BOOL: + XS_CFG_SET_BOOL(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + *(gboolean *) xs_cfgtable[i].itemData); + break; - case CTYPE_FLOAT: - XS_CFG_SET_FLOAT(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - *(gfloat *) xs_cfgtable[i].itemData); - break; + case CTYPE_FLOAT: + XS_CFG_SET_FLOAT(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + *(gfloat *) xs_cfgtable[i].itemData); + break; - case CTYPE_STR: - XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT, - xs_cfgtable[i].itemName, - *(gchar **) xs_cfgtable[i].itemData); - break; - } - } + case CTYPE_STR: + XS_CFG_SET_STRING(cfg, XS_CONFIG_IDENT, + xs_cfgtable[i].itemName, + *(gchar **) xs_cfgtable[i].itemData); + break; + } + } #ifndef AUDACIOUS_PLUGIN - xmms_cfg_write_default_file(cfg); + xmms_cfg_write_default_file(cfg); #endif - XS_CONFIG_FREE(cfg); + XS_CONFIG_FREE(cfg); - XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_cfg); - return 0; + return 0; } @@ -660,97 +660,97 @@ */ void xs_cfg_ok(void) { - gint i; - gfloat tmpValue; - gint tmpInt; - const gchar *tmpStr; + gint i; + gfloat tmpValue; + gint tmpInt; + const gchar *tmpStr; - /* Get lock on configuration */ - XS_MUTEX_LOCK(xs_cfg); + /* Get lock on configuration */ + XS_MUTEX_LOCK(xs_cfg); - XSDEBUG("get data from widgets to config...\n"); + XSDEBUG("get data from widgets to config...\n"); - for (i = 0; i < xs_widtable_max; i++) { - switch (xs_widtable[i].widType) { - case WTYPE_BGROUP: - /* Check if toggle-button is active */ - if (GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName))->active) { - /* Yes, set the constant value */ - *((gint *) xs_widtable[i].itemData) = xs_widtable[i].itemSet; - } - break; + for (i = 0; i < xs_widtable_max; i++) { + switch (xs_widtable[i].widType) { + case WTYPE_BGROUP: + /* Check if toggle-button is active */ + if (GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName))->active) { + /* Yes, set the constant value */ + *((gint *) xs_widtable[i].itemData) = xs_widtable[i].itemSet; + } + break; - case WTYPE_COMBO: - /* Get text from text-widget */ - tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW(xs_widtable[i].widName))); - if (sscanf(tmpStr, "%d", &tmpInt) != 1) - tmpInt = xs_widtable[i].itemSet; + case WTYPE_COMBO: + /* Get text from text-widget */ + tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW(xs_widtable[i].widName))); + if (sscanf(tmpStr, "%d", &tmpInt) != 1) + tmpInt = xs_widtable[i].itemSet; - *((gint *) xs_widtable[i].itemData) = tmpInt; - break; - - case WTYPE_SPIN: - case WTYPE_SCALE: - /* Get the value */ - switch (xs_widtable[i].widType) { - case WTYPE_SPIN: - tmpValue = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW(xs_widtable[i].widName)))->value; - break; + *((gint *) xs_widtable[i].itemData) = tmpInt; + break; + + case WTYPE_SPIN: + case WTYPE_SCALE: + /* Get the value */ + switch (xs_widtable[i].widType) { + case WTYPE_SPIN: + tmpValue = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW(xs_widtable[i].widName)))->value; + break; - case WTYPE_SCALE: - tmpValue = gtk_range_get_adjustment(GTK_RANGE(LUW(xs_widtable[i].widName)))->value; - break; - - default: - tmpValue = -1; - break; - } + case WTYPE_SCALE: + tmpValue = gtk_range_get_adjustment(GTK_RANGE(LUW(xs_widtable[i].widName)))->value; + break; + + default: + tmpValue = -1; + break; + } - /* Set the value */ - switch (xs_widtable[i].itemType) { - case CTYPE_INT: - *((gint *) xs_widtable[i].itemData) = (gint) tmpValue; - break; + /* Set the value */ + switch (xs_widtable[i].itemType) { + case CTYPE_INT: + *((gint *) xs_widtable[i].itemData) = (gint) tmpValue; + break; - case CTYPE_FLOAT: - *((gfloat *) xs_widtable[i].itemData) = tmpValue; - break; - } - break; + case CTYPE_FLOAT: + *((gfloat *) xs_widtable[i].itemData) = tmpValue; + break; + } + break; - case WTYPE_BUTTON: - /* Check if toggle-button is active */ - *((gboolean *) xs_widtable[i].itemData) = - (GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName))->active); - break; + case WTYPE_BUTTON: + /* Check if toggle-button is active */ + *((gboolean *) xs_widtable[i].itemData) = + (GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName))->active); + break; - case WTYPE_TEXT: - /* Get text from text-widget */ - xs_pstrcpy((gchar **) xs_widtable[i].itemData, - gtk_entry_get_text(GTK_ENTRY(LUW(xs_widtable[i].widName)))); - break; - } - } - - /* Get filter settings */ - /* - if (!xs_curve_get_points(XS_CURVE(LUW("")), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { - xs_error(_("Warning: Could not get filter curve widget points!\n")); - } - */ + case WTYPE_TEXT: + /* Get text from text-widget */ + xs_pstrcpy((gchar **) xs_widtable[i].itemData, + gtk_entry_get_text(GTK_ENTRY(LUW(xs_widtable[i].widName)))); + break; + } + } + + /* Get filter settings */ + /* + if (!xs_curve_get_points(XS_CURVE(LUW("")), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { + xs_error(_("Warning: Could not get filter curve widget points!\n")); + } + */ - /* Release lock */ - XS_MUTEX_UNLOCK(xs_cfg); - - /* Close window */ - gtk_widget_destroy(xs_configwin); - xs_configwin = NULL; + /* Release lock */ + XS_MUTEX_UNLOCK(xs_cfg); + + /* Close window */ + gtk_widget_destroy(xs_configwin); + xs_configwin = NULL; - /* Write settings */ - xs_write_configuration(); + /* Write settings */ + xs_write_configuration(); - /* Re-initialize */ - xs_reinit(); + /* Re-initialize */ + xs_reinit(); } @@ -758,11 +758,11 @@ */ gboolean xs_confirmwin_delete(GtkWidget *widget, GdkEvent *event, gpointer user_data) { - (void) widget; - (void) event; - (void) user_data; - - return FALSE; + (void) widget; + (void) event; + (void) user_data; + + return FALSE; } @@ -771,34 +771,34 @@ */ void xs_cfg_sldb_browse(GtkButton * button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - if (xs_sldb_fileselector != NULL) { - gdk_window_raise(xs_sldb_fileselector->window); - return; - } + if (xs_sldb_fileselector != NULL) { + gdk_window_raise(xs_sldb_fileselector->window); + return; + } - xs_sldb_fileselector = create_xs_sldb_fs(); - XS_MUTEX_LOCK(xs_cfg); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_sldb_fileselector), xs_cfg.songlenDBPath); - XS_MUTEX_UNLOCK(xs_cfg); - gtk_widget_show(xs_sldb_fileselector); + xs_sldb_fileselector = create_xs_sldb_fs(); + XS_MUTEX_LOCK(xs_cfg); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_sldb_fileselector), xs_cfg.songlenDBPath); + XS_MUTEX_UNLOCK(xs_cfg); + gtk_widget_show(xs_sldb_fileselector); } void xs_sldb_fs_ok(GtkButton *button, gpointer user_data) { - (void) button; - (void) user_data; - - /* Selection was accepted! */ - gtk_entry_set_text(GTK_ENTRY(LUW("cfg_sld_dbpath")), - gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_sldb_fileselector))); + (void) button; + (void) user_data; + + /* Selection was accepted! */ + gtk_entry_set_text(GTK_ENTRY(LUW("cfg_sld_dbpath")), + gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_sldb_fileselector))); - /* Close file selector window */ - gtk_widget_destroy(xs_sldb_fileselector); - xs_sldb_fileselector = NULL; + /* Close file selector window */ + gtk_widget_destroy(xs_sldb_fileselector); + xs_sldb_fileselector = NULL; } XS_DEF_WINDOW_CLOSE(sldb_fs_cancel, sldb_fileselector) @@ -809,34 +809,34 @@ */ void xs_cfg_stil_browse(GtkButton * button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - if (xs_stil_fileselector != NULL) { - gdk_window_raise(xs_stil_fileselector->window); - return; - } + if (xs_stil_fileselector != NULL) { + gdk_window_raise(xs_stil_fileselector->window); + return; + } - xs_stil_fileselector = create_xs_stil_fs(); - XS_MUTEX_LOCK(xs_cfg); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_stil_fileselector), xs_cfg.stilDBPath); - XS_MUTEX_UNLOCK(xs_cfg); - gtk_widget_show(xs_stil_fileselector); + xs_stil_fileselector = create_xs_stil_fs(); + XS_MUTEX_LOCK(xs_cfg); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_stil_fileselector), xs_cfg.stilDBPath); + XS_MUTEX_UNLOCK(xs_cfg); + gtk_widget_show(xs_stil_fileselector); } void xs_stil_fs_ok(GtkButton *button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - /* Selection was accepted! */ - gtk_entry_set_text(GTK_ENTRY(LUW("cfg_stil_dbpath")), - gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_stil_fileselector))); + /* Selection was accepted! */ + gtk_entry_set_text(GTK_ENTRY(LUW("cfg_stil_dbpath")), + gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_stil_fileselector))); - /* Close file selector window */ - gtk_widget_destroy(xs_stil_fileselector); - xs_stil_fileselector = NULL; + /* Close file selector window */ + gtk_widget_destroy(xs_stil_fileselector); + xs_stil_fileselector = NULL; } @@ -848,34 +848,34 @@ */ void xs_cfg_hvsc_browse(GtkButton * button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - if (xs_hvsc_selector != NULL) { - gdk_window_raise(xs_hvsc_selector->window); - return; - } + if (xs_hvsc_selector != NULL) { + gdk_window_raise(xs_hvsc_selector->window); + return; + } - xs_hvsc_selector = create_xs_hvsc_fs(); - XS_MUTEX_LOCK(xs_cfg); - gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_hvsc_selector), xs_cfg.hvscPath); - XS_MUTEX_UNLOCK(xs_cfg); - gtk_widget_show(xs_hvsc_selector); + xs_hvsc_selector = create_xs_hvsc_fs(); + XS_MUTEX_LOCK(xs_cfg); + gtk_file_selection_set_filename(GTK_FILE_SELECTION(xs_hvsc_selector), xs_cfg.hvscPath); + XS_MUTEX_UNLOCK(xs_cfg); + gtk_widget_show(xs_hvsc_selector); } void xs_hvsc_fs_ok(GtkButton *button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - /* Selection was accepted! */ - gtk_entry_set_text(GTK_ENTRY(LUW("cfg_hvsc_path")), - gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_hvsc_selector))); + /* Selection was accepted! */ + gtk_entry_set_text(GTK_ENTRY(LUW("cfg_hvsc_path")), + gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_hvsc_selector))); - /* Close file selector window */ - gtk_widget_destroy(xs_hvsc_selector); - xs_hvsc_selector = NULL; + /* Close file selector window */ + gtk_widget_destroy(xs_hvsc_selector); + xs_hvsc_selector = NULL; } @@ -887,156 +887,156 @@ */ void xs_cfg_sp1_filter_reset(GtkButton * button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_sp1_filter_fs"))), XS_SIDPLAY1_FS); - gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_sp1_filter_fm"))), XS_SIDPLAY1_FM); - gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_sp1_filter_ft"))), XS_SIDPLAY1_FT); + gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_sp1_filter_fs"))), XS_SIDPLAY1_FS); + gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_sp1_filter_fm"))), XS_SIDPLAY1_FM); + gtk_adjustment_set_value(gtk_range_get_adjustment(GTK_RANGE(LUW("cfg_sp1_filter_ft"))), XS_SIDPLAY1_FT); } void xs_cfg_sp2_filter_update(XSCurve *curve, t_xs_sid2_filter *f) { - assert(curve); - assert(f); - - xs_curve_reset(curve); - xs_curve_set_range(curve, 0,0, XS_SIDPLAY2_NFPOINTS, XS_SIDPLAY2_FMAX); - if (!xs_curve_set_points(curve, f->points, f->npoints)) { - // FIXME - xs_error(_("Warning: Could not set filter curve widget points!\n")); - } + assert(curve); + assert(f); + + xs_curve_reset(curve); + xs_curve_set_range(curve, 0,0, XS_SIDPLAY2_NFPOINTS, XS_SIDPLAY2_FMAX); + if (!xs_curve_set_points(curve, f->points, f->npoints)) { + // FIXME + xs_error(_("Warning: Could not set filter curve widget points!\n")); + } } void xs_cfg_sp2_presets_update(void) { - GList *tmpList = NULL; - gint i; - - for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { - tmpList = g_list_append(tmpList, - (gpointer) xs_cfg.sid2FilterPresets[i]->name); - } - - gtk_combo_set_popdown_strings(GTK_COMBO(LUW("cfg_sp2_filter_combo")), tmpList); - g_list_free(tmpList); + GList *tmpList = NULL; + gint i; + + for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { + tmpList = g_list_append(tmpList, + (gpointer) xs_cfg.sid2FilterPresets[i]->name); + } + + gtk_combo_set_popdown_strings(GTK_COMBO(LUW("cfg_sp2_filter_combo")), tmpList); + g_list_free(tmpList); } void xs_cfg_sp2_filter_load(GtkButton *button, gpointer user_data) { - const gchar *tmpStr; - gint i, j; - - (void) button; - (void) user_data; - - XS_MUTEX_LOCK(xs_cfg); - - tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sp2_filter_combo_entry"))); - for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) { - if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) { - j = i; - break; - } - } - - if (j != -1) { - fprintf(stderr, "Updating from '%s'\n", tmpStr); - xs_cfg_sp2_filter_update( - XS_CURVE(LUW("cfg_sp2_filter_curve")), - xs_cfg.sid2FilterPresets[i]); - } else { - /* error/warning: no such filter preset */ - fprintf(stderr, "No such filter preset '%s'!\n", tmpStr); - } - - XS_MUTEX_UNLOCK(xs_cfg); + const gchar *tmpStr; + gint i, j; + + (void) button; + (void) user_data; + + XS_MUTEX_LOCK(xs_cfg); + + tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sp2_filter_combo_entry"))); + for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) { + if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) { + j = i; + break; + } + } + + if (j != -1) { + fprintf(stderr, "Updating from '%s'\n", tmpStr); + xs_cfg_sp2_filter_update( + XS_CURVE(LUW("cfg_sp2_filter_curve")), + xs_cfg.sid2FilterPresets[i]); + } else { + /* error/warning: no such filter preset */ + fprintf(stderr, "No such filter preset '%s'!\n", tmpStr); + } + + XS_MUTEX_UNLOCK(xs_cfg); } void xs_cfg_sp2_filter_save(GtkButton *button, gpointer user_data) { - /* - 1) check if textentry matches any current filter name - yes) ask if saving over ok? - no) ... - - 2) save current filter to the name - */ - const gchar *tmpStr; - gint i, j; - - (void) button; - (void) user_data; - - XS_MUTEX_LOCK(xs_cfg); - - tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sp2_filter_combo_entry"))); - for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) { - if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) { - j = i; - break; - } - } - - if (j != -1) { - fprintf(stderr, "Found, confirm overwrite?\n"); - } - - fprintf(stderr, "saving!\n"); - - xs_cfg_sp2_presets_update(); - - XS_MUTEX_UNLOCK(xs_cfg); + /* + 1) check if textentry matches any current filter name + yes) ask if saving over ok? + no) ... + + 2) save current filter to the name + */ + const gchar *tmpStr; + gint i, j; + + (void) button; + (void) user_data; + + XS_MUTEX_LOCK(xs_cfg); + + tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sp2_filter_combo_entry"))); + for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) { + if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) { + j = i; + break; + } + } + + if (j != -1) { + fprintf(stderr, "Found, confirm overwrite?\n"); + } + + fprintf(stderr, "saving!\n"); + + xs_cfg_sp2_presets_update(); + + XS_MUTEX_UNLOCK(xs_cfg); } void xs_cfg_sp2_filter_delete(GtkButton *button, gpointer user_data) { - (void) button; - (void) user_data; - /* - 1) confirm - 2) delete - */ + (void) button; + (void) user_data; + /* + 1) confirm + 2) delete + */ } void xs_cfg_sp2_filter_import(GtkButton *button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - if (xs_filt_importselector != NULL) { - gdk_window_raise(xs_filt_importselector->window); - return; - } + if (xs_filt_importselector != NULL) { + gdk_window_raise(xs_filt_importselector->window); + return; + } - xs_filt_importselector = create_xs_filter_import_fs(); - gtk_widget_show(xs_filt_importselector); + xs_filt_importselector = create_xs_filter_import_fs(); + gtk_widget_show(xs_filt_importselector); } void xs_filter_import_fs_ok(GtkButton *button, gpointer user_data) { - const gchar *tmpStr; - (void) button; - (void) user_data; - - XS_MUTEX_LOCK(xs_cfg); + const gchar *tmpStr; + (void) button; + (void) user_data; + + XS_MUTEX_LOCK(xs_cfg); - /* Selection was accepted! */ - tmpStr = gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_filt_importselector)); - xs_filters_import(tmpStr, xs_cfg.sid2FilterPresets, &xs_cfg.sid2NFilterPresets); - xs_cfg_sp2_presets_update(); + /* Selection was accepted! */ + tmpStr = gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_filt_importselector)); + xs_filters_import(tmpStr, xs_cfg.sid2FilterPresets, &xs_cfg.sid2NFilterPresets); + xs_cfg_sp2_presets_update(); - /* Close file selector window */ - gtk_widget_destroy(xs_filt_importselector); - xs_filt_importselector = NULL; - XS_MUTEX_UNLOCK(xs_cfg); + /* Close file selector window */ + gtk_widget_destroy(xs_filt_importselector); + xs_filt_importselector = NULL; + XS_MUTEX_UNLOCK(xs_cfg); } @@ -1046,35 +1046,35 @@ void xs_cfg_sp2_filter_export(GtkButton *button, gpointer user_data) { - (void) button; - (void) user_data; + (void) button; + (void) user_data; - if (xs_filt_exportselector != NULL) { - gdk_window_raise(xs_filt_exportselector->window); - return; - } + if (xs_filt_exportselector != NULL) { + gdk_window_raise(xs_filt_exportselector->window); + return; + } - xs_filt_exportselector = create_xs_filter_export_fs(); - gtk_widget_show(xs_filt_exportselector); + xs_filt_exportselector = create_xs_filter_export_fs(); + gtk_widget_show(xs_filt_exportselector); } void xs_filter_export_fs_ok(GtkButton *button, gpointer user_data) { - const gchar *tmpStr; - (void) button; - (void) user_data; + const gchar *tmpStr; + (void) button; + (void) user_data; - XS_MUTEX_LOCK(xs_cfg); + XS_MUTEX_LOCK(xs_cfg); - /* Selection was accepted! */ - tmpStr = gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_filt_exportselector)); - xs_filters_export(tmpStr, xs_cfg.sid2FilterPresets, xs_cfg.sid2NFilterPresets); + /* Selection was accepted! */ + tmpStr = gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_filt_exportselector)); + xs_filters_export(tmpStr, xs_cfg.sid2FilterPresets, xs_cfg.sid2NFilterPresets); - /* Close file selector window */ - gtk_widget_destroy(xs_filt_exportselector); - xs_filt_exportselector = NULL; - XS_MUTEX_UNLOCK(xs_cfg); + /* Close file selector window */ + gtk_widget_destroy(xs_filt_exportselector); + xs_filt_exportselector = NULL; + XS_MUTEX_UNLOCK(xs_cfg); } @@ -1086,162 +1086,162 @@ */ void xs_cfg_emu_filters_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_filters_notebook"), isActive); + gtk_widget_set_sensitive(LUW("cfg_filters_notebook"), isActive); } void xs_cfg_ftitle_override_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_ftitle_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_ftitle_box"), isActive); } void xs_cfg_emu_sidplay1_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - (void) togglebutton; - (void) user_data; + (void) togglebutton; + (void) user_data; } void xs_cfg_emu_sidplay2_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_emu_mem_real"), isActive); + gtk_widget_set_sensitive(LUW("cfg_emu_mem_real"), isActive); - gtk_widget_set_sensitive(LUW("cfg_sidplay2_frame"), isActive); - gtk_widget_set_sensitive(LUW("cfg_emu_sp2_opt"), isActive); + gtk_widget_set_sensitive(LUW("cfg_sidplay2_frame"), isActive); + gtk_widget_set_sensitive(LUW("cfg_emu_sp2_opt"), isActive); - gtk_widget_set_sensitive(LUW("cfg_chn_autopan"), !isActive); + gtk_widget_set_sensitive(LUW("cfg_chn_autopan"), !isActive); #ifdef HAVE_RESID_BUILDER - gtk_widget_set_sensitive(LUW("cfg_emu_sp2_resid"), isActive); + gtk_widget_set_sensitive(LUW("cfg_emu_sp2_resid"), isActive); #else - gtk_widget_set_sensitive(LUW("cfg_emu_sp2_resid"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_emu_sp2_resid"), FALSE); #endif #ifdef HAVE_HARDSID_BUILDER - gtk_widget_set_sensitive(LUW("cfg_emu_sp2_hardsid"), isActive); + gtk_widget_set_sensitive(LUW("cfg_emu_sp2_hardsid"), isActive); #else - gtk_widget_set_sensitive(LUW("cfg_emu_sp2_hardsid"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_emu_sp2_hardsid"), FALSE); #endif } void xs_cfg_oversample_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_oversample_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_oversample_box"), isActive); } void xs_cfg_mintime_enable_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_mintime_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_mintime_box"), isActive); } void xs_cfg_maxtime_enable_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(LUW("cfg_maxtime_enable"))->active; + gboolean isActive = GTK_TOGGLE_BUTTON(LUW("cfg_maxtime_enable"))->active; - (void) togglebutton; - (void) user_data; + (void) togglebutton; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_maxtime_unknown"), isActive); - gtk_widget_set_sensitive(LUW("cfg_maxtime_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_maxtime_unknown"), isActive); + gtk_widget_set_sensitive(LUW("cfg_maxtime_box"), isActive); } void xs_cfg_sldb_enable_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_sld_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_sld_box"), isActive); } void xs_cfg_stil_enable_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_stil_box1"), isActive); - gtk_widget_set_sensitive(LUW("cfg_stil_box2"), isActive); + gtk_widget_set_sensitive(LUW("cfg_stil_box1"), isActive); + gtk_widget_set_sensitive(LUW("cfg_stil_box2"), isActive); } void xs_cfg_subauto_enable_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_subauto_min_only"), isActive); - gtk_widget_set_sensitive(LUW("cfg_subauto_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_subauto_min_only"), isActive); + gtk_widget_set_sensitive(LUW("cfg_subauto_box"), isActive); } void xs_cfg_subauto_min_only_toggled(GtkToggleButton * togglebutton, gpointer user_data) { - gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active && - GTK_TOGGLE_BUTTON(LUW("cfg_subauto_enable"))->active; + gboolean isActive = GTK_TOGGLE_BUTTON(togglebutton)->active && + GTK_TOGGLE_BUTTON(LUW("cfg_subauto_enable"))->active; - (void) user_data; + (void) user_data; - gtk_widget_set_sensitive(LUW("cfg_subauto_box"), isActive); + gtk_widget_set_sensitive(LUW("cfg_subauto_box"), isActive); } void xs_cfg_mintime_changed(GtkEditable * editable, gpointer user_data) { - gint tmpValue; - GtkAdjustment *tmpAdj; + gint tmpValue; + GtkAdjustment *tmpAdj; - (void) user_data; + (void) user_data; - tmpAdj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW("cfg_maxtime"))); + tmpAdj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW("cfg_maxtime"))); - tmpValue = (gint) gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(editable))->value; + tmpValue = (gint) gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(editable))->value; - if (tmpValue > tmpAdj->value) - gtk_adjustment_set_value(tmpAdj, tmpValue); + if (tmpValue > tmpAdj->value) + gtk_adjustment_set_value(tmpAdj, tmpValue); } void xs_cfg_maxtime_changed(GtkEditable * editable, gpointer user_data) { - gint tmpValue; - GtkAdjustment *tmpAdj; + gint tmpValue; + GtkAdjustment *tmpAdj; - (void) user_data; + (void) user_data; - tmpAdj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW("cfg_mintime"))); + tmpAdj = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW("cfg_mintime"))); - tmpValue = (gint) gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(editable))->value; + tmpValue = (gint) gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(editable))->value; - if (tmpValue < tmpAdj->value) - gtk_adjustment_set_value(tmpAdj, tmpValue); + if (tmpValue < tmpAdj->value) + gtk_adjustment_set_value(tmpAdj, tmpValue); } @@ -1252,148 +1252,148 @@ */ void xs_configure(void) { - gint i; - gfloat tmpValue; - gchar tmpStr[64]; - GList *tmpList = NULL; - GtkWidget *tmpCurve; + gint i; + gfloat tmpValue; + gchar tmpStr[64]; + GList *tmpList = NULL; + GtkWidget *tmpCurve; - /* Check if the window already exists */ - if (xs_configwin) { - gdk_window_raise(xs_configwin->window); - return; - } + /* Check if the window already exists */ + if (xs_configwin) { + gdk_window_raise(xs_configwin->window); + return; + } - /* Create the window */ - xs_configwin = create_xs_configwin(); - - /* Get lock on configuration */ - XS_MUTEX_LOCK(xs_cfg); + /* Create the window */ + xs_configwin = create_xs_configwin(); + + /* Get lock on configuration */ + XS_MUTEX_LOCK(xs_cfg); - /* Add samplerates */ - for (i = 0; i < xs_nsamplerates_table; i++) { - tmpList = g_list_append (tmpList, - (gpointer) xs_samplerates_table[i]); - } - gtk_combo_set_popdown_strings(GTK_COMBO(LUW("cfg_samplerate_combo")), tmpList); - g_list_free(tmpList); - - /* Create the custom filter curve widget for libSIDPlay2 */ - xs_cfg_sp2_presets_update(); - tmpCurve = xs_curve_new(); - xs_cfg_sp2_filter_update(XS_CURVE(tmpCurve), &xs_cfg.sid2Filter); - gtk_widget_set_name(tmpCurve, "cfg_sp2_filter_curve"); - gtk_widget_ref(tmpCurve); - gtk_object_set_data_full(GTK_OBJECT(xs_configwin), - "cfg_sp2_filter_curve", tmpCurve, (GtkDestroyNotify) gtk_widget_unref); - gtk_widget_show(tmpCurve); - gtk_container_add(GTK_CONTAINER(LUW("cfg_sp2_filter_frame")), tmpCurve); + /* Add samplerates */ + for (i = 0; i < xs_nsamplerates_table; i++) { + tmpList = g_list_append (tmpList, + (gpointer) xs_samplerates_table[i]); + } + gtk_combo_set_popdown_strings(GTK_COMBO(LUW("cfg_samplerate_combo")), tmpList); + g_list_free(tmpList); + + /* Create the custom filter curve widget for libSIDPlay2 */ + xs_cfg_sp2_presets_update(); + tmpCurve = xs_curve_new(); + xs_cfg_sp2_filter_update(XS_CURVE(tmpCurve), &xs_cfg.sid2Filter); + gtk_widget_set_name(tmpCurve, "cfg_sp2_filter_curve"); + gtk_widget_ref(tmpCurve); + gtk_object_set_data_full(GTK_OBJECT(xs_configwin), + "cfg_sp2_filter_curve", tmpCurve, (GtkDestroyNotify) gtk_widget_unref); + gtk_widget_show(tmpCurve); + gtk_container_add(GTK_CONTAINER(LUW("cfg_sp2_filter_frame")), tmpCurve); - /* Based on available optional parts, gray out options */ + /* Based on available optional parts, gray out options */ #ifndef HAVE_SIDPLAY1 - gtk_widget_set_sensitive(LUW("cfg_emu_sidplay1"), FALSE); - gtk_widget_set_sensitive(LUW("cfg_box_filter_sidplay1"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_emu_sidplay1"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_box_filter_sidplay1"), FALSE); #endif #ifndef HAVE_SIDPLAY2 - gtk_widget_set_sensitive(LUW("cfg_emu_sidplay2"), FALSE); - gtk_widget_set_sensitive(LUW("cfg_box_filter_sidplay2"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_emu_sidplay2"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_box_filter_sidplay2"), FALSE); #endif - gtk_widget_set_sensitive(LUW("cfg_resid_frame"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_resid_frame"), FALSE); #if !defined(HAVE_XMMSEXTRA) && !defined(AUDACIOUS_PLUGIN) - gtk_widget_set_sensitive(LUW("cfg_ftitle_override"), FALSE); - xs_cfg.titleOverride = TRUE; + gtk_widget_set_sensitive(LUW("cfg_ftitle_override"), FALSE); + xs_cfg.titleOverride = TRUE; #endif #if !defined(HAVE_SONG_POSITION) && !defined(AUDACIOUS_PLUGIN) - gtk_widget_set_sensitive(LUW("cfg_subctrl_patch"), FALSE); + gtk_widget_set_sensitive(LUW("cfg_subctrl_patch"), FALSE); #endif - xs_cfg_ftitle_override_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_ftitle_override")), NULL); - xs_cfg_emu_filters_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_emu_filters")), NULL); - xs_cfg_emu_sidplay1_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_emu_sidplay1")), NULL); - xs_cfg_emu_sidplay2_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_emu_sidplay2")), NULL); - xs_cfg_oversample_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_oversample")), NULL); - xs_cfg_mintime_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_mintime_enable")), NULL); - xs_cfg_maxtime_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_maxtime_enable")), NULL); - xs_cfg_sldb_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_sld_enable")), NULL); - xs_cfg_stil_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_stil_enable")), NULL); - xs_cfg_subauto_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_subauto_enable")), NULL); - xs_cfg_subauto_min_only_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_subauto_min_only")), NULL); + xs_cfg_ftitle_override_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_ftitle_override")), NULL); + xs_cfg_emu_filters_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_emu_filters")), NULL); + xs_cfg_emu_sidplay1_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_emu_sidplay1")), NULL); + xs_cfg_emu_sidplay2_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_emu_sidplay2")), NULL); + xs_cfg_oversample_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_oversample")), NULL); + xs_cfg_mintime_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_mintime_enable")), NULL); + xs_cfg_maxtime_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_maxtime_enable")), NULL); + xs_cfg_sldb_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_sld_enable")), NULL); + xs_cfg_stil_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_stil_enable")), NULL); + xs_cfg_subauto_enable_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_subauto_enable")), NULL); + xs_cfg_subauto_min_only_toggled(GTK_TOGGLE_BUTTON(LUW("cfg_subauto_min_only")), NULL); - /* Set current data to widgets */ - for (i = 0; i < xs_widtable_max; i++) { - switch (xs_widtable[i].widType) { - case WTYPE_BGROUP: - assert(xs_widtable[i].itemType == CTYPE_INT); - /* Check if current value matches the given one */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName)), - (*((gint *) xs_widtable[i].itemData) == xs_widtable[i].itemSet)); - break; + /* Set current data to widgets */ + for (i = 0; i < xs_widtable_max; i++) { + switch (xs_widtable[i].widType) { + case WTYPE_BGROUP: + assert(xs_widtable[i].itemType == CTYPE_INT); + /* Check if current value matches the given one */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName)), + (*((gint *) xs_widtable[i].itemData) == xs_widtable[i].itemSet)); + break; - case WTYPE_COMBO: - assert(xs_widtable[i].itemType == CTYPE_INT); - g_snprintf(tmpStr, sizeof(tmpStr), "%d", *(gint *) xs_widtable[i].itemData); - gtk_entry_set_text(GTK_ENTRY(LUW(xs_widtable[i].widName)), tmpStr); - break; - - case WTYPE_SPIN: - case WTYPE_SCALE: - /* Get the value */ - switch (xs_widtable[i].itemType) { - case CTYPE_INT: - tmpValue = (gfloat) * ((gint *) xs_widtable[i].itemData); - break; + case WTYPE_COMBO: + assert(xs_widtable[i].itemType == CTYPE_INT); + g_snprintf(tmpStr, sizeof(tmpStr), "%d", *(gint *) xs_widtable[i].itemData); + gtk_entry_set_text(GTK_ENTRY(LUW(xs_widtable[i].widName)), tmpStr); + break; + + case WTYPE_SPIN: + case WTYPE_SCALE: + /* Get the value */ + switch (xs_widtable[i].itemType) { + case CTYPE_INT: + tmpValue = (gfloat) * ((gint *) xs_widtable[i].itemData); + break; - case CTYPE_FLOAT: - tmpValue = *((gfloat *) xs_widtable[i].itemData); - break; + case CTYPE_FLOAT: + tmpValue = *((gfloat *) xs_widtable[i].itemData); + break; - default: - tmpValue = -1; - assert(0); - break; - } + default: + tmpValue = -1; + assert(0); + break; + } - /* Set the value */ - switch (xs_widtable[i].widType) { - case WTYPE_SPIN: - gtk_adjustment_set_value(gtk_spin_button_get_adjustment - (GTK_SPIN_BUTTON(LUW(xs_widtable[i].widName))), tmpValue); - break; + /* Set the value */ + switch (xs_widtable[i].widType) { + case WTYPE_SPIN: + gtk_adjustment_set_value(gtk_spin_button_get_adjustment + (GTK_SPIN_BUTTON(LUW(xs_widtable[i].widName))), tmpValue); + break; - case WTYPE_SCALE: - gtk_adjustment_set_value(gtk_range_get_adjustment - (GTK_RANGE(LUW(xs_widtable[i].widName))), tmpValue); - break; - } - break; + case WTYPE_SCALE: + gtk_adjustment_set_value(gtk_range_get_adjustment + (GTK_RANGE(LUW(xs_widtable[i].widName))), tmpValue); + break; + } + break; - case WTYPE_BUTTON: - assert(xs_widtable[i].itemType == CTYPE_BOOL); - /* Set toggle-button */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName)), - *((gboolean *) xs_widtable[i].itemData)); - break; + case WTYPE_BUTTON: + assert(xs_widtable[i].itemType == CTYPE_BOOL); + /* Set toggle-button */ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName)), + *((gboolean *) xs_widtable[i].itemData)); + break; - case WTYPE_TEXT: - assert(xs_widtable[i].itemType == CTYPE_STR); - /* Set text to text-widget */ - if (*(gchar **) xs_widtable[i].itemData != NULL) { - gtk_entry_set_text(GTK_ENTRY(LUW(xs_widtable[i].widName)), - *(gchar **) xs_widtable[i].itemData); - } - break; - } - } + case WTYPE_TEXT: + assert(xs_widtable[i].itemType == CTYPE_STR); + /* Set text to text-widget */ + if (*(gchar **) xs_widtable[i].itemData != NULL) { + gtk_entry_set_text(GTK_ENTRY(LUW(xs_widtable[i].widName)), + *(gchar **) xs_widtable[i].itemData); + } + break; + } + } - /* Release the configuration */ - XS_MUTEX_UNLOCK(xs_cfg); + /* Release the configuration */ + XS_MUTEX_UNLOCK(xs_cfg); - /* Show the widget */ - gtk_widget_show(xs_configwin); + /* Show the widget */ + gtk_widget_show(xs_configwin); } diff -r 04ea91a61225 -r b0743dc9165d src/xs_config.h --- a/src/xs_config.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_config.h Wed Apr 02 22:10:05 2008 +0300 @@ -12,124 +12,124 @@ /* Configuration structure */ enum XS_EMUENGINE { - XS_ENG_SIDPLAY1 = 1, - XS_ENG_SIDPLAY2 + XS_ENG_SIDPLAY1 = 1, + XS_ENG_SIDPLAY2 }; enum XS_BUILDER { - XS_BLD_RESID = 1, - XS_BLD_HARDSID + XS_BLD_RESID = 1, + XS_BLD_HARDSID }; enum XS_RESOLUTION { - XS_RES_8BIT = 8, - XS_RES_16BIT = 16 + XS_RES_8BIT = 8, + XS_RES_16BIT = 16 }; enum XS_CHANNELS { - XS_CHN_MONO = 1, - XS_CHN_STEREO = 2, - XS_CHN_AUTOPAN = 3 + XS_CHN_MONO = 1, + XS_CHN_STEREO = 2, + XS_CHN_AUTOPAN = 3 }; enum XS_CLOCK { - XS_CLOCK_PAL = 1, - XS_CLOCK_NTSC, - XS_CLOCK_VBI, - XS_CLOCK_CIA, - XS_CLOCK_ANY + XS_CLOCK_PAL = 1, + XS_CLOCK_NTSC, + XS_CLOCK_VBI, + XS_CLOCK_CIA, + XS_CLOCK_ANY }; enum XS_MPU { - XS_MPU_BANK_SWITCHING = 1, - XS_MPU_TRANSPARENT_ROM, - XS_MPU_PLAYSID_ENVIRONMENT, - XS_MPU_REAL + XS_MPU_BANK_SWITCHING = 1, + XS_MPU_TRANSPARENT_ROM, + XS_MPU_PLAYSID_ENVIRONMENT, + XS_MPU_REAL }; enum XS_SSC { - XS_SSC_NONE = 1, - XS_SSC_POPUP, - XS_SSC_PATCH, - XS_SSC_SEEK + XS_SSC_NONE = 1, + XS_SSC_POPUP, + XS_SSC_PATCH, + XS_SSC_SEEK }; enum XS_SIDMODEL { - XS_SIDMODEL_UNKNOWN = 0, - XS_SIDMODEL_6581, - XS_SIDMODEL_8580, - XS_SIDMODEL_ANY + XS_SIDMODEL_UNKNOWN = 0, + XS_SIDMODEL_6581, + XS_SIDMODEL_8580, + XS_SIDMODEL_ANY }; typedef struct { - t_xs_int_point points[XS_SIDPLAY2_NFPOINTS]; - gint npoints; - gchar *name; + t_xs_int_point points[XS_SIDPLAY2_NFPOINTS]; + gint npoints; + gchar *name; } t_xs_sid2_filter; extern struct t_xs_cfg { - /* General audio settings */ - gint audioBitsPerSample; - gint audioChannels; - gint audioFrequency; + /* General audio settings */ + gint audioBitsPerSample; + gint audioChannels; + gint audioFrequency; - gboolean oversampleEnable; - gint oversampleFactor; /* Factor of oversampling */ + gboolean oversampleEnable; + gint oversampleFactor; /* Factor of oversampling */ - /* Emulation settings */ - gboolean mos8580; /* TRUE = 8580, FALSE = 6581 */ - gboolean forceModel; - gint memoryMode; /* See XS_MPU-constants */ - gint clockSpeed; /* PAL (50Hz) or NTSC (60Hz) */ - gboolean forceSpeed; /* TRUE = force to given clockspeed */ + /* Emulation settings */ + gboolean mos8580; /* TRUE = 8580, FALSE = 6581 */ + gboolean forceModel; + gint memoryMode; /* See XS_MPU-constants */ + gint clockSpeed; /* PAL (50Hz) or NTSC (60Hz) */ + gboolean forceSpeed; /* TRUE = force to given clockspeed */ - gint playerEngine; /* Selected player engine */ + gint playerEngine; /* Selected player engine */ - gboolean emulateFilters; - gfloat sid1FilterFs; - gfloat sid1FilterFm; - gfloat sid1FilterFt; + gboolean emulateFilters; + gfloat sid1FilterFs; + gfloat sid1FilterFm; + gfloat sid1FilterFt; - gint sid2OptLevel; /* SIDPlay2 emulation optimization */ - gint sid2Builder; /* SIDPlay2 "builder" aka SID-emu */ - t_xs_sid2_filter sid2Filter; /* Current SIDPlay2 filter */ - t_xs_sid2_filter **sid2FilterPresets; - gint sid2NFilterPresets; - - - /* Playing settings */ - gboolean playMaxTimeEnable, - playMaxTimeUnknown; /* Use max-time only when song-length is unknown */ - gint playMaxTime; /* MAX playtime in seconds */ + gint sid2OptLevel; /* SIDPlay2 emulation optimization */ + gint sid2Builder; /* SIDPlay2 "builder" aka SID-emu */ + t_xs_sid2_filter sid2Filter; /* Current SIDPlay2 filter */ + t_xs_sid2_filter **sid2FilterPresets; + gint sid2NFilterPresets; + + + /* Playing settings */ + gboolean playMaxTimeEnable, + playMaxTimeUnknown; /* Use max-time only when song-length is unknown */ + gint playMaxTime; /* MAX playtime in seconds */ - gboolean playMinTimeEnable; - gint playMinTime; /* MIN playtime in seconds */ + gboolean playMinTimeEnable; + gint playMinTime; /* MIN playtime in seconds */ - gboolean songlenDBEnable; - gchar *songlenDBPath; /* Path to Songlengths.txt */ + gboolean songlenDBEnable; + gchar *songlenDBPath; /* Path to Songlengths.txt */ - /* Miscellaneous settings */ - gboolean stilDBEnable; - gchar *stilDBPath; /* Path to STIL.txt */ - gchar *hvscPath; /* Path-prefix for HVSC */ + /* Miscellaneous settings */ + gboolean stilDBEnable; + gchar *stilDBPath; /* Path to STIL.txt */ + gchar *hvscPath; /* Path-prefix for HVSC */ - gint subsongControl; - gboolean detectMagic; + gint subsongControl; + gboolean detectMagic; - gboolean titleOverride; /* TRUE if XMMS titles are overriden */ - gchar *titleFormat; + gboolean titleOverride; /* TRUE if XMMS titles are overriden */ + gchar *titleFormat; - gboolean subAutoEnable, - subAutoMinOnly; - gint subAutoMinTime; + gboolean subAutoEnable, + subAutoMinOnly; + gint subAutoMinTime; } xs_cfg; XS_MUTEX_H(xs_cfg); @@ -138,46 +138,46 @@ /* Configuration-file */ enum { - CTYPE_INT = 1, - CTYPE_FLOAT, - CTYPE_STR, - CTYPE_BOOL + CTYPE_INT = 1, + CTYPE_FLOAT, + CTYPE_STR, + CTYPE_BOOL }; enum { - WTYPE_BGROUP = 1, - WTYPE_SPIN, - WTYPE_SCALE, - WTYPE_BUTTON, - WTYPE_TEXT, - WTYPE_COMBO + WTYPE_BGROUP = 1, + WTYPE_SPIN, + WTYPE_SCALE, + WTYPE_BUTTON, + WTYPE_TEXT, + WTYPE_COMBO }; typedef struct { - gint itemType; /* Type of item (CTYPE_*) */ - void *itemData; /* Pointer to variable */ - gchar *itemName; /* Name of configuration item */ + gint itemType; /* Type of item (CTYPE_*) */ + void *itemData; /* Pointer to variable */ + gchar *itemName; /* Name of configuration item */ } t_xs_cfg_item; typedef struct { - gint widType; - gint itemType; - gchar *widName; - void *itemData; - gint itemSet; + gint widType; + gint itemType; + gchar *widName; + void *itemData; + gint itemSet; } t_xs_wid_item; /* Functions */ -void xs_init_configuration(void); -void xs_configure(void); -void xs_read_configuration(void); -gint xs_write_configuration(void); +void xs_init_configuration(void); +void xs_configure(void); +void xs_read_configuration(void); +gint xs_write_configuration(void); #ifdef __cplusplus } #endif -#endif /* XS_CONFIG_H */ +#endif /* XS_CONFIG_H */ diff -r 04ea91a61225 -r b0743dc9165d src/xs_curve.c --- a/src/xs_curve.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_curve.c Wed Apr 02 22:10:05 2008 +0300 @@ -33,29 +33,29 @@ #include -#define RADIUS 3 /* radius of the control points */ -#define RADIUS2 (RADIUS * 2) -#define MIN_DISTANCE 7 /* min distance between control points */ +#define RADIUS 3 /* radius of the control points */ +#define RADIUS2 (RADIUS * 2) +#define MIN_DISTANCE 7 /* min distance between control points */ -#define GRAPH_MASK (GDK_EXPOSURE_MASK | \ - GDK_POINTER_MOTION_MASK | \ - GDK_POINTER_MOTION_HINT_MASK | \ - GDK_ENTER_NOTIFY_MASK | \ - GDK_BUTTON_PRESS_MASK | \ - GDK_BUTTON_RELEASE_MASK | \ - GDK_BUTTON1_MOTION_MASK) +#define GRAPH_MASK (GDK_EXPOSURE_MASK | \ + GDK_POINTER_MOTION_MASK | \ + GDK_POINTER_MOTION_HINT_MASK | \ + GDK_ENTER_NOTIFY_MASK | \ + GDK_BUTTON_PRESS_MASK | \ + GDK_BUTTON_RELEASE_MASK | \ + GDK_BUTTON1_MOTION_MASK) -#define GET_X(i) curve->ctlpoints[i].x -#define GET_Y(i) curve->ctlpoints[i].y +#define GET_X(i) curve->ctlpoints[i].x +#define GET_Y(i) curve->ctlpoints[i].y enum { - ARG_0, - ARG_MIN_X, - ARG_MAX_X, - ARG_MIN_Y, - ARG_MAX_Y + ARG_0, + ARG_MIN_X, + ARG_MAX_X, + ARG_MIN_Y, + ARG_MAX_Y }; static GtkDrawingAreaClass *parent_class = NULL; @@ -71,586 +71,586 @@ GtkType xs_curve_get_type(void) { - static GtkType curve_type = 0; + static GtkType curve_type = 0; - if (!curve_type) { - static const GtkTypeInfo curve_info = { - "XSCurve", - sizeof(XSCurve), - sizeof(XSCurveClass), - (GtkClassInitFunc) xs_curve_class_init, - (GtkObjectInitFunc) xs_curve_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; + if (!curve_type) { + static const GtkTypeInfo curve_info = { + "XSCurve", + sizeof(XSCurve), + sizeof(XSCurveClass), + (GtkClassInitFunc) xs_curve_class_init, + (GtkObjectInitFunc) xs_curve_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; - curve_type = gtk_type_unique(GTK_TYPE_DRAWING_AREA, &curve_info); - } - return curve_type; + curve_type = gtk_type_unique(GTK_TYPE_DRAWING_AREA, &curve_info); + } + return curve_type; } static void xs_curve_class_init(XSCurveClass *class) { - GtkObjectClass *object_class; + GtkObjectClass *object_class; - parent_class = gtk_type_class(GTK_TYPE_DRAWING_AREA); + parent_class = gtk_type_class(GTK_TYPE_DRAWING_AREA); - object_class = (GtkObjectClass *) class; + object_class = (GtkObjectClass *) class; - object_class->set_arg = xs_curve_set_arg; - object_class->get_arg = xs_curve_get_arg; - object_class->finalize = xs_curve_finalize; + object_class->set_arg = xs_curve_set_arg; + object_class->get_arg = xs_curve_get_arg; + object_class->finalize = xs_curve_finalize; - gtk_object_add_arg_type("XSCurve::min_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_X); - gtk_object_add_arg_type("XSCurve::max_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_X); - gtk_object_add_arg_type("XSCurve::min_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_Y); - gtk_object_add_arg_type("XSCurve::max_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_Y); + gtk_object_add_arg_type("XSCurve::min_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_X); + gtk_object_add_arg_type("XSCurve::max_x", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_X); + gtk_object_add_arg_type("XSCurve::min_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MIN_Y); + gtk_object_add_arg_type("XSCurve::max_y", GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_MAX_Y); } static void xs_curve_init(XSCurve *curve) { - gint old_mask; + gint old_mask; - curve->pixmap = NULL; - curve->grab_point = -1; + curve->pixmap = NULL; + curve->grab_point = -1; - curve->nctlpoints = 0; - curve->ctlpoints = NULL; + curve->nctlpoints = 0; + curve->ctlpoints = NULL; - curve->min_x = 0.0; - curve->max_x = 2047.0; - curve->min_y = 0.0; - curve->max_y = 24000.0; + curve->min_x = 0.0; + curve->max_x = 2047.0; + curve->min_y = 0.0; + curve->max_y = 24000.0; - old_mask = gtk_widget_get_events(GTK_WIDGET(curve)); - gtk_widget_set_events(GTK_WIDGET(curve), old_mask | GRAPH_MASK); - gtk_signal_connect(GTK_OBJECT(curve), "event", (GtkSignalFunc) xs_curve_graph_events, curve); - xs_curve_size_graph(curve); + old_mask = gtk_widget_get_events(GTK_WIDGET(curve)); + gtk_widget_set_events(GTK_WIDGET(curve), old_mask | GRAPH_MASK); + gtk_signal_connect(GTK_OBJECT(curve), "event", (GtkSignalFunc) xs_curve_graph_events, curve); + xs_curve_size_graph(curve); } static void xs_curve_set_arg(GtkObject *object, GtkArg *arg, guint arg_id) { - XSCurve *curve = XS_CURVE(object); + XSCurve *curve = XS_CURVE(object); - switch (arg_id) { - case ARG_MIN_X: - xs_curve_set_range(curve, GTK_VALUE_FLOAT(*arg), curve->max_x, curve->min_y, curve->max_y); - break; - case ARG_MAX_X: - xs_curve_set_range(curve, curve->min_x, GTK_VALUE_FLOAT(*arg), curve->min_y, curve->max_y); - break; - case ARG_MIN_Y: - xs_curve_set_range(curve, curve->min_x, curve->max_x, GTK_VALUE_FLOAT(*arg), curve->max_y); - break; - case ARG_MAX_Y: - xs_curve_set_range(curve, curve->min_x, curve->max_x, curve->min_y, GTK_VALUE_FLOAT(*arg)); - break; - } + switch (arg_id) { + case ARG_MIN_X: + xs_curve_set_range(curve, GTK_VALUE_FLOAT(*arg), curve->max_x, curve->min_y, curve->max_y); + break; + case ARG_MAX_X: + xs_curve_set_range(curve, curve->min_x, GTK_VALUE_FLOAT(*arg), curve->min_y, curve->max_y); + break; + case ARG_MIN_Y: + xs_curve_set_range(curve, curve->min_x, curve->max_x, GTK_VALUE_FLOAT(*arg), curve->max_y); + break; + case ARG_MAX_Y: + xs_curve_set_range(curve, curve->min_x, curve->max_x, curve->min_y, GTK_VALUE_FLOAT(*arg)); + break; + } } static void xs_curve_get_arg(GtkObject *object, GtkArg *arg, guint arg_id) { - XSCurve *curve = XS_CURVE(object); + XSCurve *curve = XS_CURVE(object); - switch (arg_id) { - case ARG_MIN_X: - GTK_VALUE_FLOAT(*arg) = curve->min_x; - break; - case ARG_MAX_X: - GTK_VALUE_FLOAT(*arg) = curve->max_x; - break; - case ARG_MIN_Y: - GTK_VALUE_FLOAT(*arg) = curve->min_y; - break; - case ARG_MAX_Y: - GTK_VALUE_FLOAT(*arg) = curve->max_y; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } + switch (arg_id) { + case ARG_MIN_X: + GTK_VALUE_FLOAT(*arg) = curve->min_x; + break; + case ARG_MAX_X: + GTK_VALUE_FLOAT(*arg) = curve->max_x; + break; + case ARG_MIN_Y: + GTK_VALUE_FLOAT(*arg) = curve->min_y; + break; + case ARG_MAX_Y: + GTK_VALUE_FLOAT(*arg) = curve->max_y; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } } static int xs_project(gfloat value, gfloat min, gfloat max, int norm) { - return (norm - 1) * ((value - min) / (max - min)) + 0.5; + return (norm - 1) * ((value - min) / (max - min)) + 0.5; } static gfloat xs_unproject(gint value, gfloat min, gfloat max, int norm) { - return value / (gfloat) (norm - 1) * (max - min) + min; + return value / (gfloat) (norm - 1) * (max - min) + min; } static inline void xs_cubic_coeff(gfloat x1, gfloat y1, - gfloat x2, gfloat y2, - gfloat k1, gfloat k2, - gfloat *a, gfloat *b, - gfloat *c, gfloat *d) + gfloat x2, gfloat y2, + gfloat k1, gfloat k2, + gfloat *a, gfloat *b, + gfloat *c, gfloat *d) { - gfloat dx = x2 - x1, dy = y2 - y1; + gfloat dx = x2 - x1, dy = y2 - y1; - *a = ((k1 + k2) - 2 * dy / dx) / (dx * dx); - *b = ((k2 - k1) / dx - 3 * (x1 + x2) * (*a)) / 2; - *c = k1 - (3 * x1 * (*a) + 2 * (*b)) * x1; - *d = y1 - ((x1 * (*a) + (*b)) * x1 + (*c)) * x1; + *a = ((k1 + k2) - 2 * dy / dx) / (dx * dx); + *b = ((k2 - k1) / dx - 3 * (x1 + x2) * (*a)) / 2; + *c = k1 - (3 * x1 * (*a) + 2 * (*b)) * x1; + *d = y1 - ((x1 * (*a) + (*b)) * x1 + (*c)) * x1; } static void xs_curve_draw(XSCurve *curve, gint width, gint height) { - gfloat res = 5.0f; - GtkStateType state; - GtkStyle *style; - gint i, ox = -1, oy = -1; - t_xs_point *p0, *p1, *p2, *p3; + gfloat res = 5.0f; + GtkStateType state; + GtkStyle *style; + gint i, ox = -1, oy = -1; + t_xs_point *p0, *p1, *p2, *p3; - if (!curve->pixmap) - return; + if (!curve->pixmap) + return; - state = GTK_STATE_NORMAL; - if (!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(curve))) - state = GTK_STATE_INSENSITIVE; + state = GTK_STATE_NORMAL; + if (!GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(curve))) + state = GTK_STATE_INSENSITIVE; - style = GTK_WIDGET(curve)->style; + style = GTK_WIDGET(curve)->style; - /* Clear the pixmap */ - gtk_paint_flat_box(style, curve->pixmap, - GTK_STATE_NORMAL, GTK_SHADOW_NONE, - NULL, GTK_WIDGET(curve), "curve_bg", - 0, 0, - width + RADIUS2, - height + RADIUS2); + /* Clear the pixmap */ + gtk_paint_flat_box(style, curve->pixmap, + GTK_STATE_NORMAL, GTK_SHADOW_NONE, + NULL, GTK_WIDGET(curve), "curve_bg", + 0, 0, + width + RADIUS2, + height + RADIUS2); - - /* Draw the grid */ - for (i = 0; i < 5; i++) { - gdk_draw_line(curve->pixmap, style->dark_gc[state], - RADIUS, i * (height / 4.0) + RADIUS, - width + RADIUS, i * (height / 4.0) + RADIUS); + + /* Draw the grid */ + for (i = 0; i < 5; i++) { + gdk_draw_line(curve->pixmap, style->dark_gc[state], + RADIUS, i * (height / 4.0) + RADIUS, + width + RADIUS, i * (height / 4.0) + RADIUS); - gdk_draw_line(curve->pixmap, style->dark_gc[state], - i * (width / 4.0) + RADIUS, RADIUS, - i * (width / 4.0) + RADIUS, height + RADIUS); - } + gdk_draw_line(curve->pixmap, style->dark_gc[state], + i * (width / 4.0) + RADIUS, RADIUS, + i * (width / 4.0) + RADIUS, height + RADIUS); + } #if 1 - /* Draw the spline/curve itself */ - p0 = curve->ctlpoints; - p1 = p0; - p2 = p1; p2++; - p3 = p2; p3++; + /* Draw the spline/curve itself */ + p0 = curve->ctlpoints; + p1 = p0; + p2 = p1; p2++; + p3 = p2; p3++; - /* Draw each curve segment */ - if (curve->nctlpoints > 5) - for (i = 0; i < curve->nctlpoints; i++, ++p0, ++p1, ++p2, ++p3) { - gint n; - gfloat k1, k2, a, b, c, d, x; - - if (p1->x == p2->x) - continue; + /* Draw each curve segment */ + if (curve->nctlpoints > 5) + for (i = 0; i < curve->nctlpoints; i++, ++p0, ++p1, ++p2, ++p3) { + gint n; + gfloat k1, k2, a, b, c, d, x; + + if (p1->x == p2->x) + continue; - if (p0->x == p1->x && p2->x == p3->x) { - k1 = k2 = (p2->y - p1->y) / (p2->x - p1->x); - } else if (p0->x == p1->x) { - k2 = (p3->y - p1->y) / (p3->x - p1->x); - k1 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k2) / 2; - } else if (p2->x == p3->x) { - k1 = (p2->y - p0->y) / (p2->x - p0->x); - k2 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k1) / 2; - } else { - k1 = (p2->y - p0->y) / (p2->x - p0->x); - k2 = (p3->y - p1->y) / (p3->x - p1->x); - } + if (p0->x == p1->x && p2->x == p3->x) { + k1 = k2 = (p2->y - p1->y) / (p2->x - p1->x); + } else if (p0->x == p1->x) { + k2 = (p3->y - p1->y) / (p3->x - p1->x); + k1 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k2) / 2; + } else if (p2->x == p3->x) { + k1 = (p2->y - p0->y) / (p2->x - p0->x); + k2 = (3 * (p2->y - p1->y) / (p2->x - p1->x) - k1) / 2; + } else { + k1 = (p2->y - p0->y) / (p2->x - p0->x); + k2 = (p3->y - p1->y) / (p3->x - p1->x); + } - xs_cubic_coeff(p1->x, p1->y, p2->x, p2->y, k1, k2, &a, &b, &c, &d); + xs_cubic_coeff(p1->x, p1->y, p2->x, p2->y, k1, k2, &a, &b, &c, &d); - for (x = p1->x; x <= p2->x; x += res, n++) { - gfloat y = ((a * x + b) * x + c) * x + d; - gint qx, qy; - qx = RADIUS + xs_project(x, curve->min_x, curve->max_x, width); - qy = RADIUS + xs_project(y, curve->min_y, curve->max_y, height); - - if (ox != -1) { - gdk_draw_line(curve->pixmap, style->fg_gc[state], - ox, oy, qx, qy); - } - ox = qx; oy = qy; - } - } + for (x = p1->x; x <= p2->x; x += res, n++) { + gfloat y = ((a * x + b) * x + c) * x + d; + gint qx, qy; + qx = RADIUS + xs_project(x, curve->min_x, curve->max_x, width); + qy = RADIUS + xs_project(y, curve->min_y, curve->max_y, height); + + if (ox != -1) { + gdk_draw_line(curve->pixmap, style->fg_gc[state], + ox, oy, qx, qy); + } + ox = qx; oy = qy; + } + } #endif - /* Draw control points */ - for (i = 0; i < curve->nctlpoints; ++i) { - gint x, y; - GtkStateType cstate; + /* Draw control points */ + for (i = 0; i < curve->nctlpoints; ++i) { + gint x, y; + GtkStateType cstate; - if (GET_X(i) < curve->min_x || GET_Y(i) < curve->min_y || - GET_X(i) >= curve->max_x || GET_Y(i) >= curve->max_y) - continue; + if (GET_X(i) < curve->min_x || GET_Y(i) < curve->min_y || + GET_X(i) >= curve->max_x || GET_Y(i) >= curve->max_y) + continue; - x = xs_project(GET_X(i), curve->min_x, curve->max_x, width); - y = xs_project(GET_Y(i), curve->min_y, curve->max_y, height); - - if (i == curve->grab_point) { - cstate = GTK_STATE_SELECTED; - gdk_draw_line(curve->pixmap, style->fg_gc[cstate], - x + RADIUS, RADIUS, x + RADIUS, height + RADIUS); - gdk_draw_line(curve->pixmap, style->fg_gc[cstate], - RADIUS, y + RADIUS, width + RADIUS, y + RADIUS); - } else - cstate = state; - - gdk_draw_arc(curve->pixmap, style->fg_gc[cstate], TRUE, - x, y, RADIUS2, RADIUS2, 0, 360 * 64); - } - - /* Draw pixmap in the widget */ - gdk_draw_pixmap(GTK_WIDGET(curve)->window, - style->fg_gc[state], curve->pixmap, - 0, 0, 0, 0, - width + RADIUS2, - height + RADIUS2); + x = xs_project(GET_X(i), curve->min_x, curve->max_x, width); + y = xs_project(GET_Y(i), curve->min_y, curve->max_y, height); + + if (i == curve->grab_point) { + cstate = GTK_STATE_SELECTED; + gdk_draw_line(curve->pixmap, style->fg_gc[cstate], + x + RADIUS, RADIUS, x + RADIUS, height + RADIUS); + gdk_draw_line(curve->pixmap, style->fg_gc[cstate], + RADIUS, y + RADIUS, width + RADIUS, y + RADIUS); + } else + cstate = state; + + gdk_draw_arc(curve->pixmap, style->fg_gc[cstate], TRUE, + x, y, RADIUS2, RADIUS2, 0, 360 * 64); + } + + /* Draw pixmap in the widget */ + gdk_draw_pixmap(GTK_WIDGET(curve)->window, + style->fg_gc[state], curve->pixmap, + 0, 0, 0, 0, + width + RADIUS2, + height + RADIUS2); } static gint xs_curve_graph_events(GtkWidget *widget, GdkEvent *event, XSCurve *curve) { - GdkCursorType new_type = curve->cursor_type; - GdkEventButton *bevent; - GtkWidget *w; - gint i, width, height, x, y, tx, ty, cx, closest_point = 0, min_x; - guint distance; + GdkCursorType new_type = curve->cursor_type; + GdkEventButton *bevent; + GtkWidget *w; + gint i, width, height, x, y, tx, ty, cx, closest_point = 0, min_x; + guint distance; - w = GTK_WIDGET(curve); - width = w->allocation.width - RADIUS2; - height = w->allocation.height - RADIUS2; + w = GTK_WIDGET(curve); + width = w->allocation.width - RADIUS2; + height = w->allocation.height - RADIUS2; - if ((width < 0) || (height < 0)) - return FALSE; + if ((width < 0) || (height < 0)) + return FALSE; - /* get the pointer position */ - gdk_window_get_pointer(w->window, &tx, &ty, NULL); - x = CLAMP((tx - RADIUS), 0, width - 1); - y = CLAMP((ty - RADIUS), 0, height - 1); - min_x = curve->min_x; + /* get the pointer position */ + gdk_window_get_pointer(w->window, &tx, &ty, NULL); + x = CLAMP((tx - RADIUS), 0, width - 1); + y = CLAMP((ty - RADIUS), 0, height - 1); + min_x = curve->min_x; - distance = ~0U; - for (i = 0; i < curve->nctlpoints; ++i) { - cx = xs_project(GET_X(i), min_x, curve->max_x, width); - if ((guint) abs(x - cx) < distance) { - distance = abs(x - cx); - closest_point = i; - } - } - - /* Act based on event type */ - switch (event->type) { - case GDK_CONFIGURE: - if (curve->pixmap) - gdk_pixmap_unref(curve->pixmap); - curve->pixmap = 0; + distance = ~0U; + for (i = 0; i < curve->nctlpoints; ++i) { + cx = xs_project(GET_X(i), min_x, curve->max_x, width); + if ((guint) abs(x - cx) < distance) { + distance = abs(x - cx); + closest_point = i; + } + } + + /* Act based on event type */ + switch (event->type) { + case GDK_CONFIGURE: + if (curve->pixmap) + gdk_pixmap_unref(curve->pixmap); + curve->pixmap = 0; - /* fall through */ + /* fall through */ - case GDK_EXPOSE: - if (!curve->pixmap) { - curve->pixmap = gdk_pixmap_new(w->window, - w->allocation.width, w->allocation.height, -1); - } - xs_curve_draw(curve, width, height); - break; + case GDK_EXPOSE: + if (!curve->pixmap) { + curve->pixmap = gdk_pixmap_new(w->window, + w->allocation.width, w->allocation.height, -1); + } + xs_curve_draw(curve, width, height); + break; - case GDK_BUTTON_PRESS: - gtk_grab_add(widget); + case GDK_BUTTON_PRESS: + gtk_grab_add(widget); - bevent = (GdkEventButton *) event; - new_type = GDK_TCROSS; + bevent = (GdkEventButton *) event; + new_type = GDK_TCROSS; - if (distance > MIN_DISTANCE) { - /* insert a new control point */ - if (curve->nctlpoints > 0) { - cx = xs_project(GET_X(closest_point), min_x, curve->max_x, width); - if (x > cx) closest_point++; - } - - curve->nctlpoints++; - - curve->ctlpoints = g_realloc(curve->ctlpoints, - curve->nctlpoints * sizeof(*curve->ctlpoints)); - - for (i = curve->nctlpoints - 1; i > closest_point; --i) { - memcpy(curve->ctlpoints + i, - curve->ctlpoints + i - 1, - sizeof(*curve->ctlpoints)); - } - } - - curve->grab_point = closest_point; - GET_X(curve->grab_point) = xs_unproject(x, min_x, curve->max_x, width); - GET_Y(curve->grab_point) = xs_unproject(y, curve->min_y, curve->max_y, height); + if (distance > MIN_DISTANCE) { + /* insert a new control point */ + if (curve->nctlpoints > 0) { + cx = xs_project(GET_X(closest_point), min_x, curve->max_x, width); + if (x > cx) closest_point++; + } + + curve->nctlpoints++; + + curve->ctlpoints = g_realloc(curve->ctlpoints, + curve->nctlpoints * sizeof(*curve->ctlpoints)); + + for (i = curve->nctlpoints - 1; i > closest_point; --i) { + memcpy(curve->ctlpoints + i, + curve->ctlpoints + i - 1, + sizeof(*curve->ctlpoints)); + } + } + + curve->grab_point = closest_point; + GET_X(curve->grab_point) = xs_unproject(x, min_x, curve->max_x, width); + GET_Y(curve->grab_point) = xs_unproject(y, curve->min_y, curve->max_y, height); - xs_curve_draw(curve, width, height); - break; + xs_curve_draw(curve, width, height); + break; - case GDK_BUTTON_RELEASE: - { - gint src, dst; - - gtk_grab_remove(widget); + case GDK_BUTTON_RELEASE: + { + gint src, dst; + + gtk_grab_remove(widget); - /* delete inactive points: */ - for (src = dst = 0; src < curve->nctlpoints; ++src) { - if (GET_X(src) >= min_x) { - memcpy(curve->ctlpoints + dst, - curve->ctlpoints + src, - sizeof(*curve->ctlpoints)); - dst++; - } - } + /* delete inactive points: */ + for (src = dst = 0; src < curve->nctlpoints; ++src) { + if (GET_X(src) >= min_x) { + memcpy(curve->ctlpoints + dst, + curve->ctlpoints + src, + sizeof(*curve->ctlpoints)); + dst++; + } + } - if (dst < src) { - curve->nctlpoints -= (src - dst); - if (curve->nctlpoints <= 0) { - curve->nctlpoints = 1; - GET_X(0) = min_x; - GET_Y(0) = curve->min_y; - xs_curve_draw(curve, width, height); - } - curve->ctlpoints = g_realloc(curve->ctlpoints, - curve->nctlpoints * sizeof(*curve->ctlpoints)); - } + if (dst < src) { + curve->nctlpoints -= (src - dst); + if (curve->nctlpoints <= 0) { + curve->nctlpoints = 1; + GET_X(0) = min_x; + GET_Y(0) = curve->min_y; + xs_curve_draw(curve, width, height); + } + curve->ctlpoints = g_realloc(curve->ctlpoints, + curve->nctlpoints * sizeof(*curve->ctlpoints)); + } - new_type = GDK_FLEUR; - curve->grab_point = -1; - } - xs_curve_draw(curve, width, height); - break; + new_type = GDK_FLEUR; + curve->grab_point = -1; + } + xs_curve_draw(curve, width, height); + break; - case GDK_MOTION_NOTIFY: - if (curve->grab_point == -1) { - /* if no point is grabbed... */ - if (distance <= MIN_DISTANCE) - new_type = GDK_FLEUR; - else - new_type = GDK_TCROSS; - } else { - gint leftbound, rightbound; - - /* drag the grabbed point */ - new_type = GDK_TCROSS; - - leftbound = -MIN_DISTANCE; - if (curve->grab_point > 0) { - leftbound = xs_project( - GET_X(curve->grab_point-1), - min_x, curve->max_x, width); - } + case GDK_MOTION_NOTIFY: + if (curve->grab_point == -1) { + /* if no point is grabbed... */ + if (distance <= MIN_DISTANCE) + new_type = GDK_FLEUR; + else + new_type = GDK_TCROSS; + } else { + gint leftbound, rightbound; + + /* drag the grabbed point */ + new_type = GDK_TCROSS; + + leftbound = -MIN_DISTANCE; + if (curve->grab_point > 0) { + leftbound = xs_project( + GET_X(curve->grab_point-1), + min_x, curve->max_x, width); + } - rightbound = width + RADIUS2 + MIN_DISTANCE; - if (curve->grab_point + 1 < curve->nctlpoints) { - rightbound = xs_project( - GET_X(curve->grab_point+1), - min_x, curve->max_x, width); - } + rightbound = width + RADIUS2 + MIN_DISTANCE; + if (curve->grab_point + 1 < curve->nctlpoints) { + rightbound = xs_project( + GET_X(curve->grab_point+1), + min_x, curve->max_x, width); + } - if ((tx <= leftbound) || (tx >= rightbound) || - (ty > height + RADIUS2 + MIN_DISTANCE) || (ty < -MIN_DISTANCE)) { - GET_X(curve->grab_point) = min_x - 1.0; - } else { - GET_X(curve->grab_point) = - xs_unproject(x, min_x, curve->max_x, width); - GET_Y(curve->grab_point) = - xs_unproject(y, curve->min_y, curve->max_y, height); - } - - xs_curve_draw(curve, width, height); - } - - /* See if cursor type was changed and update accordingly */ - if (new_type != (GdkCursorType) curve->cursor_type) { - GdkCursor *cursor; - curve->cursor_type = new_type; - cursor = gdk_cursor_new(curve->cursor_type); - gdk_window_set_cursor(w->window, cursor); - gdk_cursor_destroy(cursor); - } - break; + if ((tx <= leftbound) || (tx >= rightbound) || + (ty > height + RADIUS2 + MIN_DISTANCE) || (ty < -MIN_DISTANCE)) { + GET_X(curve->grab_point) = min_x - 1.0; + } else { + GET_X(curve->grab_point) = + xs_unproject(x, min_x, curve->max_x, width); + GET_Y(curve->grab_point) = + xs_unproject(y, curve->min_y, curve->max_y, height); + } + + xs_curve_draw(curve, width, height); + } + + /* See if cursor type was changed and update accordingly */ + if (new_type != (GdkCursorType) curve->cursor_type) { + GdkCursor *cursor; + curve->cursor_type = new_type; + cursor = gdk_cursor_new(curve->cursor_type); + gdk_window_set_cursor(w->window, cursor); + gdk_cursor_destroy(cursor); + } + break; - default: - break; - } - - return FALSE; + default: + break; + } + + return FALSE; } static void xs_curve_size_graph(XSCurve *curve) { - gint width, height; - gfloat aspect; + gint width, height; + gfloat aspect; - width = (curve->max_x - curve->min_x) + 1; - height = (curve->max_y - curve->min_y) + 1; - aspect = width / (gfloat) height; + width = (curve->max_x - curve->min_x) + 1; + height = (curve->max_y - curve->min_y) + 1; + aspect = width / (gfloat) height; - if (width > gdk_screen_width() / 4) - width = gdk_screen_width() / 4; + if (width > gdk_screen_width() / 4) + width = gdk_screen_width() / 4; - if (height > gdk_screen_height() / 4) - height = gdk_screen_height() / 4; + if (height > gdk_screen_height() / 4) + height = gdk_screen_height() / 4; - if (aspect < 1.0) - width = height * aspect; - else - height = width / aspect; + if (aspect < 1.0) + width = height * aspect; + else + height = width / aspect; - gtk_drawing_area_size(GTK_DRAWING_AREA(curve), width + RADIUS2, height + RADIUS2); + gtk_drawing_area_size(GTK_DRAWING_AREA(curve), width + RADIUS2, height + RADIUS2); } static void xs_curve_update(XSCurve *curve) { - if (curve->pixmap) { - gint width, height; + if (curve->pixmap) { + gint width, height; - width = GTK_WIDGET(curve)->allocation.width - RADIUS2; - height = GTK_WIDGET(curve)->allocation.height - RADIUS2; - xs_curve_draw(curve, width, height); - } + width = GTK_WIDGET(curve)->allocation.width - RADIUS2; + height = GTK_WIDGET(curve)->allocation.height - RADIUS2; + xs_curve_draw(curve, width, height); + } } void xs_curve_reset(XSCurve *curve) { - if (curve->ctlpoints) - g_free(curve->ctlpoints); + if (curve->ctlpoints) + g_free(curve->ctlpoints); - curve->nctlpoints = 4; - curve->ctlpoints = g_malloc(curve->nctlpoints * sizeof(curve->ctlpoints[0])); + curve->nctlpoints = 4; + curve->ctlpoints = g_malloc(curve->nctlpoints * sizeof(curve->ctlpoints[0])); - GET_X(0) = curve->min_x; - GET_Y(0) = curve->min_y; - GET_X(1) = curve->min_x; - GET_Y(1) = curve->min_y; + GET_X(0) = curve->min_x; + GET_Y(0) = curve->min_y; + GET_X(1) = curve->min_x; + GET_Y(1) = curve->min_y; - GET_X(2) = curve->max_x; - GET_Y(2) = curve->max_y; - GET_X(3) = curve->max_x; - GET_Y(3) = curve->max_y; - - xs_curve_update(curve); + GET_X(2) = curve->max_x; + GET_Y(2) = curve->max_y; + GET_X(3) = curve->max_x; + GET_Y(3) = curve->max_y; + + xs_curve_update(curve); } void xs_curve_set_range(XSCurve *curve, gfloat min_x, gfloat min_y, gfloat max_x, gfloat max_y) { - curve->min_x = min_x; - curve->max_x = max_x; - - curve->min_y = min_y; - curve->max_y = max_y; + curve->min_x = min_x; + curve->max_x = max_x; + + curve->min_y = min_y; + curve->max_y = max_y; - xs_curve_size_graph(curve); - xs_curve_reset(curve); + xs_curve_size_graph(curve); + xs_curve_reset(curve); } gboolean xs_curve_realloc_data(XSCurve *curve, gint npoints) { - if (npoints != curve->nctlpoints) { - curve->nctlpoints = npoints; - curve->ctlpoints = (t_xs_point *) g_realloc(curve->ctlpoints, - curve->nctlpoints * sizeof(*curve->ctlpoints)); + if (npoints != curve->nctlpoints) { + curve->nctlpoints = npoints; + curve->ctlpoints = (t_xs_point *) g_realloc(curve->ctlpoints, + curve->nctlpoints * sizeof(*curve->ctlpoints)); - if (curve->ctlpoints == NULL) - return FALSE; - } - - return TRUE; + if (curve->ctlpoints == NULL) + return FALSE; + } + + return TRUE; } void xs_curve_get_data(XSCurve *curve, t_xs_point ***points, gint **npoints) { - *points = &(curve->ctlpoints); - *npoints = &(curve->nctlpoints); + *points = &(curve->ctlpoints); + *npoints = &(curve->nctlpoints); } gboolean xs_curve_set_points(XSCurve *curve, t_xs_int_point *points, gint npoints) { - gint i; + gint i; - if (!xs_curve_realloc_data(curve, npoints + 4)) - return FALSE; - - GET_X(0) = curve->min_x; - GET_Y(0) = curve->min_y; - GET_X(1) = curve->min_x; - GET_Y(1) = curve->min_y; + if (!xs_curve_realloc_data(curve, npoints + 4)) + return FALSE; + + GET_X(0) = curve->min_x; + GET_Y(0) = curve->min_y; + GET_X(1) = curve->min_x; + GET_Y(1) = curve->min_y; - for (i = 0; i < npoints; i++) { - GET_X(i+2) = points[i].x; - GET_Y(i+2) = points[i].y; - } + for (i = 0; i < npoints; i++) { + GET_X(i+2) = points[i].x; + GET_Y(i+2) = points[i].y; + } - GET_X(npoints+2) = curve->max_x; - GET_Y(npoints+2) = curve->max_y; - GET_X(npoints+3) = curve->max_x; - GET_Y(npoints+3) = curve->max_y; - - xs_curve_update(curve); - return TRUE; + GET_X(npoints+2) = curve->max_x; + GET_Y(npoints+2) = curve->max_y; + GET_X(npoints+3) = curve->max_x; + GET_Y(npoints+3) = curve->max_y; + + xs_curve_update(curve); + return TRUE; } gboolean xs_curve_get_points(XSCurve *curve, t_xs_int_point **points, gint *npoints) { - gint i, n; - - n = curve->nctlpoints - 4; - - *points = g_malloc(n * sizeof(t_xs_int_point)); - if (*points == NULL) - return FALSE; - - *npoints = n; - for (i = 2; i < curve->nctlpoints - 2; i++) { - (*points)[i].x = GET_X(i); - (*points)[i].y = GET_Y(i); - } + gint i, n; + + n = curve->nctlpoints - 4; + + *points = g_malloc(n * sizeof(t_xs_int_point)); + if (*points == NULL) + return FALSE; + + *npoints = n; + for (i = 2; i < curve->nctlpoints - 2; i++) { + (*points)[i].x = GET_X(i); + (*points)[i].y = GET_Y(i); + } - return TRUE; + return TRUE; } GtkWidget *xs_curve_new(void) { - return gtk_type_new(xs_curve_get_type()); + return gtk_type_new(xs_curve_get_type()); } static void xs_curve_finalize(GtkObject *object) { - XSCurve *curve; + XSCurve *curve; - g_return_if_fail(object != NULL); - g_return_if_fail(XS_IS_CURVE(object)); + g_return_if_fail(object != NULL); + g_return_if_fail(XS_IS_CURVE(object)); - curve = XS_CURVE(object); - if (curve->pixmap) - gdk_pixmap_unref(curve->pixmap); - if (curve->ctlpoints) - g_free(curve->ctlpoints); + curve = XS_CURVE(object); + if (curve->pixmap) + gdk_pixmap_unref(curve->pixmap); + if (curve->ctlpoints) + g_free(curve->ctlpoints); - (*GTK_OBJECT_CLASS(parent_class)->finalize) (object); + (*GTK_OBJECT_CLASS(parent_class)->finalize) (object); } diff -r 04ea91a61225 -r b0743dc9165d src/xs_curve.h --- a/src/xs_curve.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_curve.h Wed Apr 02 22:10:05 2008 +0300 @@ -10,11 +10,11 @@ /* Macros for type-classing this GtkWidget/object */ -#define XS_TYPE_CURVE (xs_curve_get_type()) -#define XS_CURVE(obj) (GTK_CHECK_CAST ((obj), XS_TYPE_CURVE, XSCurve)) -#define XS_CURVE_CLASS(luokka) (GTK_CHECK_CLASS_CAST ((luokka), XS_TYPE_CURVE, XSCurveClass)) -#define XS_IS_CURVE(obj) (GTK_CHECK_TYPE ((obj), XS_TYPE_CURVE)) -#define XS_IS_CURVE_CLASS(luokka) (GTK_CHECK_CLASS_TYPE ((luokka), XS_TYPE_CURVE)) +#define XS_TYPE_CURVE (xs_curve_get_type()) +#define XS_CURVE(obj) (GTK_CHECK_CAST ((obj), XS_TYPE_CURVE, XSCurve)) +#define XS_CURVE_CLASS(luokka) (GTK_CHECK_CLASS_CAST ((luokka), XS_TYPE_CURVE, XSCurveClass)) +#define XS_IS_CURVE(obj) (GTK_CHECK_TYPE ((obj), XS_TYPE_CURVE)) +#define XS_IS_CURVE_CLASS(luokka) (GTK_CHECK_CLASS_TYPE ((luokka), XS_TYPE_CURVE)) /* Structures @@ -23,44 +23,44 @@ typedef struct _XSCurveClass XSCurveClass; typedef struct { - gfloat x,y; + gfloat x,y; } t_xs_point; typedef struct { - gint x, y; + gint x, y; } t_xs_int_point; struct _XSCurve { - GtkDrawingArea graph; + GtkDrawingArea graph; - gint cursor_type; - gfloat min_x; - gfloat max_x; - gfloat min_y; - gfloat max_y; - GdkPixmap *pixmap; - gint grab_point; /* point currently grabbed */ + gint cursor_type; + gfloat min_x; + gfloat max_x; + gfloat min_y; + gfloat max_y; + GdkPixmap *pixmap; + gint grab_point; /* point currently grabbed */ - /* control points */ - gint nctlpoints; /* number of control points */ - t_xs_point *ctlpoints; /* array of control points */ + /* control points */ + gint nctlpoints; /* number of control points */ + t_xs_point *ctlpoints; /* array of control points */ }; struct _XSCurveClass { - GtkDrawingAreaClass parent_class; + GtkDrawingAreaClass parent_class; }; -GtkType xs_curve_get_type (void); -GtkWidget* xs_curve_new (void); -void xs_curve_reset (XSCurve *curve); -void xs_curve_set_range (XSCurve *curve, - gfloat min_x, gfloat min_y, - gfloat max_x, gfloat max_y); -gboolean xs_curve_realloc_data (XSCurve *curve, gint npoints); -void xs_curve_get_data (XSCurve *curve, t_xs_point ***points, gint **npoints); -gboolean xs_curve_set_points (XSCurve *curve, t_xs_int_point *points, gint npoints); -gboolean xs_curve_get_points (XSCurve *curve, t_xs_int_point **points, gint *npoints); +GtkType xs_curve_get_type (void); +GtkWidget* xs_curve_new (void); +void xs_curve_reset (XSCurve *curve); +void xs_curve_set_range (XSCurve *curve, + gfloat min_x, gfloat min_y, + gfloat max_x, gfloat max_y); +gboolean xs_curve_realloc_data (XSCurve *curve, gint npoints); +void xs_curve_get_data (XSCurve *curve, t_xs_point ***points, gint **npoints); +gboolean xs_curve_set_points (XSCurve *curve, t_xs_int_point *points, gint npoints); +gboolean xs_curve_get_points (XSCurve *curve, t_xs_int_point **points, gint *npoints); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_fileinfo.c --- a/src/xs_fileinfo.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_fileinfo.c Wed Apr 02 22:10:05 2008 +0300 @@ -36,258 +36,258 @@ static stil_node_t *xs_fileinfostil = NULL; XS_MUTEX(xs_fileinfowin); -#define LUW(x) lookup_widget(xs_fileinfowin, x) +#define LUW(x) lookup_widget(xs_fileinfowin, x) #ifndef AUDACIOUS_PLUGIN void xs_fileinfo_update(void) { - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_fileinfowin); + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_fileinfowin); - /* Check if control window exists, we are currently playing and have a tune */ - if (xs_fileinfowin) { - gboolean isEnabled; - GtkAdjustment *tmpAdj; + /* Check if control window exists, we are currently playing and have a tune */ + if (xs_fileinfowin) { + gboolean isEnabled; + GtkAdjustment *tmpAdj; - if (xs_status.tuneInfo && xs_status.isPlaying && (xs_status.tuneInfo->nsubTunes > 1)) { - tmpAdj = gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))); + if (xs_status.tuneInfo && xs_status.isPlaying && (xs_status.tuneInfo->nsubTunes > 1)) { + tmpAdj = gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))); - tmpAdj->value = xs_status.currSong; - tmpAdj->lower = 1; - tmpAdj->upper = xs_status.tuneInfo->nsubTunes; - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_fileinfowin); - gtk_adjustment_value_changed(tmpAdj); - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_fileinfowin); - isEnabled = TRUE; - } else - isEnabled = FALSE; + tmpAdj->value = xs_status.currSong; + tmpAdj->lower = 1; + tmpAdj->upper = xs_status.tuneInfo->nsubTunes; + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_fileinfowin); + gtk_adjustment_value_changed(tmpAdj); + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_fileinfowin); + isEnabled = TRUE; + } else + isEnabled = FALSE; - /* Enable or disable subtune-control in fileinfo window */ - gtk_widget_set_sensitive(LUW("fileinfo_subctrl_prev"), isEnabled); - gtk_widget_set_sensitive(LUW("fileinfo_subctrl_adj"), isEnabled); - gtk_widget_set_sensitive(LUW("fileinfo_subctrl_next"), isEnabled); - } + /* Enable or disable subtune-control in fileinfo window */ + gtk_widget_set_sensitive(LUW("fileinfo_subctrl_prev"), isEnabled); + gtk_widget_set_sensitive(LUW("fileinfo_subctrl_adj"), isEnabled); + gtk_widget_set_sensitive(LUW("fileinfo_subctrl_next"), isEnabled); + } - XS_MUTEX_UNLOCK(xs_status); - XS_MUTEX_UNLOCK(xs_fileinfowin); + XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_fileinfowin); } static void xs_fileinfo_setsong(void) { - gint n; + gint n; - XS_MUTEX_LOCK(xs_status); - XS_MUTEX_LOCK(xs_fileinfowin); + XS_MUTEX_LOCK(xs_status); + XS_MUTEX_LOCK(xs_fileinfowin); - if (xs_status.tuneInfo && xs_status.isPlaying) { - n = (gint) gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))->value; - if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes)) - xs_status.currSong = n; - } + if (xs_status.tuneInfo && xs_status.isPlaying) { + n = (gint) gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))->value; + if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes)) + xs_status.currSong = n; + } - XS_MUTEX_UNLOCK(xs_fileinfowin); - XS_MUTEX_UNLOCK(xs_status); + XS_MUTEX_UNLOCK(xs_fileinfowin); + XS_MUTEX_UNLOCK(xs_status); } #endif /* AUDACIOUS_PLUGIN */ void xs_fileinfo_ok(void) { - XS_MUTEX_LOCK(xs_fileinfowin); - if (xs_fileinfowin) { - gtk_widget_destroy(xs_fileinfowin); - xs_fileinfowin = NULL; - } - XS_MUTEX_UNLOCK(xs_fileinfowin); + XS_MUTEX_LOCK(xs_fileinfowin); + if (xs_fileinfowin) { + gtk_widget_destroy(xs_fileinfowin); + xs_fileinfowin = NULL; + } + XS_MUTEX_UNLOCK(xs_fileinfowin); } gboolean xs_fileinfo_delete(GtkWidget * widget, GdkEvent * event, gpointer user_data) { - (void) widget; - (void) event; - (void) user_data; + (void) widget; + (void) event; + (void) user_data; - XSDEBUG("delete_event\n"); - xs_fileinfo_ok(); - return FALSE; + XSDEBUG("delete_event\n"); + xs_fileinfo_ok(); + return FALSE; } static void xs_fileinfo_subtune(GtkWidget * widget, void *data) { - stil_subnode_t *tmpNode; - GtkWidget *tmpText; - gchar *subName, *subAuthor, *subInfo; + stil_subnode_t *tmpNode; + GtkWidget *tmpText; + gchar *subName, *subAuthor, *subInfo; - (void) widget; - (void) data; + (void) widget; + (void) data; - /* Freeze text-widget and delete the old text */ - tmpText = LUW("fileinfo_sub_info"); + /* Freeze text-widget and delete the old text */ + tmpText = LUW("fileinfo_sub_info"); #ifndef AUDACIOUS_PLUGIN - gtk_text_freeze(GTK_TEXT(tmpText)); - gtk_text_set_point(GTK_TEXT(tmpText), 0); - gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText))); + gtk_text_freeze(GTK_TEXT(tmpText)); + gtk_text_set_point(GTK_TEXT(tmpText), 0); + gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText))); #endif - /* Get subtune information */ - tmpNode = (stil_subnode_t *) data; - if (!tmpNode && xs_fileinfostil) - tmpNode = xs_fileinfostil->subTunes[0]; - - if (tmpNode) { - subName = tmpNode->name; - subAuthor = tmpNode->author; - subInfo = tmpNode->info; - } else { - subName = NULL; - subAuthor = NULL; - subInfo = NULL; - } + /* Get subtune information */ + tmpNode = (stil_subnode_t *) data; + if (!tmpNode && xs_fileinfostil) + tmpNode = xs_fileinfostil->subTunes[0]; + + if (tmpNode) { + subName = tmpNode->name; + subAuthor = tmpNode->author; + subInfo = tmpNode->info; + } else { + subName = NULL; + subAuthor = NULL; + subInfo = NULL; + } - /* Get and set subtune information */ - gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : ""); - gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : ""); + /* Get and set subtune information */ + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : ""); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : ""); #ifdef AUDACIOUS_PLUGIN - gtk_text_buffer_set_text(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmpText))), - subInfo ? subInfo : "", -1); + gtk_text_buffer_set_text(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmpText))), + subInfo ? subInfo : "", -1); #else - gtk_text_insert(GTK_TEXT(tmpText), NULL, NULL, NULL, - subInfo ? subInfo : "", -1); + gtk_text_insert(GTK_TEXT(tmpText), NULL, NULL, NULL, + subInfo ? subInfo : "", -1); - /* Un-freeze the widget */ - gtk_text_thaw(GTK_TEXT(tmpText)); + /* Un-freeze the widget */ + gtk_text_thaw(GTK_TEXT(tmpText)); #endif } void xs_fileinfo(gchar * pcFilename) { - GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; - xs_tuneinfo_t *tmpInfo; - stil_subnode_t *tmpNode; - gchar tmpStr[256], *tmpFilename; - gint n; + GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; + xs_tuneinfo_t *tmpInfo; + stil_subnode_t *tmpNode; + gchar tmpStr[256], *tmpFilename; + gint n; - /* Current implementation leaves old fileinfo window untouched if - * no information can be found for the new file. Hmm... - */ + /* Current implementation leaves old fileinfo window untouched if + * no information can be found for the new file. Hmm... + */ #ifdef AUDACIOUS_PLUGIN - xs_get_trackinfo(pcFilename, &tmpFilename, &n); + xs_get_trackinfo(pcFilename, &tmpFilename, &n); #else - tmpFilename = pcFilename; -#endif + tmpFilename = pcFilename; +#endif - /* Get new tune information */ - XS_MUTEX_LOCK(xs_fileinfowin); - XS_MUTEX_LOCK(xs_status); - if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename)) == NULL) { - XS_MUTEX_UNLOCK(xs_fileinfowin); - XS_MUTEX_UNLOCK(xs_status); - return; - } - XS_MUTEX_UNLOCK(xs_status); + /* Get new tune information */ + XS_MUTEX_LOCK(xs_fileinfowin); + XS_MUTEX_LOCK(xs_status); + if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename)) == NULL) { + XS_MUTEX_UNLOCK(xs_fileinfowin); + XS_MUTEX_UNLOCK(xs_status); + return; + } + XS_MUTEX_UNLOCK(xs_status); - xs_fileinfostil = xs_stil_get(tmpFilename); + xs_fileinfostil = xs_stil_get(tmpFilename); #ifdef AUDACIOUS_PLUGIN - g_free(tmpFilename); + g_free(tmpFilename); #endif - /* Check if there already is an open fileinfo window */ - if (xs_fileinfowin) - gdk_window_raise(xs_fileinfowin->window); - else { - xs_fileinfowin = create_xs_fileinfowin(); + /* Check if there already is an open fileinfo window */ + if (xs_fileinfowin) + gdk_window_raise(xs_fileinfowin->window); + else { + xs_fileinfowin = create_xs_fileinfowin(); #ifndef AUDACIOUS_PLUGIN - XS_SIGNAL_CONNECT(gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))), - "value_changed", xs_fileinfo_setsong, NULL); + XS_SIGNAL_CONNECT(gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))), + "value_changed", xs_fileinfo_setsong, NULL); #endif - } + } - /* Delete current items */ - tmpOptionMenu = LUW("fileinfo_sub_tune"); - tmpMenu = gtk_option_menu_get_menu(GTK_OPTION_MENU(tmpOptionMenu)); - gtk_widget_destroy(tmpMenu); - gtk_option_menu_remove_menu(GTK_OPTION_MENU(tmpOptionMenu)); - tmpMenu = gtk_menu_new(); + /* Delete current items */ + tmpOptionMenu = LUW("fileinfo_sub_tune"); + tmpMenu = gtk_option_menu_get_menu(GTK_OPTION_MENU(tmpOptionMenu)); + gtk_widget_destroy(tmpMenu); + gtk_option_menu_remove_menu(GTK_OPTION_MENU(tmpOptionMenu)); + tmpMenu = gtk_menu_new(); - /* Set the generic song information */ - tmpFilename = XS_CS_FILENAME(pcFilename); - gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), tmpFilename); - g_free(tmpFilename); - gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), tmpInfo->sidName); - gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), tmpInfo->sidComposer); - gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), tmpInfo->sidCopyright); + /* Set the generic song information */ + tmpFilename = XS_CS_FILENAME(pcFilename); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), tmpFilename); + g_free(tmpFilename); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), tmpInfo->sidName); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), tmpInfo->sidComposer); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), tmpInfo->sidCopyright); - /* Main tune - the pseudo tune */ - tmpMenuItem = gtk_menu_item_new_with_label(_("General info")); - gtk_widget_show(tmpMenuItem); - gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); - if (xs_fileinfostil) - tmpNode = xs_fileinfostil->subTunes[0]; - else - tmpNode = NULL; - XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode); + /* Main tune - the pseudo tune */ + tmpMenuItem = gtk_menu_item_new_with_label(_("General info")); + gtk_widget_show(tmpMenuItem); + gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); + if (xs_fileinfostil) + tmpNode = xs_fileinfostil->subTunes[0]; + else + tmpNode = NULL; + XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode); - /* Other menu items */ - for (n = 1; n <= tmpInfo->nsubTunes; n++) { - if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) { - gboolean isSet = FALSE; - tmpNode = xs_fileinfostil->subTunes[n]; - - g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); + /* Other menu items */ + for (n = 1; n <= tmpInfo->nsubTunes; n++) { + if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) { + gboolean isSet = FALSE; + tmpNode = xs_fileinfostil->subTunes[n]; + + g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); - if (tmpNode->name) { - xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->name); - isSet = TRUE; - } + if (tmpNode->name) { + xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->name); + isSet = TRUE; + } - if (tmpNode->title) { - xs_pnstrcat(tmpStr, sizeof(tmpStr), - isSet ? " [*]" : tmpNode->title); - isSet = TRUE; - } + if (tmpNode->title) { + xs_pnstrcat(tmpStr, sizeof(tmpStr), + isSet ? " [*]" : tmpNode->title); + isSet = TRUE; + } - if (tmpNode->info) { - xs_pnstrcat(tmpStr, sizeof(tmpStr), " [!]"); - isSet = TRUE; - } + if (tmpNode->info) { + xs_pnstrcat(tmpStr, sizeof(tmpStr), " [!]"); + isSet = TRUE; + } - if (!isSet) - xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); + if (!isSet) + xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); - tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); - gtk_widget_show(tmpMenuItem); - gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); - XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode); - } + tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); + gtk_widget_show(tmpMenuItem); + gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); + XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode); + } - } + } - gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu); - gtk_widget_show(tmpOptionMenu); + gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu); + gtk_widget_show(tmpOptionMenu); - /* Set the subtune information */ - xs_fileinfo_subtune(tmpOptionMenu, NULL); + /* Set the subtune information */ + xs_fileinfo_subtune(tmpOptionMenu, NULL); - /* Free temporary tuneinfo */ - xs_tuneinfo_free(tmpInfo); + /* Free temporary tuneinfo */ + xs_tuneinfo_free(tmpInfo); - /* Show the window */ - gtk_widget_show(xs_fileinfowin); + /* Show the window */ + gtk_widget_show(xs_fileinfowin); - XS_MUTEX_UNLOCK(xs_fileinfowin); + XS_MUTEX_UNLOCK(xs_fileinfowin); #ifndef AUDACIOUS_PLUGIN - xs_fileinfo_update(); + xs_fileinfo_update(); #endif } diff -r 04ea91a61225 -r b0743dc9165d src/xs_fileinfo.h --- a/src/xs_fileinfo.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_fileinfo.h Wed Apr 02 22:10:05 2008 +0300 @@ -7,12 +7,12 @@ extern "C" { #endif -gint xs_stil_init(void); -void xs_stil_close(void); +gint xs_stil_init(void); +void xs_stil_close(void); #ifndef AUDACIOUS_PLUGIN -void xs_fileinfo_update(void); +void xs_fileinfo_update(void); #endif -void xs_fileinfo(gchar *); +void xs_fileinfo(gchar *); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_filter.c --- a/src/xs_filter.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_filter.c Wed Apr 02 22:10:05 2008 +0300 @@ -25,60 +25,60 @@ /* Let's do some preprocessor magic :) */ #define XS_FVAR(T, P, K) g ## K ## int ## P *sp_ ## T ## P , *dp_ ## T ## P -#define XS_FILTER1(T, P, K, Q) \ - dataSize /= sizeof(g ## K ## int ## P); \ - sp_ ## T ## P = (g ## K ## int ## P *) srcBuf; \ - dp_ ## T ## P = (g ## K ## int ## P *) destBuf; \ - while (dataSize-- > 0) { \ - for (tmp = 0, i = 0; i < oversampleFactor; i++) \ - tmp += (gint32) ((gint ## P) (*(sp_ ## T ## P ++) Q)); \ - xs_filter_mbn = (tmp + xs_filter_mbn) / (oversampleFactor + 1); \ - *(dp_ ## T ## P ++) = ((g ## K ## int ## P) xs_filter_mbn) Q ; \ - } +#define XS_FILTER1(T, P, K, Q) \ + dataSize /= sizeof(g ## K ## int ## P); \ + sp_ ## T ## P = (g ## K ## int ## P *) srcBuf; \ + dp_ ## T ## P = (g ## K ## int ## P *) destBuf; \ + while (dataSize-- > 0) { \ + for (tmp = 0, i = 0; i < oversampleFactor; i++) \ + tmp += (gint32) ((gint ## P) (*(sp_ ## T ## P ++) Q)); \ + xs_filter_mbn = (tmp + xs_filter_mbn) / (oversampleFactor + 1); \ + *(dp_ ## T ## P ++) = ((g ## K ## int ## P) xs_filter_mbn) Q ; \ + } static gint32 xs_filter_mbn = 0; gint xs_filter_rateconv(void *destBuf, void *srcBuf, const AFormat audioFormat, - const gint oversampleFactor, const gint bufSize) + const gint oversampleFactor, const gint bufSize) { - static gint32 tmp; - XS_FVAR(s, 8,); - XS_FVAR(u, 8, u); - XS_FVAR(s, 16,); - XS_FVAR(u, 16, u); - gint i; - gint dataSize = bufSize; + static gint32 tmp; + XS_FVAR(s, 8,); + XS_FVAR(u, 8, u); + XS_FVAR(s, 16,); + XS_FVAR(u, 16, u); + gint i; + gint dataSize = bufSize; - if (dataSize <= 0) - return dataSize; + if (dataSize <= 0) + return dataSize; - switch (audioFormat) { - case FMT_U8: - XS_FILTER1(u, 8, u, ^0x80) - break; + switch (audioFormat) { + case FMT_U8: + XS_FILTER1(u, 8, u, ^0x80) + break; - case FMT_S8: - XS_FILTER1(s, 8,,) - break; + case FMT_S8: + XS_FILTER1(s, 8,,) + break; - case FMT_U16_BE: - case FMT_U16_LE: - case FMT_U16_NE: - XS_FILTER1(u, 16, u, ^0x8000) - break; + case FMT_U16_BE: + case FMT_U16_LE: + case FMT_U16_NE: + XS_FILTER1(u, 16, u, ^0x8000) + break; - case FMT_S16_BE: - case FMT_S16_LE: - case FMT_S16_NE: - XS_FILTER1(s, 16,,) - break; + case FMT_S16_BE: + case FMT_S16_LE: + case FMT_S16_NE: + XS_FILTER1(s, 16,,) + break; - default: - return -1; - } + default: + return -1; + } - return 0; + return 0; } diff -r 04ea91a61225 -r b0743dc9165d src/xs_filter.h --- a/src/xs_filter.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_filter.h Wed Apr 02 22:10:05 2008 +0300 @@ -11,9 +11,9 @@ typedef struct { } t_xs_filter; -void xs_filter_init(t_xs_filter *); +void xs_filter_init(t_xs_filter *); */ -gint xs_filter_rateconv(void *, void *, const AFormat, const gint, const gint); +gint xs_filter_rateconv(void *, void *, const AFormat, const gint, const gint); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_init.c --- a/src/xs_init.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_init.c Wed Apr 02 22:10:05 2008 +0300 @@ -26,29 +26,29 @@ InputPlugin xs_plugin_ip = { - NULL, /* FILLED BY XMMS */ - NULL, /* FILLED BY XMMS */ - PACKAGE_STRING, /* Plugin description */ - xs_init, /* Initialization */ - xs_about, /* Show aboutbox */ - xs_configure, /* Show/edit configuration */ - xs_is_our_file, /* Check file */ - NULL, /* Scan directory */ - xs_play_file, /* Play given file */ - xs_stop, /* Stop playing */ - xs_pause, /* Pause playing */ - xs_seek, /* Seek time */ - NULL, /* Set equalizer */ - xs_get_time, /* Get playing time */ - NULL, /* Get volume */ - NULL, /* Set volume */ - xs_close, /* Cleanup */ - NULL, /* OBSOLETE! */ - NULL, /* Send data to Visualization plugin */ - NULL, NULL, /* FILLED BY XMMS */ - xs_get_song_info, /* Get song title and length */ - xs_fileinfo, /* Show file-information dialog */ - NULL /* FILLED BY XMMS */ + NULL, /* FILLED BY XMMS */ + NULL, /* FILLED BY XMMS */ + PACKAGE_STRING, /* Plugin description */ + xs_init, /* Initialization */ + xs_about, /* Show aboutbox */ + xs_configure, /* Show/edit configuration */ + xs_is_our_file, /* Check file */ + NULL, /* Scan directory */ + xs_play_file, /* Play given file */ + xs_stop, /* Stop playing */ + xs_pause, /* Pause playing */ + xs_seek, /* Seek time */ + NULL, /* Set equalizer */ + xs_get_time, /* Get playing time */ + NULL, /* Get volume */ + NULL, /* Set volume */ + xs_close, /* Cleanup */ + NULL, /* OBSOLETE! */ + NULL, /* Send data to Visualization plugin */ + NULL, NULL, /* FILLED BY XMMS */ + xs_get_song_info, /* Get song title and length */ + xs_fileinfo, /* Show file-information dialog */ + NULL /* FILLED BY XMMS */ }; @@ -58,6 +58,6 @@ */ InputPlugin *get_iplugin_info(void) { - bindtextdomain(PACKAGE, LOCALEDIR); - return &xs_plugin_ip; + bindtextdomain(PACKAGE, LOCALEDIR); + return &xs_plugin_ip; } diff -r 04ea91a61225 -r b0743dc9165d src/xs_length.c --- a/src/xs_length.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_length.c Wed Apr 02 22:10:05 2008 +0300 @@ -32,11 +32,11 @@ */ static void xs_sldb_node_free(sldb_node_t *node) { - if (node) { - /* Nothing much to do here ... */ - g_free(node->lengths); - g_free(node); - } + if (node) { + /* Nothing much to do here ... */ + g_free(node->lengths); + g_free(node); + } } @@ -44,19 +44,19 @@ */ static void xs_sldb_node_insert(xs_sldb_t *db, sldb_node_t *node) { - assert(db); + assert(db); - if (db->nodes) { - /* The first node's prev points to last node */ - LPREV = db->nodes->prev; /* New node's prev = Previous last node */ - db->nodes->prev->next = node; /* Previous last node's next = New node */ - db->nodes->prev = node; /* New last node = New node */ - LNEXT = NULL; /* But next is NULL! */ - } else { - db->nodes = node; /* First node ... */ - LPREV = node; /* ... it's also last */ - LNEXT = NULL; /* But next is NULL! */ - } + if (db->nodes) { + /* The first node's prev points to last node */ + LPREV = db->nodes->prev; /* New node's prev = Previous last node */ + db->nodes->prev->next = node; /* Previous last node's next = New node */ + db->nodes->prev = node; /* New last node = New node */ + LNEXT = NULL; /* But next is NULL! */ + } else { + db->nodes = node; /* First node ... */ + LPREV = node; /* ... it's also last */ + LNEXT = NULL; /* But next is NULL! */ + } } @@ -64,37 +64,37 @@ */ static gint xs_sldb_gettime(gchar *str, size_t *pos) { - gint result, tmp; + gint result, tmp; - /* Check if it starts with a digit */ - if (isdigit(str[*pos])) { - /* Get minutes-field */ - result = 0; - while (isdigit(str[*pos])) - result = (result * 10) + (str[(*pos)++] - '0'); + /* Check if it starts with a digit */ + if (isdigit(str[*pos])) { + /* Get minutes-field */ + result = 0; + while (isdigit(str[*pos])) + result = (result * 10) + (str[(*pos)++] - '0'); - result *= 60; + result *= 60; - /* Check the field separator char */ - if (str[*pos] == ':') { - /* Get seconds-field */ - (*pos)++; - tmp = 0; - while (isdigit(str[*pos])) { - tmp = (tmp * 10) + (str[(*pos)++] - '0'); - } + /* Check the field separator char */ + if (str[*pos] == ':') { + /* Get seconds-field */ + (*pos)++; + tmp = 0; + while (isdigit(str[*pos])) { + tmp = (tmp * 10) + (str[(*pos)++] - '0'); + } - result += tmp; - } else - result = -2; - } else - result = -1; + result += tmp; + } else + result = -2; + } else + result = -1; - /* Ignore and skip the possible attributes */ - while (str[*pos] && !isspace(str[*pos])) - (*pos)++; + /* Ignore and skip the possible attributes */ + while (str[*pos] && !isspace(str[*pos])) + (*pos)++; - return result; + return result; } @@ -102,90 +102,90 @@ */ sldb_node_t * xs_sldb_read_entry(gchar *inLine) { - size_t linePos; - gint i; - gboolean isOK; - sldb_node_t *tmnode; + size_t linePos; + gint i; + gboolean isOK; + sldb_node_t *tmnode; - /* Allocate new node */ - tmnode = (sldb_node_t *) g_malloc0(sizeof(sldb_node_t)); - if (!tmnode) { - xs_error("Error allocating new node. Fatal error.\n"); - return NULL; - } + /* Allocate new node */ + tmnode = (sldb_node_t *) g_malloc0(sizeof(sldb_node_t)); + if (!tmnode) { + xs_error("Error allocating new node. Fatal error.\n"); + return NULL; + } - /* Get hash value */ - linePos = 0; - for (i = 0; i < XS_MD5HASH_LENGTH; i++, linePos += 2) { - gint tmpu; - sscanf(&inLine[linePos], "%2x", &tmpu); - tmnode->md5Hash[i] = tmpu; - } - - /* Get playtimes */ - if (inLine[linePos] != 0) { - if (inLine[linePos] != '=') { - xs_error("'=' expected on column #%d.\n", linePos); - xs_sldb_node_free(tmnode); - return NULL; - } else { - size_t tmpLen, savePos; - - /* First playtime is after '=' */ - savePos = ++linePos; - tmpLen = strlen(inLine); - - /* Get number of sub-tune lengths */ - isOK = TRUE; - while ((linePos < tmpLen) && isOK) { - xs_findnext(inLine, &linePos); + /* Get hash value */ + linePos = 0; + for (i = 0; i < XS_MD5HASH_LENGTH; i++, linePos += 2) { + gint tmpu; + sscanf(&inLine[linePos], "%2x", &tmpu); + tmnode->md5Hash[i] = tmpu; + } + + /* Get playtimes */ + if (inLine[linePos] != 0) { + if (inLine[linePos] != '=') { + xs_error("'=' expected on column #%d.\n", linePos); + xs_sldb_node_free(tmnode); + return NULL; + } else { + size_t tmpLen, savePos; + + /* First playtime is after '=' */ + savePos = ++linePos; + tmpLen = strlen(inLine); + + /* Get number of sub-tune lengths */ + isOK = TRUE; + while ((linePos < tmpLen) && isOK) { + xs_findnext(inLine, &linePos); - if (xs_sldb_gettime(inLine, &linePos) >= 0) - tmnode->nlengths++; - else - isOK = FALSE; - } - - /* Allocate memory for lengths */ - if (tmnode->nlengths > 0) { - tmnode->lengths = (gint *) g_malloc0(tmnode->nlengths * sizeof(gint)); - if (!tmnode->lengths) { - xs_error("Could not allocate memory for node.\n"); - xs_sldb_node_free(tmnode); - return NULL; - } - } else { - xs_sldb_node_free(tmnode); - return NULL; - } - - /* Read lengths in */ - i = 0; - linePos = savePos; - isOK = TRUE; - while ((linePos < tmpLen) && (i < tmnode->nlengths) && isOK) { - gint l; - - xs_findnext(inLine, &linePos); + if (xs_sldb_gettime(inLine, &linePos) >= 0) + tmnode->nlengths++; + else + isOK = FALSE; + } + + /* Allocate memory for lengths */ + if (tmnode->nlengths > 0) { + tmnode->lengths = (gint *) g_malloc0(tmnode->nlengths * sizeof(gint)); + if (!tmnode->lengths) { + xs_error("Could not allocate memory for node.\n"); + xs_sldb_node_free(tmnode); + return NULL; + } + } else { + xs_sldb_node_free(tmnode); + return NULL; + } + + /* Read lengths in */ + i = 0; + linePos = savePos; + isOK = TRUE; + while ((linePos < tmpLen) && (i < tmnode->nlengths) && isOK) { + gint l; + + xs_findnext(inLine, &linePos); - l = xs_sldb_gettime(inLine, &linePos); - if (l >= 0) - tmnode->lengths[i] = l; - else - isOK = FALSE; + l = xs_sldb_gettime(inLine, &linePos); + if (l >= 0) + tmnode->lengths[i] = l; + else + isOK = FALSE; - i++; - } + i++; + } - if (!isOK) { - xs_sldb_node_free(tmnode); - return NULL; - } else - return tmnode; - } - } + if (!isOK) { + xs_sldb_node_free(tmnode); + return NULL; + } else + return tmnode; + } + } - return NULL; + return NULL; } @@ -193,56 +193,56 @@ */ gint xs_sldb_read(xs_sldb_t *db, const gchar *dbFilename) { - FILE *inFile; - gchar inLine[XS_BUF_SIZE]; - size_t lineNum; - sldb_node_t *tmnode; - assert(db); + FILE *inFile; + gchar inLine[XS_BUF_SIZE]; + size_t lineNum; + sldb_node_t *tmnode; + assert(db); - /* Try to open the file */ - if ((inFile = fopen(dbFilename, "ra")) == NULL) { - xs_error("Could not open SongLengthDB '%s'\n", dbFilename); - return -1; - } + /* Try to open the file */ + if ((inFile = fopen(dbFilename, "ra")) == NULL) { + xs_error("Could not open SongLengthDB '%s'\n", dbFilename); + return -1; + } - /* Read and parse the data */ - lineNum = 0; + /* Read and parse the data */ + lineNum = 0; - while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { - size_t linePos = 0; - lineNum++; - - xs_findnext(inLine, &linePos); + while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { + size_t linePos = 0; + lineNum++; + + xs_findnext(inLine, &linePos); - /* Check if it is datafield */ - if (isxdigit(inLine[linePos])) { - /* Check the length of the hash */ - gint hashLen; - for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++); + /* Check if it is datafield */ + if (isxdigit(inLine[linePos])) { + /* Check the length of the hash */ + gint hashLen; + for (hashLen = 0; inLine[linePos] && isxdigit(inLine[linePos]); hashLen++, linePos++); - if (hashLen != XS_MD5HASH_LENGTH_CH) { - xs_error("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n", - dbFilename, lineNum); - } else { - /* Parse and add node to db */ - if ((tmnode = xs_sldb_read_entry(inLine)) != NULL) { - xs_sldb_node_insert(db, tmnode); - } else { - xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n", - dbFilename, lineNum); - } - } - } else if ((inLine[linePos] != ';') && (inLine[linePos] != '[') && (inLine[linePos] != 0)) { - xs_error("Invalid line in SongLengthDB file '%s' line #%d\n", - dbFilename, lineNum); - } + if (hashLen != XS_MD5HASH_LENGTH_CH) { + xs_error("Invalid MD5-hash in SongLengthDB file '%s' line #%d!\n", + dbFilename, lineNum); + } else { + /* Parse and add node to db */ + if ((tmnode = xs_sldb_read_entry(inLine)) != NULL) { + xs_sldb_node_insert(db, tmnode); + } else { + xs_error("Invalid entry in SongLengthDB file '%s' line #%d!\n", + dbFilename, lineNum); + } + } + } else if ((inLine[linePos] != ';') && (inLine[linePos] != '[') && (inLine[linePos] != 0)) { + xs_error("Invalid line in SongLengthDB file '%s' line #%d\n", + dbFilename, lineNum); + } - } + } - /* Close the file */ - fclose(inFile); + /* Close the file */ + fclose(inFile); - return 0; + return 0; } @@ -253,13 +253,13 @@ */ static gint xs_sldb_cmphash(xs_md5hash_t testHash1, xs_md5hash_t testHash2) { - gint i, d; + gint i, d; - /* Compute difference of hashes */ - for (i = 0, d = 0; (i < XS_MD5HASH_LENGTH) && !d; i++) - d = (testHash1[i] - testHash2[i]); + /* Compute difference of hashes */ + for (i = 0, d = 0; (i < XS_MD5HASH_LENGTH) && !d; i++) + d = (testHash1[i] - testHash2[i]); - return d; + return d; } @@ -267,10 +267,10 @@ */ static gint xs_sldb_cmp(const void *node1, const void *node2) { - /* We assume here that we never ever get NULL-pointers or similar */ - return xs_sldb_cmphash( - (*(sldb_node_t **) node1)->md5Hash, - (*(sldb_node_t **) node2)->md5Hash); + /* We assume here that we never ever get NULL-pointers or similar */ + return xs_sldb_cmphash( + (*(sldb_node_t **) node1)->md5Hash, + (*(sldb_node_t **) node2)->md5Hash); } @@ -278,44 +278,44 @@ */ gint xs_sldb_index(xs_sldb_t * db) { - sldb_node_t *pCurr; - size_t i; - assert(db); + sldb_node_t *pCurr; + size_t i; + assert(db); - /* Free old index */ - if (db->pindex) { - g_free(db->pindex); - db->pindex = NULL; - } + /* Free old index */ + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; + } - /* Get size of db */ - pCurr = db->nodes; - db->n = 0; - while (pCurr) { - db->n++; - pCurr = pCurr->next; - } + /* Get size of db */ + pCurr = db->nodes; + db->n = 0; + while (pCurr) { + db->n++; + pCurr = pCurr->next; + } - /* Check number of nodes */ - if (db->n > 0) { - /* Allocate memory for index-table */ - db->pindex = (sldb_node_t **) g_malloc(sizeof(sldb_node_t *) * db->n); - if (!db->pindex) - return -1; + /* Check number of nodes */ + if (db->n > 0) { + /* Allocate memory for index-table */ + db->pindex = (sldb_node_t **) g_malloc(sizeof(sldb_node_t *) * db->n); + if (!db->pindex) + return -1; - /* Get node-pointers to table */ - i = 0; - pCurr = db->nodes; - while (pCurr && (i < db->n)) { - db->pindex[i++] = pCurr; - pCurr = pCurr->next; - } + /* Get node-pointers to table */ + i = 0; + pCurr = db->nodes; + while (pCurr && (i < db->n)) { + db->pindex[i++] = pCurr; + pCurr = pCurr->next; + } - /* Sort the indexes */ - qsort(db->pindex, db->n, sizeof(sldb_node_t *), xs_sldb_cmp); - } + /* Sort the indexes */ + qsort(db->pindex, db->n, sizeof(sldb_node_t *), xs_sldb_cmp); + } - return 0; + return 0; } @@ -323,172 +323,172 @@ */ void xs_sldb_free(xs_sldb_t * db) { - sldb_node_t *pCurr, *next; + sldb_node_t *pCurr, *next; - if (!db) - return; + if (!db) + return; - /* Free the memory allocated for nodes */ - pCurr = db->nodes; - while (pCurr) { - next = pCurr->next; - xs_sldb_node_free(pCurr); - pCurr = next; - } + /* Free the memory allocated for nodes */ + pCurr = db->nodes; + while (pCurr) { + next = pCurr->next; + xs_sldb_node_free(pCurr); + pCurr = next; + } - db->nodes = NULL; + db->nodes = NULL; - /* Free memory allocated for index */ - if (db->pindex) { - g_free(db->pindex); - db->pindex = NULL; - } + /* Free memory allocated for index */ + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; + } - /* Free structure */ - db->n = 0; - g_free(db); + /* Free structure */ + db->n = 0; + g_free(db); } /* Compute md5hash of given SID-file */ typedef struct { - gchar magicID[4]; /* "PSID" / "RSID" magic identifier */ - guint16 version, /* Version number */ - dataOffset, /* Start of actual c64 data in file */ - loadAddress, /* Loading address */ - initAddress, /* Initialization address */ - playAddress, /* Play one frame */ - nSongs, /* Number of subsongs */ - startSong; /* Default starting song */ - guint32 speed; /* Speed */ - gchar sidName[32]; /* Descriptive text-fields, ASCIIZ */ - gchar sidAuthor[32]; - gchar sidCopyright[32]; + gchar magicID[4]; /* "PSID" / "RSID" magic identifier */ + guint16 version, /* Version number */ + dataOffset, /* Start of actual c64 data in file */ + loadAddress, /* Loading address */ + initAddress, /* Initialization address */ + playAddress, /* Play one frame */ + nSongs, /* Number of subsongs */ + startSong; /* Default starting song */ + guint32 speed; /* Speed */ + gchar sidName[32]; /* Descriptive text-fields, ASCIIZ */ + gchar sidAuthor[32]; + gchar sidCopyright[32]; } psidv1_header_t; typedef struct { - guint16 flags; /* Flags */ - guint8 startPage, pageLength; - guint16 reserved; + guint16 flags; /* Flags */ + guint8 startPage, pageLength; + guint16 reserved; } psidv2_header_t; static gint xs_get_sid_hash(const gchar *filename, xs_md5hash_t hash) { - xs_file_t *inFile; - xs_md5state_t inState; - psidv1_header_t psidH; - psidv2_header_t psidH2; - guint8 *songData; - guint8 ib8[2], i8; - gint index, result; + xs_file_t *inFile; + xs_md5state_t inState; + psidv1_header_t psidH; + psidv2_header_t psidH2; + guint8 *songData; + guint8 ib8[2], i8; + gint index, result; - /* Try to open the file */ - if ((inFile = xs_fopen(filename, "rb")) == NULL) - return -1; + /* Try to open the file */ + if ((inFile = xs_fopen(filename, "rb")) == NULL) + return -1; - /* Read PSID header in */ - xs_fread(psidH.magicID, sizeof(psidH.magicID), 1, inFile); - if (strncmp(psidH.magicID, "PSID", 4) && strncmp(psidH.magicID, "RSID", 4)) { - xs_fclose(inFile); - xs_error("Not a PSID or RSID file '%s'\n", filename); - return -2; - } + /* Read PSID header in */ + xs_fread(psidH.magicID, sizeof(psidH.magicID), 1, inFile); + if (strncmp(psidH.magicID, "PSID", 4) && strncmp(psidH.magicID, "RSID", 4)) { + xs_fclose(inFile); + xs_error("Not a PSID or RSID file '%s'\n", filename); + return -2; + } - psidH.version = xs_fread_be16(inFile); - psidH.dataOffset = xs_fread_be16(inFile); - psidH.loadAddress = xs_fread_be16(inFile); - psidH.initAddress = xs_fread_be16(inFile); - psidH.playAddress = xs_fread_be16(inFile); - psidH.nSongs = xs_fread_be16(inFile); - psidH.startSong = xs_fread_be16(inFile); - psidH.speed = xs_fread_be32(inFile); + psidH.version = xs_fread_be16(inFile); + psidH.dataOffset = xs_fread_be16(inFile); + psidH.loadAddress = xs_fread_be16(inFile); + psidH.initAddress = xs_fread_be16(inFile); + psidH.playAddress = xs_fread_be16(inFile); + psidH.nSongs = xs_fread_be16(inFile); + psidH.startSong = xs_fread_be16(inFile); + psidH.speed = xs_fread_be32(inFile); - xs_fread(psidH.sidName, sizeof(gchar), sizeof(psidH.sidName), inFile); - xs_fread(psidH.sidAuthor, sizeof(gchar), sizeof(psidH.sidAuthor), inFile); - xs_fread(psidH.sidCopyright, sizeof(gchar), sizeof(psidH.sidCopyright), inFile); - - if (xs_feof(inFile) || xs_ferror(inFile)) { - xs_fclose(inFile); - xs_error("Error reading SID file header from '%s'\n", filename); - return -4; - } - - /* Check if we need to load PSIDv2NG header ... */ - psidH2.flags = 0; /* Just silence a stupid gcc warning */ - - if (psidH.version == 2) { - /* Yes, we need to */ - psidH2.flags = xs_fread_be16(inFile); - psidH2.startPage = xs_fgetc(inFile); - psidH2.pageLength = xs_fgetc(inFile); - psidH2.reserved = xs_fread_be16(inFile); - } + xs_fread(psidH.sidName, sizeof(gchar), sizeof(psidH.sidName), inFile); + xs_fread(psidH.sidAuthor, sizeof(gchar), sizeof(psidH.sidAuthor), inFile); + xs_fread(psidH.sidCopyright, sizeof(gchar), sizeof(psidH.sidCopyright), inFile); + + if (xs_feof(inFile) || xs_ferror(inFile)) { + xs_fclose(inFile); + xs_error("Error reading SID file header from '%s'\n", filename); + return -4; + } + + /* Check if we need to load PSIDv2NG header ... */ + psidH2.flags = 0; /* Just silence a stupid gcc warning */ + + if (psidH.version == 2) { + /* Yes, we need to */ + psidH2.flags = xs_fread_be16(inFile); + psidH2.startPage = xs_fgetc(inFile); + psidH2.pageLength = xs_fgetc(inFile); + psidH2.reserved = xs_fread_be16(inFile); + } - /* Allocate buffer */ - songData = (guint8 *) g_malloc(XS_SIDBUF_SIZE * sizeof(guint8)); - if (!songData) { - xs_fclose(inFile); - xs_error("Error allocating temp data buffer for file '%s'\n", filename); - return -3; - } + /* Allocate buffer */ + songData = (guint8 *) g_malloc(XS_SIDBUF_SIZE * sizeof(guint8)); + if (!songData) { + xs_fclose(inFile); + xs_error("Error allocating temp data buffer for file '%s'\n", filename); + return -3; + } - /* Read data to buffer */ - result = xs_fread(songData, sizeof(guint8), XS_SIDBUF_SIZE, inFile); - xs_fclose(inFile); + /* Read data to buffer */ + result = xs_fread(songData, sizeof(guint8), XS_SIDBUF_SIZE, inFile); + xs_fclose(inFile); - /* Initialize and start MD5-hash calculation */ - xs_md5_init(&inState); + /* Initialize and start MD5-hash calculation */ + xs_md5_init(&inState); - if (psidH.loadAddress == 0) { - /* Strip load address (2 first bytes) */ - xs_md5_append(&inState, &songData[2], result - 2); - } else { - /* Append "as is" */ - xs_md5_append(&inState, songData, result); - } + if (psidH.loadAddress == 0) { + /* Strip load address (2 first bytes) */ + xs_md5_append(&inState, &songData[2], result - 2); + } else { + /* Append "as is" */ + xs_md5_append(&inState, songData, result); + } - /* Free buffer */ - g_free(songData); + /* Free buffer */ + g_free(songData); - /* Append header data to hash */ -#define XSADDHASH(QDATAB) do { \ - ib8[0] = (QDATAB & 0xff); \ - ib8[1] = (QDATAB >> 8); \ - xs_md5_append(&inState, (guint8 *) &ib8, sizeof(ib8)); \ - } while (0) + /* Append header data to hash */ +#define XSADDHASH(QDATAB) do { \ + ib8[0] = (QDATAB & 0xff); \ + ib8[1] = (QDATAB >> 8); \ + xs_md5_append(&inState, (guint8 *) &ib8, sizeof(ib8)); \ + } while (0) - XSADDHASH(psidH.initAddress); - XSADDHASH(psidH.playAddress); - XSADDHASH(psidH.nSongs); + XSADDHASH(psidH.initAddress); + XSADDHASH(psidH.playAddress); + XSADDHASH(psidH.nSongs); #undef XSADDHASH - /* Append song speed data to hash */ - i8 = 0; - for (index = 0; (index < psidH.nSongs) && (index < 32); index++) { - i8 = (psidH.speed & (1 << index)) ? 60 : 0; - xs_md5_append(&inState, &i8, sizeof(i8)); - } + /* Append song speed data to hash */ + i8 = 0; + for (index = 0; (index < psidH.nSongs) && (index < 32); index++) { + i8 = (psidH.speed & (1 << index)) ? 60 : 0; + xs_md5_append(&inState, &i8, sizeof(i8)); + } - /* Rest of songs (more than 32) */ - for (index = 32; index < psidH.nSongs; index++) { - xs_md5_append(&inState, &i8, sizeof(i8)); - } + /* Rest of songs (more than 32) */ + for (index = 32; index < psidH.nSongs; index++) { + xs_md5_append(&inState, &i8, sizeof(i8)); + } - /* PSIDv2NG specific */ - if (psidH.version == 2) { - /* SEE SIDPLAY HEADERS FOR INFO */ - i8 = (psidH2.flags >> 2) & 3; - if (i8 == 2) - xs_md5_append(&inState, &i8, sizeof(i8)); - } + /* PSIDv2NG specific */ + if (psidH.version == 2) { + /* SEE SIDPLAY HEADERS FOR INFO */ + i8 = (psidH2.flags >> 2) & 3; + if (i8 == 2) + xs_md5_append(&inState, &i8, sizeof(i8)); + } - /* Calculate the hash */ - xs_md5_finish(&inState, hash); + /* Calculate the hash */ + xs_md5_finish(&inState, hash); - return 0; + return 0; } @@ -496,24 +496,24 @@ */ sldb_node_t *xs_sldb_get(xs_sldb_t *db, const gchar *filename) { - sldb_node_t keyItem, *key, **item; + sldb_node_t keyItem, *key, **item; - /* Check the database pointers */ - if (!db || !db->nodes || !db->pindex) - return NULL; + /* Check the database pointers */ + if (!db || !db->nodes || !db->pindex) + return NULL; - /* Get the hash and then look up from db */ - if (xs_get_sid_hash(filename, keyItem.md5Hash) == 0) { - key = &keyItem; - item = bsearch(&key, db->pindex, db->n, - sizeof(db->pindex[0]), xs_sldb_cmp); - - if (item) - return *item; - else - return NULL; - } else - return NULL; + /* Get the hash and then look up from db */ + if (xs_get_sid_hash(filename, keyItem.md5Hash) == 0) { + key = &keyItem; + item = bsearch(&key, db->pindex, db->n, + sizeof(db->pindex[0]), xs_sldb_cmp); + + if (item) + return *item; + else + return NULL; + } else + return NULL; } diff -r 04ea91a61225 -r b0743dc9165d src/xs_length.h --- a/src/xs_length.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_length.h Wed Apr 02 22:10:05 2008 +0300 @@ -11,26 +11,26 @@ /* Types */ typedef struct _sldb_node_t { - xs_md5hash_t md5Hash; /* 128-bit MD5 hash-digest */ - gint nlengths; /* Number of lengths */ - gint *lengths; /* Lengths in seconds */ - struct _sldb_node_t *prev, *next; + xs_md5hash_t md5Hash; /* 128-bit MD5 hash-digest */ + gint nlengths; /* Number of lengths */ + gint *lengths; /* Lengths in seconds */ + struct _sldb_node_t *prev, *next; } sldb_node_t; typedef struct { - sldb_node_t *nodes, - **pindex; - size_t n; + sldb_node_t *nodes, + **pindex; + size_t n; } xs_sldb_t; /* Functions */ -gint xs_sldb_read(xs_sldb_t *, const gchar *); -gint xs_sldb_index(xs_sldb_t *); -void xs_sldb_free(xs_sldb_t *); -sldb_node_t * xs_sldb_get(xs_sldb_t *, const gchar *); +gint xs_sldb_read(xs_sldb_t *, const gchar *); +gint xs_sldb_index(xs_sldb_t *); +void xs_sldb_free(xs_sldb_t *); +sldb_node_t * xs_sldb_get(xs_sldb_t *, const gchar *); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_md5.c --- a/src/xs_md5.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_md5.c Wed Apr 02 22:10:05 2008 +0300 @@ -13,17 +13,17 @@ #if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define xs_md5_bytereverse(buf, len) /* Nothing */ +#define xs_md5_bytereverse(buf, len) /* Nothing */ #else #if G_BYTE_ORDER == G_BIG_ENDIAN static void xs_md5_bytereverse(guint8 *buf, guint l) { - guint32 t; - do { - t = (guint32) ((guint) buf[3] << 8 | buf[2]) << 16 | ((guint) buf[1] << 8 | buf[0]); - *(guint32 *) buf = t; - buf += sizeof(guint32); - } while (--l); + guint32 t; + do { + t = (guint32) ((guint) buf[3] << 8 | buf[2]) << 16 | ((guint) buf[1] << 8 | buf[0]); + *(guint32 *) buf = t; + buf += sizeof(guint32); + } while (--l); } #else #error Unsupported endianess! @@ -36,13 +36,13 @@ */ void xs_md5_init(xs_md5state_t *ctx) { - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; - ctx->bits[0] = 0; - ctx->bits[1] = 0; + ctx->bits[0] = 0; + ctx->bits[1] = 0; } @@ -55,89 +55,89 @@ #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) #define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) + ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) static void xs_md5_transform(guint32 buf[4], guint32 const in[16]) { - register guint32 a, b, c, d; + register guint32 a, b, c, d; - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } @@ -146,43 +146,43 @@ */ void xs_md5_append(xs_md5state_t *ctx, const guint8 *buf, guint len) { - guint32 t; + guint32 t; - /* Update bitcount */ - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((guint32) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; + /* Update bitcount */ + t = ctx->bits[0]; + if ((ctx->bits[0] = t + ((guint32) len << 3)) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - /* Handle any leading odd-sized chunks */ - if (t) { - guint8 *p = (guint8 *) ctx->in + t; + /* Handle any leading odd-sized chunks */ + if (t) { + guint8 *p = (guint8 *) ctx->in + t; - t = 64 - t; - if (len < t) { - memcpy(p, buf, len); - return; - } - memcpy(p, buf, t); - xs_md5_bytereverse(ctx->in, 16); - xs_md5_transform(ctx->buf, (guint32 *) ctx->in); - buf += t; - len -= t; - } + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + xs_md5_bytereverse(ctx->in, 16); + xs_md5_transform(ctx->buf, (guint32 *) ctx->in); + buf += t; + len -= t; + } - /* Process data in 64-byte chunks */ - while (len >= 64) { - memcpy(ctx->in, buf, 64); - xs_md5_bytereverse(ctx->in, 16); - xs_md5_transform(ctx->buf, (guint32 *) ctx->in); - buf += 64; - len -= 64; - } + /* Process data in 64-byte chunks */ + while (len >= 64) { + memcpy(ctx->in, buf, 64); + xs_md5_bytereverse(ctx->in, 16); + xs_md5_transform(ctx->buf, (guint32 *) ctx->in); + buf += 64; + len -= 64; + } - /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + /* Handle any remaining bytes of data. */ + memcpy(ctx->in, buf, len); } /* Final wrapup - pad to 64-byte boundary with the bit pattern @@ -190,41 +190,41 @@ */ void xs_md5_finish(xs_md5state_t *ctx, xs_md5hash_t digest) { - guint count; - guint8 *p; + guint count; + guint8 *p; - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - xs_md5_bytereverse(ctx->in, 16); - xs_md5_transform(ctx->buf, (guint32 *) ctx->in); + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + xs_md5_bytereverse(ctx->in, 16); + xs_md5_transform(ctx->buf, (guint32 *) ctx->in); - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - xs_md5_bytereverse(ctx->in, 14); + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + xs_md5_bytereverse(ctx->in, 14); - /* Append length in bits and transform */ - ((guint32 *) ctx->in)[14] = ctx->bits[0]; - ((guint32 *) ctx->in)[15] = ctx->bits[1]; + /* Append length in bits and transform */ + ((guint32 *) ctx->in)[14] = ctx->bits[0]; + ((guint32 *) ctx->in)[15] = ctx->bits[1]; - xs_md5_transform(ctx->buf, (guint32 *) ctx->in); - xs_md5_bytereverse((guint8 *) ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + xs_md5_transform(ctx->buf, (guint32 *) ctx->in); + xs_md5_bytereverse((guint8 *) ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ } diff -r 04ea91a61225 -r b0743dc9165d src/xs_md5.h --- a/src/xs_md5.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_md5.h Wed Apr 02 22:10:05 2008 +0300 @@ -10,13 +10,13 @@ /* Typedefs */ typedef struct md5_state_s { - guint32 bits[2]; /* message length in bits, lsw first */ - guint32 buf[4]; /* digest buffer */ - guint8 in[64]; /* accumulate block */ + guint32 bits[2]; /* message length in bits, lsw first */ + guint32 buf[4]; /* digest buffer */ + guint8 in[64]; /* accumulate block */ } xs_md5state_t; -#define XS_MD5HASH_LENGTH (16) -#define XS_MD5HASH_LENGTH_CH (XS_MD5HASH_LENGTH * 2) +#define XS_MD5HASH_LENGTH (16) +#define XS_MD5HASH_LENGTH_CH (XS_MD5HASH_LENGTH * 2) typedef guint8 xs_md5hash_t[XS_MD5HASH_LENGTH]; diff -r 04ea91a61225 -r b0743dc9165d src/xs_player.h --- a/src/xs_player.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_player.h Wed Apr 02 22:10:05 2008 +0300 @@ -11,45 +11,45 @@ struct xs_status_t; typedef struct { - gint plrIdent; - gboolean (*plrProbe)(xs_file_t *); - gboolean (*plrInit)(struct xs_status_t *); - void (*plrClose)(struct xs_status_t *); - gboolean (*plrInitSong)(struct xs_status_t *); - guint (*plrFillBuffer)(struct xs_status_t *, gchar *, guint); - gboolean (*plrLoadSID)(struct xs_status_t *, gchar *); - void (*plrDeleteSID)(struct xs_status_t *); - xs_tuneinfo_t* (*plrGetSIDInfo)(const gchar *); - gboolean (*plrUpdateSIDInfo)(struct xs_status_t *); - void (*plrFlush)(struct xs_status_t *); + gint plrIdent; + gboolean (*plrProbe)(xs_file_t *); + gboolean (*plrInit)(struct xs_status_t *); + void (*plrClose)(struct xs_status_t *); + gboolean (*plrInitSong)(struct xs_status_t *); + guint (*plrFillBuffer)(struct xs_status_t *, gchar *, guint); + gboolean (*plrLoadSID)(struct xs_status_t *, gchar *); + void (*plrDeleteSID)(struct xs_status_t *); + xs_tuneinfo_t* (*plrGetSIDInfo)(const gchar *); + gboolean (*plrUpdateSIDInfo)(struct xs_status_t *); + void (*plrFlush)(struct xs_status_t *); } xs_player_t; typedef struct xs_status_t { - gint audioFrequency, /* Audio settings */ - audioChannels, - audioBitsPerSample, - oversampleFactor; /* Factor of oversampling */ - AFormat audioFormat; - gboolean oversampleEnable; /* TRUE after sidEngine initialization, - if xs_cfg.oversampleEnable == TRUE and - emulation backend supports oversampling. - */ - void *sidEngine; /* SID-emulation internal engine data */ - xs_player_t *sidPlayer; /* Selected player engine */ - gboolean isError, isPlaying, isInitialized; - gint currSong, /* Current sub-tune */ - lastTime; + gint audioFrequency, /* Audio settings */ + audioChannels, + audioBitsPerSample, + oversampleFactor; /* Factor of oversampling */ + AFormat audioFormat; + gboolean oversampleEnable; /* TRUE after sidEngine initialization, + if xs_cfg.oversampleEnable == TRUE and + emulation backend supports oversampling. + */ + void *sidEngine; /* SID-emulation internal engine data */ + xs_player_t *sidPlayer; /* Selected player engine */ + gboolean isError, isPlaying, isInitialized; + gint currSong, /* Current sub-tune */ + lastTime; - xs_tuneinfo_t *tuneInfo; + xs_tuneinfo_t *tuneInfo; } xs_status_t; /* Global variables */ -extern InputPlugin xs_plugin_ip; +extern InputPlugin xs_plugin_ip; -extern xs_status_t xs_status; +extern xs_status_t xs_status; XS_MUTEX_H(xs_status); diff -r 04ea91a61225 -r b0743dc9165d src/xs_sidplay.h --- a/src/xs_sidplay.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_sidplay.h Wed Apr 02 22:10:05 2008 +0300 @@ -28,55 +28,55 @@ */ xs_tuneinfo_t *TFUNCTION(const gchar *sidFilename) { - xs_tuneinfo_t *pResult; - TTUNEINFO myInfo; - TTUNE *myTune; - guint8 *buf = NULL; - size_t bufSize = 0; + xs_tuneinfo_t *pResult; + TTUNEINFO myInfo; + TTUNE *myTune; + guint8 *buf = NULL; + size_t bufSize = 0; - /* Load file */ - if (!sidFilename) return NULL; + /* Load file */ + if (!sidFilename) return NULL; - if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) - return NULL; - - /* Check if the tune exists and is readable */ - if ((myTune = new TTUNE(buf, bufSize)) == NULL) { - g_free(buf); - return NULL; - } - g_free(buf); + if (xs_fload_buffer(sidFilename, &buf, &bufSize) != 0) + return NULL; + + /* Check if the tune exists and is readable */ + if ((myTune = new TTUNE(buf, bufSize)) == NULL) { + g_free(buf); + return NULL; + } + g_free(buf); - if (!myTune->getStatus()) { - delete myTune; - return NULL; - } + if (!myTune->getStatus()) { + delete myTune; + return NULL; + } - /* Get general tune information */ + /* Get general tune information */ #ifdef XS_SIDPLAY1_H - myTune->getInfo(myInfo); + myTune->getInfo(myInfo); #endif #ifdef XS_SIDPLAY2_H - myInfo = myTune->getInfo(); + myInfo = myTune->getInfo(); #endif - /* Allocate tuneinfo structure and set information */ - pResult = xs_tuneinfo_new(sidFilename, - myInfo.songs, myInfo.startSong, - myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], - myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, - myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel); - - /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, - * songSpeed and clockSpeed are "undefined" before song initialization, - * but in practice sidModel is known after getInfo() invocation... - * This of course does not take the sub-tune specific changes into account, - * but at least we have a reasonable guesstimate. - */ + /* Allocate tuneinfo structure and set information */ + pResult = xs_tuneinfo_new(sidFilename, + myInfo.songs, myInfo.startSong, + myInfo.infoString[0], myInfo.infoString[1], myInfo.infoString[2], + myInfo.loadAddr, myInfo.initAddr, myInfo.playAddr, + myInfo.dataFileLen, myInfo.formatString, myInfo.sidModel); + + /* NOTICE! libSIDPlay[12] headers specifically state that sidModel, + * songSpeed and clockSpeed are "undefined" before song initialization, + * but in practice sidModel is known after getInfo() invocation... + * This of course does not take the sub-tune specific changes into account, + * but at least we have a reasonable guesstimate. + */ - delete myTune; + delete myTune; - return pResult; + return pResult; } @@ -84,68 +84,68 @@ */ gboolean TFUNCTION2(xs_status_t *myStatus) { - TTUNEINFO myInfo; - TTUNE *myTune; - TENGINE *myEngine; - xs_tuneinfo_t *i; - - /* Check if we have required structures initialized */ - if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine) - return FALSE; + TTUNEINFO myInfo; + TTUNE *myTune; + TENGINE *myEngine; + xs_tuneinfo_t *i; + + /* Check if we have required structures initialized */ + if (!myStatus || !myStatus->tuneInfo || !myStatus->sidEngine) + return FALSE; - myEngine = (TENGINE *) myStatus->sidEngine; - myTune = myEngine->currTune; - if (!myTune) - return FALSE; + myEngine = (TENGINE *) myStatus->sidEngine; + myTune = myEngine->currTune; + if (!myTune) + return FALSE; - /* Get currently playing tune information */ + /* Get currently playing tune information */ #ifdef XS_SIDPLAY1_H - myTune->getInfo(myInfo); + myTune->getInfo(myInfo); #endif #ifdef XS_SIDPLAY2_H - myInfo = myTune->getInfo(); + myInfo = myTune->getInfo(); #endif - /* NOTICE! Here we assume that libSIDPlay[12] headers define - * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... - */ - i = myStatus->tuneInfo; - i->sidModel = myInfo.sidModel; + /* NOTICE! Here we assume that libSIDPlay[12] headers define + * SIDTUNE_SIDMODEL_* similarly to our enums in xs_config.h ... + */ + i = myStatus->tuneInfo; + i->sidModel = myInfo.sidModel; - if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { - gint tmpSpeed = -1; - - switch (myInfo.clockSpeed) { - case SIDTUNE_CLOCK_PAL: - tmpSpeed = XS_CLOCK_PAL; - break; - case SIDTUNE_CLOCK_NTSC: - tmpSpeed = XS_CLOCK_NTSC; - break; - case SIDTUNE_CLOCK_ANY: - tmpSpeed = XS_CLOCK_ANY; - break; - case SIDTUNE_CLOCK_UNKNOWN: - switch (myInfo.songSpeed) { - case SIDTUNE_SPEED_VBI: - tmpSpeed = XS_CLOCK_VBI; - break; - case SIDTUNE_SPEED_CIA_1A: - tmpSpeed = XS_CLOCK_CIA; - break; - default: - tmpSpeed = myInfo.songSpeed; - break; - } - default: - tmpSpeed = myInfo.clockSpeed; - break; - } - - i->subTunes[myStatus->currSong - 1].tuneSpeed = tmpSpeed; - } + if ((myStatus->currSong > 0) && (myStatus->currSong <= i->nsubTunes)) { + gint tmpSpeed = -1; + + switch (myInfo.clockSpeed) { + case SIDTUNE_CLOCK_PAL: + tmpSpeed = XS_CLOCK_PAL; + break; + case SIDTUNE_CLOCK_NTSC: + tmpSpeed = XS_CLOCK_NTSC; + break; + case SIDTUNE_CLOCK_ANY: + tmpSpeed = XS_CLOCK_ANY; + break; + case SIDTUNE_CLOCK_UNKNOWN: + switch (myInfo.songSpeed) { + case SIDTUNE_SPEED_VBI: + tmpSpeed = XS_CLOCK_VBI; + break; + case SIDTUNE_SPEED_CIA_1A: + tmpSpeed = XS_CLOCK_CIA; + break; + default: + tmpSpeed = myInfo.songSpeed; + break; + } + default: + tmpSpeed = myInfo.clockSpeed; + break; + } + + i->subTunes[myStatus->currSong - 1].tuneSpeed = tmpSpeed; + } - return TRUE; + return TRUE; } /* Undefine these */ diff -r 04ea91a61225 -r b0743dc9165d src/xs_sidplay1.cc --- a/src/xs_sidplay1.cc Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_sidplay1.cc Wed Apr 02 22:10:05 2008 +0300 @@ -34,15 +34,15 @@ /* Maximum audio frequency supported by libSIDPlay v1 */ -#define SIDPLAY1_MAX_FREQ (48000) +#define SIDPLAY1_MAX_FREQ (48000) typedef struct { - emuEngine *currEng; - emuConfig currConfig; - sidTune *currTune; - guint8 *buf; - size_t bufSize; + emuEngine *currEng; + emuConfig currConfig; + sidTune *currTune; + guint8 *buf; + size_t bufSize; } xs_sidplay1_t; @@ -52,11 +52,11 @@ /* Return song information */ -#define TFUNCTION xs_sidplay1_getinfo -#define TFUNCTION2 xs_sidplay1_updateinfo -#define TTUNEINFO sidTuneInfo -#define TTUNE sidTune -#define TENGINE xs_sidplay1_t +#define TFUNCTION xs_sidplay1_getinfo +#define TFUNCTION2 xs_sidplay1_updateinfo +#define TTUNEINFO sidTuneInfo +#define TTUNE sidTune +#define TENGINE xs_sidplay1_t #include "xs_sidplay.h" @@ -64,17 +64,17 @@ */ gboolean xs_sidplay1_probe(xs_file_t *f) { - gchar tmpBuf[4]; - - if (!f) return FALSE; - - if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) - return FALSE; - - if (!strncmp(tmpBuf, "PSID", 4)) - return TRUE; - else - return FALSE; + gchar tmpBuf[4]; + + if (!f) return FALSE; + + if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) + return FALSE; + + if (!strncmp(tmpBuf, "PSID", 4)) + return TRUE; + else + return FALSE; } @@ -82,171 +82,171 @@ */ gboolean xs_sidplay1_init(xs_status_t * myStatus) { - gint tmpFreq; - xs_sidplay1_t *myEngine; - assert(myStatus); + gint tmpFreq; + xs_sidplay1_t *myEngine; + assert(myStatus); - /* Allocate internal structures */ - myEngine = (xs_sidplay1_t *) g_malloc0(sizeof(xs_sidplay1_t)); - if (!myEngine) return FALSE; + /* Allocate internal structures */ + myEngine = (xs_sidplay1_t *) g_malloc0(sizeof(xs_sidplay1_t)); + if (!myEngine) return FALSE; - /* Initialize engine */ - myEngine->currEng = new emuEngine(); - if (!myEngine->currEng) { - xs_error("[SIDPlay1] Could not initialize emulation engine.\n"); - g_free(myEngine); - return FALSE; - } + /* Initialize engine */ + myEngine->currEng = new emuEngine(); + if (!myEngine->currEng) { + xs_error("[SIDPlay1] Could not initialize emulation engine.\n"); + g_free(myEngine); + return FALSE; + } - /* Verify endianess */ - if (!myEngine->currEng->verifyEndianess()) { - xs_error("[SIDPlay1] Endianess verification failed.\n"); - delete myEngine->currEng; - g_free(myEngine); - return FALSE; - } + /* Verify endianess */ + if (!myEngine->currEng->verifyEndianess()) { + xs_error("[SIDPlay1] Endianess verification failed.\n"); + delete myEngine->currEng; + g_free(myEngine); + return FALSE; + } - myStatus->sidEngine = myEngine; + myStatus->sidEngine = myEngine; - /* Get current configuration */ - myEngine->currEng->getConfig(myEngine->currConfig); + /* Get current configuration */ + myEngine->currEng->getConfig(myEngine->currConfig); - /* Configure channel parameters */ - switch (myStatus->audioChannels) { + /* Configure channel parameters */ + switch (myStatus->audioChannels) { - case XS_CHN_AUTOPAN: - myEngine->currConfig.channels = SIDEMU_STEREO; - myEngine->currConfig.autoPanning = SIDEMU_CENTEREDAUTOPANNING; - myEngine->currConfig.volumeControl = SIDEMU_FULLPANNING; - break; + case XS_CHN_AUTOPAN: + myEngine->currConfig.channels = SIDEMU_STEREO; + myEngine->currConfig.autoPanning = SIDEMU_CENTEREDAUTOPANNING; + myEngine->currConfig.volumeControl = SIDEMU_FULLPANNING; + break; - case XS_CHN_STEREO: - myEngine->currConfig.channels = SIDEMU_STEREO; - myEngine->currConfig.autoPanning = SIDEMU_NONE; - myEngine->currConfig.volumeControl = SIDEMU_NONE; - break; + case XS_CHN_STEREO: + myEngine->currConfig.channels = SIDEMU_STEREO; + myEngine->currConfig.autoPanning = SIDEMU_NONE; + myEngine->currConfig.volumeControl = SIDEMU_NONE; + break; - case XS_CHN_MONO: - default: - myEngine->currConfig.channels = SIDEMU_MONO; - myEngine->currConfig.autoPanning = SIDEMU_NONE; - myEngine->currConfig.volumeControl = SIDEMU_NONE; - myStatus->audioChannels = XS_CHN_MONO; - break; - } + case XS_CHN_MONO: + default: + myEngine->currConfig.channels = SIDEMU_MONO; + myEngine->currConfig.autoPanning = SIDEMU_NONE; + myEngine->currConfig.volumeControl = SIDEMU_NONE; + myStatus->audioChannels = XS_CHN_MONO; + break; + } - /* Memory mode settings */ - switch (xs_cfg.memoryMode) { - case XS_MPU_TRANSPARENT_ROM: - myEngine->currConfig.memoryMode = MPU_TRANSPARENT_ROM; - break; + /* Memory mode settings */ + switch (xs_cfg.memoryMode) { + case XS_MPU_TRANSPARENT_ROM: + myEngine->currConfig.memoryMode = MPU_TRANSPARENT_ROM; + break; - case XS_MPU_PLAYSID_ENVIRONMENT: - myEngine->currConfig.memoryMode = MPU_PLAYSID_ENVIRONMENT; - break; + case XS_MPU_PLAYSID_ENVIRONMENT: + myEngine->currConfig.memoryMode = MPU_PLAYSID_ENVIRONMENT; + break; - case XS_MPU_BANK_SWITCHING: - default: - myEngine->currConfig.memoryMode = MPU_BANK_SWITCHING; - xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; - break; - } + case XS_MPU_BANK_SWITCHING: + default: + myEngine->currConfig.memoryMode = MPU_BANK_SWITCHING; + xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; + break; + } - /* Audio parameters sanity checking and setup */ - myEngine->currConfig.bitsPerSample = myStatus->audioBitsPerSample; - tmpFreq = myStatus->audioFrequency; + /* Audio parameters sanity checking and setup */ + myEngine->currConfig.bitsPerSample = myStatus->audioBitsPerSample; + tmpFreq = myStatus->audioFrequency; - if (myStatus->oversampleEnable) { - if ((tmpFreq * myStatus->oversampleFactor) > SIDPLAY1_MAX_FREQ) { - myStatus->oversampleEnable = FALSE; - } else { - tmpFreq = (tmpFreq * myStatus->oversampleFactor); - } - } else { - if (tmpFreq > SIDPLAY1_MAX_FREQ) - tmpFreq = SIDPLAY1_MAX_FREQ; - } + if (myStatus->oversampleEnable) { + if ((tmpFreq * myStatus->oversampleFactor) > SIDPLAY1_MAX_FREQ) { + myStatus->oversampleEnable = FALSE; + } else { + tmpFreq = (tmpFreq * myStatus->oversampleFactor); + } + } else { + if (tmpFreq > SIDPLAY1_MAX_FREQ) + tmpFreq = SIDPLAY1_MAX_FREQ; + } - myEngine->currConfig.frequency = tmpFreq; + myEngine->currConfig.frequency = tmpFreq; - switch (myStatus->audioBitsPerSample) { - case XS_RES_8BIT: - switch (myStatus->audioFormat) { - case FMT_S8: - myStatus->audioFormat = FMT_S8; - myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; - break; + switch (myStatus->audioBitsPerSample) { + case XS_RES_8BIT: + switch (myStatus->audioFormat) { + case FMT_S8: + myStatus->audioFormat = FMT_S8; + myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; + break; - case FMT_U8: - default: - myStatus->audioFormat = FMT_U8; - myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; - break; - } - break; + case FMT_U8: + default: + myStatus->audioFormat = FMT_U8; + myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; + break; + } + break; - case XS_RES_16BIT: - default: - switch (myStatus->audioFormat) { - case FMT_U16_NE: - case FMT_U16_LE: - case FMT_U16_BE: - myStatus->audioFormat = FMT_U16_NE; - myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; - break; + case XS_RES_16BIT: + default: + switch (myStatus->audioFormat) { + case FMT_U16_NE: + case FMT_U16_LE: + case FMT_U16_BE: + myStatus->audioFormat = FMT_U16_NE; + myEngine->currConfig.sampleFormat = SIDEMU_UNSIGNED_PCM; + break; - case FMT_S16_NE: - case FMT_S16_LE: - case FMT_S16_BE: - default: - myStatus->audioFormat = FMT_S16_NE; - myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; - break; - } - break; - } + case FMT_S16_NE: + case FMT_S16_LE: + case FMT_S16_BE: + default: + myStatus->audioFormat = FMT_S16_NE; + myEngine->currConfig.sampleFormat = SIDEMU_SIGNED_PCM; + break; + } + break; + } - /* Clockspeed settings */ - switch (xs_cfg.clockSpeed) { - case XS_CLOCK_NTSC: - myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_NTSC; - break; + /* Clockspeed settings */ + switch (xs_cfg.clockSpeed) { + case XS_CLOCK_NTSC: + myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_NTSC; + break; - case XS_CLOCK_PAL: - default: - myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_PAL; - xs_cfg.clockSpeed = XS_CLOCK_PAL; - break; - } + case XS_CLOCK_PAL: + default: + myEngine->currConfig.clockSpeed = SIDTUNE_CLOCK_PAL; + xs_cfg.clockSpeed = XS_CLOCK_PAL; + break; + } - myEngine->currConfig.forceSongSpeed = xs_cfg.forceSpeed; - - - /* Configure rest of the emulation */ - /* if (xs_cfg.forceModel) */ - myEngine->currConfig.mos8580 = xs_cfg.mos8580; - myEngine->currConfig.emulateFilter = xs_cfg.emulateFilters; - myEngine->currConfig.filterFs = xs_cfg.sid1FilterFs; - myEngine->currConfig.filterFm = xs_cfg.sid1FilterFm; - myEngine->currConfig.filterFt = xs_cfg.sid1FilterFt; + myEngine->currConfig.forceSongSpeed = xs_cfg.forceSpeed; + + + /* Configure rest of the emulation */ + /* if (xs_cfg.forceModel) */ + myEngine->currConfig.mos8580 = xs_cfg.mos8580; + myEngine->currConfig.emulateFilter = xs_cfg.emulateFilters; + myEngine->currConfig.filterFs = xs_cfg.sid1FilterFs; + myEngine->currConfig.filterFm = xs_cfg.sid1FilterFm; + myEngine->currConfig.filterFt = xs_cfg.sid1FilterFt; - /* Now set the emulator configuration */ - if (!myEngine->currEng->setConfig(myEngine->currConfig)) { - xs_error("[SIDPlay1] Emulator engine configuration failed!\n"); - return FALSE; - } - - /* Create sidtune object */ - myEngine->currTune = new sidTune(0); - if (!myEngine->currTune) { - xs_error("[SIDPlay1] Could not initialize SIDTune object.\n"); - return FALSE; - } - - return TRUE; + /* Now set the emulator configuration */ + if (!myEngine->currEng->setConfig(myEngine->currConfig)) { + xs_error("[SIDPlay1] Emulator engine configuration failed!\n"); + return FALSE; + } + + /* Create sidtune object */ + myEngine->currTune = new sidTune(0); + if (!myEngine->currTune) { + xs_error("[SIDPlay1] Could not initialize SIDTune object.\n"); + return FALSE; + } + + return TRUE; } @@ -254,26 +254,26 @@ */ void xs_sidplay1_close(xs_status_t * myStatus) { - xs_sidplay1_t *myEngine; - assert(myStatus); + xs_sidplay1_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay1_t *) myStatus->sidEngine; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; - /* Free internals */ - if (myEngine->currEng) { - delete myEngine->currEng; - myEngine->currEng = NULL; - } + /* Free internals */ + if (myEngine->currEng) { + delete myEngine->currEng; + myEngine->currEng = NULL; + } - if (myEngine->currTune) { - delete myEngine->currTune; - myEngine->currTune = NULL; - } + if (myEngine->currTune) { + delete myEngine->currTune; + myEngine->currTune = NULL; + } - xs_sidplay1_delete(myStatus); - - g_free(myEngine); - myStatus->sidEngine = NULL; + xs_sidplay1_delete(myStatus); + + g_free(myEngine); + myStatus->sidEngine = NULL; } @@ -281,25 +281,25 @@ */ gboolean xs_sidplay1_initsong(xs_status_t * myStatus) { - xs_sidplay1_t *myEngine; - assert(myStatus); + xs_sidplay1_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay1_t *) myStatus->sidEngine; - if (!myEngine) return FALSE; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; + if (!myEngine) return FALSE; - if (!myEngine->currTune) { - xs_error("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n"); - return FALSE; - } + if (!myEngine->currTune) { + xs_error("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n"); + return FALSE; + } - if (!myEngine->currTune->getStatus()) { - xs_error("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n"); - return FALSE; - } + if (!myEngine->currTune->getStatus()) { + xs_error("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n"); + return FALSE; + } - myStatus->isInitialized = TRUE; + myStatus->isInitialized = TRUE; - return sidEmuInitializeSong(*myEngine->currEng, *myEngine->currTune, myStatus->currSong); + return sidEmuInitializeSong(*myEngine->currEng, *myEngine->currTune, myStatus->currSong); } @@ -307,15 +307,15 @@ */ guint xs_sidplay1_fillbuffer(xs_status_t * myStatus, gchar * audioBuffer, guint audioBufSize) { - xs_sidplay1_t *myEngine; - assert(myStatus); + xs_sidplay1_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay1_t *) myStatus->sidEngine; - if (!myEngine) return 0; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; + if (!myEngine) return 0; - sidEmuFillBuffer(*myEngine->currEng, *myEngine->currTune, audioBuffer, audioBufSize); + sidEmuFillBuffer(*myEngine->currEng, *myEngine->currTune, audioBuffer, audioBufSize); - return audioBufSize; + return audioBufSize; } @@ -323,23 +323,23 @@ */ gboolean xs_sidplay1_load(xs_status_t * myStatus, gchar * filename) { - xs_sidplay1_t *myEngine; - assert(myStatus); - myStatus->isInitialized = FALSE; + xs_sidplay1_t *myEngine; + assert(myStatus); + myStatus->isInitialized = FALSE; - myEngine = (xs_sidplay1_t *) myStatus->sidEngine; - if (!myEngine) return FALSE; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; + if (!myEngine) return FALSE; - /* Try to get the tune */ - if (!filename) return FALSE; - - if (xs_fload_buffer(filename, &(myEngine->buf), &(myEngine->bufSize)) != 0) - return FALSE; - - if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize)) - return FALSE; + /* Try to get the tune */ + if (!filename) return FALSE; + + if (xs_fload_buffer(filename, &(myEngine->buf), &(myEngine->bufSize)) != 0) + return FALSE; + + if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize)) + return FALSE; - return TRUE; + return TRUE; } @@ -347,17 +347,17 @@ */ void xs_sidplay1_delete(xs_status_t * myStatus) { - xs_sidplay1_t *myEngine; - assert(myStatus); + xs_sidplay1_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay1_t *) myStatus->sidEngine; - if (!myEngine) return; - - g_free(myEngine->buf); - myEngine->buf = NULL; - myEngine->bufSize = 0; + myEngine = (xs_sidplay1_t *) myStatus->sidEngine; + if (!myEngine) return; + + g_free(myEngine->buf); + myEngine->buf = NULL; + myEngine->bufSize = 0; } -} /* extern "C" */ -#endif /* HAVE_SIDPLAY1 */ +} /* extern "C" */ +#endif /* HAVE_SIDPLAY1 */ diff -r 04ea91a61225 -r b0743dc9165d src/xs_sidplay1.h --- a/src/xs_sidplay1.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_sidplay1.h Wed Apr 02 22:10:05 2008 +0300 @@ -9,15 +9,15 @@ extern "C" { #endif -gboolean xs_sidplay1_probe(xs_file_t *); -void xs_sidplay1_close(xs_status_t *); -gboolean xs_sidplay1_init(xs_status_t *); -gboolean xs_sidplay1_initsong(xs_status_t *); -guint xs_sidplay1_fillbuffer(xs_status_t *, gchar *, guint); -gboolean xs_sidplay1_load(xs_status_t *, gchar *); -void xs_sidplay1_delete(xs_status_t *); -xs_tuneinfo_t* xs_sidplay1_getinfo(const gchar *); -gboolean xs_sidplay1_updateinfo(xs_status_t *); +gboolean xs_sidplay1_probe(xs_file_t *); +void xs_sidplay1_close(xs_status_t *); +gboolean xs_sidplay1_init(xs_status_t *); +gboolean xs_sidplay1_initsong(xs_status_t *); +guint xs_sidplay1_fillbuffer(xs_status_t *, gchar *, guint); +gboolean xs_sidplay1_load(xs_status_t *, gchar *); +void xs_sidplay1_delete(xs_status_t *); +xs_tuneinfo_t* xs_sidplay1_getinfo(const gchar *); +gboolean xs_sidplay1_updateinfo(xs_status_t *); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_sidplay2.cc --- a/src/xs_sidplay2.cc Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_sidplay2.cc Wed Apr 02 22:10:05 2008 +0300 @@ -39,12 +39,12 @@ typedef struct { - sidplay2 *currEng; - sidbuilder *currBuilder; - sid2_config_t currConfig; - SidTune *currTune; - guint8 *buf; - size_t bufSize; + sidplay2 *currEng; + sidbuilder *currBuilder; + sid2_config_t currConfig; + SidTune *currTune; + guint8 *buf; + size_t bufSize; } xs_sidplay2_t; @@ -54,11 +54,11 @@ /* Return song information */ -#define TFUNCTION xs_sidplay2_getinfo -#define TFUNCTION2 xs_sidplay2_updateinfo -#define TTUNEINFO SidTuneInfo -#define TTUNE SidTune -#define TENGINE xs_sidplay2_t +#define TFUNCTION xs_sidplay2_getinfo +#define TFUNCTION2 xs_sidplay2_updateinfo +#define TTUNEINFO SidTuneInfo +#define TTUNE SidTune +#define TENGINE xs_sidplay2_t #include "xs_sidplay.h" @@ -66,17 +66,17 @@ */ gboolean xs_sidplay2_probe(xs_file_t *f) { - gchar tmpBuf[4]; - - if (!f) return FALSE; - - if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) - return FALSE; - - if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4)) - return TRUE; - else - return FALSE; + gchar tmpBuf[4]; + + if (!f) return FALSE; + + if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) + return FALSE; + + if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4)) + return TRUE; + else + return FALSE; } @@ -84,282 +84,282 @@ */ gboolean xs_sidplay2_init(xs_status_t * myStatus) { - gint tmpFreq, i; - xs_sidplay2_t *myEngine; - sid_filter_t tmpFilter; - t_xs_sid2_filter *f; - assert(myStatus); + gint tmpFreq, i; + xs_sidplay2_t *myEngine; + sid_filter_t tmpFilter; + t_xs_sid2_filter *f; + assert(myStatus); - /* Allocate internal structures */ - myEngine = (xs_sidplay2_t *) g_malloc0(sizeof(xs_sidplay2_t)); - myStatus->sidEngine = myEngine; - if (!myEngine) return FALSE; + /* Allocate internal structures */ + myEngine = (xs_sidplay2_t *) g_malloc0(sizeof(xs_sidplay2_t)); + myStatus->sidEngine = myEngine; + if (!myEngine) return FALSE; - /* Initialize the engine */ - myEngine->currEng = new sidplay2; - if (!myEngine->currEng) { - xs_error("[SIDPlay2] Could not initialize emulation engine.\n"); - return FALSE; - } + /* Initialize the engine */ + myEngine->currEng = new sidplay2; + if (!myEngine->currEng) { + xs_error("[SIDPlay2] Could not initialize emulation engine.\n"); + return FALSE; + } - /* Get current configuration */ - myEngine->currConfig = myEngine->currEng->config(); + /* Get current configuration */ + myEngine->currConfig = myEngine->currEng->config(); - /* Configure channels and stuff */ - switch (myStatus->audioChannels) { + /* Configure channels and stuff */ + switch (myStatus->audioChannels) { - case XS_CHN_AUTOPAN: - myEngine->currConfig.playback = sid2_stereo; - break; + case XS_CHN_AUTOPAN: + myEngine->currConfig.playback = sid2_stereo; + break; - case XS_CHN_STEREO: - myEngine->currConfig.playback = sid2_stereo; - break; + case XS_CHN_STEREO: + myEngine->currConfig.playback = sid2_stereo; + break; - case XS_CHN_MONO: - default: - myEngine->currConfig.playback = sid2_mono; - myStatus->audioChannels = XS_CHN_MONO; - break; - } + case XS_CHN_MONO: + default: + myEngine->currConfig.playback = sid2_mono; + myStatus->audioChannels = XS_CHN_MONO; + break; + } - /* Memory mode settings */ - switch (xs_cfg.memoryMode) { - case XS_MPU_BANK_SWITCHING: - myEngine->currConfig.environment = sid2_envBS; - break; + /* Memory mode settings */ + switch (xs_cfg.memoryMode) { + case XS_MPU_BANK_SWITCHING: + myEngine->currConfig.environment = sid2_envBS; + break; - case XS_MPU_TRANSPARENT_ROM: - myEngine->currConfig.environment = sid2_envTP; - break; + case XS_MPU_TRANSPARENT_ROM: + myEngine->currConfig.environment = sid2_envTP; + break; - case XS_MPU_PLAYSID_ENVIRONMENT: - myEngine->currConfig.environment = sid2_envPS; - break; + case XS_MPU_PLAYSID_ENVIRONMENT: + myEngine->currConfig.environment = sid2_envPS; + break; - case XS_MPU_REAL: - default: - myEngine->currConfig.environment = sid2_envR; - xs_cfg.memoryMode = XS_MPU_REAL; - break; - } + case XS_MPU_REAL: + default: + myEngine->currConfig.environment = sid2_envR; + xs_cfg.memoryMode = XS_MPU_REAL; + break; + } - /* Audio parameters sanity checking and setup */ - myEngine->currConfig.precision = myStatus->audioBitsPerSample; - tmpFreq = myStatus->audioFrequency; + /* Audio parameters sanity checking and setup */ + myEngine->currConfig.precision = myStatus->audioBitsPerSample; + tmpFreq = myStatus->audioFrequency; - if (myStatus->oversampleEnable) - tmpFreq = (tmpFreq * myStatus->oversampleFactor); + if (myStatus->oversampleEnable) + tmpFreq = (tmpFreq * myStatus->oversampleFactor); - myEngine->currConfig.frequency = tmpFreq; + myEngine->currConfig.frequency = tmpFreq; - switch (myStatus->audioBitsPerSample) { - case XS_RES_8BIT: - myStatus->audioFormat = FMT_U8; - myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; - break; + switch (myStatus->audioBitsPerSample) { + case XS_RES_8BIT: + myStatus->audioFormat = FMT_U8; + myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; + break; - case XS_RES_16BIT: - default: - switch (myStatus->audioFormat) { - case FMT_U16_LE: - myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; - break; + case XS_RES_16BIT: + default: + switch (myStatus->audioFormat) { + case FMT_U16_LE: + myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; + break; - case FMT_U16_BE: - myEngine->currConfig.sampleFormat = SID2_BIG_UNSIGNED; - break; + case FMT_U16_BE: + myEngine->currConfig.sampleFormat = SID2_BIG_UNSIGNED; + break; - case FMT_U16_NE: + case FMT_U16_NE: #if G_BYTE_ORDER == G_BIG_ENDIAN - myEngine->currConfig.sampleFormat = SID2_BIG_UNSIGNED; + myEngine->currConfig.sampleFormat = SID2_BIG_UNSIGNED; #else #if G_BYTE_ORDER == G_LITTLE_ENDIAN - myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; + myEngine->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; #else #error Unsupported endianess! #endif #endif - break; + break; - case FMT_S16_LE: - myEngine->currConfig.sampleFormat = SID2_LITTLE_SIGNED; - break; + case FMT_S16_LE: + myEngine->currConfig.sampleFormat = SID2_LITTLE_SIGNED; + break; - case FMT_S16_BE: - myEngine->currConfig.sampleFormat = SID2_BIG_SIGNED; - break; + case FMT_S16_BE: + myEngine->currConfig.sampleFormat = SID2_BIG_SIGNED; + break; - default: - myStatus->audioFormat = FMT_S16_NE; + default: + myStatus->audioFormat = FMT_S16_NE; #if G_BYTE_ORDER == G_BIG_ENDIAN - myEngine->currConfig.sampleFormat = SID2_BIG_SIGNED; + myEngine->currConfig.sampleFormat = SID2_BIG_SIGNED; #else #if G_BYTE_ORDER == G_LITTLE_ENDIAN - myEngine->currConfig.sampleFormat = SID2_LITTLE_SIGNED; + myEngine->currConfig.sampleFormat = SID2_LITTLE_SIGNED; #else #error Unsupported endianess! #endif #endif - break; + break; - } - break; - } - - /* Convert filter */ - f = &(xs_cfg.sid2Filter); - XSDEBUG("using filter '%s', %d points\n", f->name, f->npoints); - if (f->npoints > XS_SIDPLAY2_NFPOINTS) { - xs_error("[SIDPlay2] Invalid number of filter curve points (%d > %d)\n", - f->npoints, XS_SIDPLAY2_NFPOINTS); - f->npoints = XS_SIDPLAY2_NFPOINTS; - } - - tmpFilter.points = f->npoints; - for (i = 0; i < f->npoints; i++) { - tmpFilter.cutoff[i][0] = f->points[i].x; - tmpFilter.cutoff[i][1] = f->points[i].y; - } + } + break; + } + + /* Convert filter */ + f = &(xs_cfg.sid2Filter); + XSDEBUG("using filter '%s', %d points\n", f->name, f->npoints); + if (f->npoints > XS_SIDPLAY2_NFPOINTS) { + xs_error("[SIDPlay2] Invalid number of filter curve points (%d > %d)\n", + f->npoints, XS_SIDPLAY2_NFPOINTS); + f->npoints = XS_SIDPLAY2_NFPOINTS; + } + + tmpFilter.points = f->npoints; + for (i = 0; i < f->npoints; i++) { + tmpFilter.cutoff[i][0] = f->points[i].x; + tmpFilter.cutoff[i][1] = f->points[i].y; + } - /* Initialize builder object */ - XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (myEngine->currEng->info()).maxsids); + /* Initialize builder object */ + XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (myEngine->currEng->info()).maxsids); #ifdef HAVE_RESID_BUILDER - if (xs_cfg.sid2Builder == XS_BLD_RESID) { - ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); - myEngine->currBuilder = (sidbuilder *) rs; - if (rs) { - /* Builder object created, initialize it */ - rs->create((myEngine->currEng->info()).maxsids); - if (!*rs) { - xs_error("reSID->create() failed.\n"); - return FALSE; - } + if (xs_cfg.sid2Builder == XS_BLD_RESID) { + ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); + myEngine->currBuilder = (sidbuilder *) rs; + if (rs) { + /* Builder object created, initialize it */ + rs->create((myEngine->currEng->info()).maxsids); + if (!*rs) { + xs_error("reSID->create() failed.\n"); + return FALSE; + } - rs->filter(xs_cfg.emulateFilters); - if (!*rs) { - xs_error("reSID->filter(%d) failed.\n", xs_cfg.emulateFilters); - return FALSE; - } + rs->filter(xs_cfg.emulateFilters); + if (!*rs) { + xs_error("reSID->filter(%d) failed.\n", xs_cfg.emulateFilters); + return FALSE; + } - // FIXME FIX ME: support other configurable parameters ... - // ... WHEN/IF resid-builder+libsidplay2 gets fixed - rs->sampling(tmpFreq); - if (!*rs) { - xs_error("reSID->sampling(%d) failed.\n", tmpFreq); - return FALSE; - } - - if (tmpFilter.points > 0) - rs->filter((sid_filter_t *) &tmpFilter); - else - rs->filter((sid_filter_t *) NULL); - - if (!*rs) { - xs_error("reSID->filter(NULL) failed.\n"); - return FALSE; - } - } - } + // FIXME FIX ME: support other configurable parameters ... + // ... WHEN/IF resid-builder+libsidplay2 gets fixed + rs->sampling(tmpFreq); + if (!*rs) { + xs_error("reSID->sampling(%d) failed.\n", tmpFreq); + return FALSE; + } + + if (tmpFilter.points > 0) + rs->filter((sid_filter_t *) &tmpFilter); + else + rs->filter((sid_filter_t *) NULL); + + if (!*rs) { + xs_error("reSID->filter(NULL) failed.\n"); + return FALSE; + } + } + } #endif #ifdef HAVE_HARDSID_BUILDER - if (xs_cfg.sid2Builder == XS_BLD_HARDSID) { - HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder"); - myEngine->currBuilder = (sidbuilder *) hs; - if (hs) { - /* Builder object created, initialize it */ - hs->create((myEngine->currEng->info()).maxsids); - if (!*hs) { - xs_error("hardSID->create() failed.\n"); - return FALSE; - } + if (xs_cfg.sid2Builder == XS_BLD_HARDSID) { + HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder"); + myEngine->currBuilder = (sidbuilder *) hs; + if (hs) { + /* Builder object created, initialize it */ + hs->create((myEngine->currEng->info()).maxsids); + if (!*hs) { + xs_error("hardSID->create() failed.\n"); + return FALSE; + } - hs->filter(xs_cfg.emulateFilters); - if (!*hs) { - xs_error("hardSID->filter(%d) failed.\n", xs_cfg.emulateFilters); - return FALSE; - } - } - } + hs->filter(xs_cfg.emulateFilters); + if (!*hs) { + xs_error("hardSID->filter(%d) failed.\n", xs_cfg.emulateFilters); + return FALSE; + } + } + } #endif - if (!myEngine->currBuilder) { - xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); - return FALSE; - } + if (!myEngine->currBuilder) { + xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); + return FALSE; + } - XSDEBUG("%s\n", myEngine->currBuilder->credits()); + XSDEBUG("%s\n", myEngine->currBuilder->credits()); - /* Clockspeed settings */ - switch (xs_cfg.clockSpeed) { - case XS_CLOCK_NTSC: - myEngine->currConfig.clockDefault = SID2_CLOCK_NTSC; - break; + /* Clockspeed settings */ + switch (xs_cfg.clockSpeed) { + case XS_CLOCK_NTSC: + myEngine->currConfig.clockDefault = SID2_CLOCK_NTSC; + break; - default: - xs_error("[SIDPlay2] Invalid clockSpeed=%d, falling back to PAL.\n", - xs_cfg.clockSpeed); + default: + xs_error("[SIDPlay2] Invalid clockSpeed=%d, falling back to PAL.\n", + xs_cfg.clockSpeed); - case XS_CLOCK_PAL: - myEngine->currConfig.clockDefault = SID2_CLOCK_PAL; - xs_cfg.clockSpeed = XS_CLOCK_PAL; - break; - } + case XS_CLOCK_PAL: + myEngine->currConfig.clockDefault = SID2_CLOCK_PAL; + xs_cfg.clockSpeed = XS_CLOCK_PAL; + break; + } - /* Configure rest of the emulation */ - myEngine->currConfig.sidEmulation = myEngine->currBuilder; - - if (xs_cfg.forceSpeed) { - myEngine->currConfig.clockForced = true; - myEngine->currConfig.clockSpeed = myEngine->currConfig.clockDefault; - } else { - myEngine->currConfig.clockForced = false; - myEngine->currConfig.clockSpeed = SID2_CLOCK_CORRECT; - } - - if ((xs_cfg.sid2OptLevel >= 0) && (xs_cfg.sid2OptLevel <= SID2_MAX_OPTIMISATION)) - myEngine->currConfig.optimisation = xs_cfg.sid2OptLevel; - else { - xs_error("Invalid sid2OptLevel=%d, falling back to %d.\n", - xs_cfg.sid2OptLevel, SID2_DEFAULT_OPTIMISATION); - - xs_cfg.sid2OptLevel = - myEngine->currConfig.optimisation = SID2_DEFAULT_OPTIMISATION; - } + /* Configure rest of the emulation */ + myEngine->currConfig.sidEmulation = myEngine->currBuilder; + + if (xs_cfg.forceSpeed) { + myEngine->currConfig.clockForced = true; + myEngine->currConfig.clockSpeed = myEngine->currConfig.clockDefault; + } else { + myEngine->currConfig.clockForced = false; + myEngine->currConfig.clockSpeed = SID2_CLOCK_CORRECT; + } + + if ((xs_cfg.sid2OptLevel >= 0) && (xs_cfg.sid2OptLevel <= SID2_MAX_OPTIMISATION)) + myEngine->currConfig.optimisation = xs_cfg.sid2OptLevel; + else { + xs_error("Invalid sid2OptLevel=%d, falling back to %d.\n", + xs_cfg.sid2OptLevel, SID2_DEFAULT_OPTIMISATION); + + xs_cfg.sid2OptLevel = + myEngine->currConfig.optimisation = SID2_DEFAULT_OPTIMISATION; + } - if (xs_cfg.mos8580) - myEngine->currConfig.sidDefault = SID2_MOS8580; - else - myEngine->currConfig.sidDefault = SID2_MOS6581; + if (xs_cfg.mos8580) + myEngine->currConfig.sidDefault = SID2_MOS8580; + else + myEngine->currConfig.sidDefault = SID2_MOS6581; - if (xs_cfg.forceModel) - myEngine->currConfig.sidModel = myEngine->currConfig.sidDefault; - else - myEngine->currConfig.sidModel = SID2_MODEL_CORRECT; + if (xs_cfg.forceModel) + myEngine->currConfig.sidModel = myEngine->currConfig.sidDefault; + else + myEngine->currConfig.sidModel = SID2_MODEL_CORRECT; - - /* XXX: Should this be configurable? libSIDPlay1 does not support it, though */ - myEngine->currConfig.sidSamples = TRUE; + + /* XXX: Should this be configurable? libSIDPlay1 does not support it, though */ + myEngine->currConfig.sidSamples = TRUE; - /* Now set the emulator configuration */ - if (myEngine->currEng->config(myEngine->currConfig) < 0) { - xs_error("[SIDPlay2] Emulator engine configuration failed!\n"); - return FALSE; - } + /* Now set the emulator configuration */ + if (myEngine->currEng->config(myEngine->currConfig) < 0) { + xs_error("[SIDPlay2] Emulator engine configuration failed!\n"); + return FALSE; + } - /* Create the sidtune */ - myEngine->currTune = new SidTune(0); - if (!myEngine->currTune) { - xs_error("[SIDPlay2] Could not initialize SIDTune object.\n"); - return FALSE; - } + /* Create the sidtune */ + myEngine->currTune = new SidTune(0); + if (!myEngine->currTune) { + xs_error("[SIDPlay2] Could not initialize SIDTune object.\n"); + return FALSE; + } - return TRUE; + return TRUE; } @@ -367,31 +367,31 @@ */ void xs_sidplay2_close(xs_status_t * myStatus) { - xs_sidplay2_t *myEngine; - assert(myStatus); + xs_sidplay2_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay2_t *) myStatus->sidEngine; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; - /* Free internals */ - if (myEngine->currBuilder) { - delete myEngine->currBuilder; - myEngine->currBuilder = NULL; - } + /* Free internals */ + if (myEngine->currBuilder) { + delete myEngine->currBuilder; + myEngine->currBuilder = NULL; + } - if (myEngine->currEng) { - delete myEngine->currEng; - myEngine->currEng = NULL; - } + if (myEngine->currEng) { + delete myEngine->currEng; + myEngine->currEng = NULL; + } - if (myEngine->currTune) { - delete myEngine->currTune; - myEngine->currTune = NULL; - } + if (myEngine->currTune) { + delete myEngine->currTune; + myEngine->currTune = NULL; + } - xs_sidplay2_delete(myStatus); + xs_sidplay2_delete(myStatus); - g_free(myEngine); - myStatus->sidEngine = NULL; + g_free(myEngine); + myStatus->sidEngine = NULL; } @@ -399,25 +399,25 @@ */ gboolean xs_sidplay2_initsong(xs_status_t * myStatus) { - xs_sidplay2_t *myEngine; - assert(myStatus); + xs_sidplay2_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay2_t *) myStatus->sidEngine; - if (!myEngine) return FALSE; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; + if (!myEngine) return FALSE; - if (!myEngine->currTune->selectSong(myStatus->currSong)) { - xs_error("[SIDPlay2] currTune->selectSong() failed\n"); - return FALSE; - } + if (!myEngine->currTune->selectSong(myStatus->currSong)) { + xs_error("[SIDPlay2] currTune->selectSong() failed\n"); + return FALSE; + } - if (myEngine->currEng->load(myEngine->currTune) < 0) { - xs_error("[SIDPlay2] currEng->load() failed\n"); - return FALSE; - } - - myStatus->isInitialized = TRUE; + if (myEngine->currEng->load(myEngine->currTune) < 0) { + xs_error("[SIDPlay2] currEng->load() failed\n"); + return FALSE; + } + + myStatus->isInitialized = TRUE; - return TRUE; + return TRUE; } @@ -425,13 +425,13 @@ */ guint xs_sidplay2_fillbuffer(xs_status_t * myStatus, gchar * audioBuffer, guint audioBufSize) { - xs_sidplay2_t *myEngine; - assert(myStatus); + xs_sidplay2_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay2_t *) myStatus->sidEngine; - if (!myEngine) return 0; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; + if (!myEngine) return 0; - return myEngine->currEng->play(audioBuffer, audioBufSize); + return myEngine->currEng->play(audioBuffer, audioBufSize); } @@ -439,23 +439,23 @@ */ gboolean xs_sidplay2_load(xs_status_t * myStatus, gchar * pcFilename) { - xs_sidplay2_t *myEngine; - assert(myStatus); - myStatus->isInitialized = FALSE; + xs_sidplay2_t *myEngine; + assert(myStatus); + myStatus->isInitialized = FALSE; - myEngine = (xs_sidplay2_t *) myStatus->sidEngine; - if (!myEngine) return FALSE; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; + if (!myEngine) return FALSE; - /* Try to get the tune */ - if (!pcFilename) return FALSE; + /* Try to get the tune */ + if (!pcFilename) return FALSE; - if (xs_fload_buffer(pcFilename, &(myEngine->buf), &(myEngine->bufSize)) != 0) - return FALSE; - - if (!myEngine->currTune->read(myEngine->buf, myEngine->bufSize)) - return FALSE; + if (xs_fload_buffer(pcFilename, &(myEngine->buf), &(myEngine->bufSize)) != 0) + return FALSE; + + if (!myEngine->currTune->read(myEngine->buf, myEngine->bufSize)) + return FALSE; - return TRUE; + return TRUE; } @@ -463,15 +463,15 @@ */ void xs_sidplay2_delete(xs_status_t * myStatus) { - xs_sidplay2_t *myEngine; - assert(myStatus); + xs_sidplay2_t *myEngine; + assert(myStatus); - myEngine = (xs_sidplay2_t *) myStatus->sidEngine; - if (!myEngine) return; - - g_free(myEngine->buf); - myEngine->buf = NULL; - myEngine->bufSize = 0; + myEngine = (xs_sidplay2_t *) myStatus->sidEngine; + if (!myEngine) return; + + g_free(myEngine->buf); + myEngine->buf = NULL; + myEngine->bufSize = 0; } @@ -479,20 +479,20 @@ */ void xs_sidplay2_flush(xs_status_t * myStatus) { - assert(myStatus); + assert(myStatus); #ifdef HAVE_HARDSID_BUILDER #ifdef HSID_SID2_COM - IfPtr hs(myStatus->currBuilder); - if (hs) - hs->flush(); + IfPtr hs(myStatus->currBuilder); + if (hs) + hs->flush(); #else - if (xs_cfg.sid2Builder == XS_BLD_HARDSID) - ((HardSIDBuilder *) myStatus->currBuilder)->flush(); + if (xs_cfg.sid2Builder == XS_BLD_HARDSID) + ((HardSIDBuilder *) myStatus->currBuilder)->flush(); #endif #endif } -} /* extern "C" */ -#endif /* HAVE_SIDPLAY2 */ +} /* extern "C" */ +#endif /* HAVE_SIDPLAY2 */ diff -r 04ea91a61225 -r b0743dc9165d src/xs_sidplay2.h --- a/src/xs_sidplay2.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_sidplay2.h Wed Apr 02 22:10:05 2008 +0300 @@ -9,16 +9,16 @@ extern "C" { #endif -gboolean xs_sidplay2_probe(xs_file_t *); -void xs_sidplay2_close(xs_status_t *); -gboolean xs_sidplay2_init(xs_status_t *); -gboolean xs_sidplay2_initsong(xs_status_t *); -guint xs_sidplay2_fillbuffer(xs_status_t *, gchar *, guint); -gboolean xs_sidplay2_load(xs_status_t *, gchar *); -void xs_sidplay2_delete(xs_status_t *); -xs_tuneinfo_t* xs_sidplay2_getinfo(const gchar *); -gboolean xs_sidplay2_updateinfo(xs_status_t *); -void xs_sidplay2_flush(xs_status_t *); +gboolean xs_sidplay2_probe(xs_file_t *); +void xs_sidplay2_close(xs_status_t *); +gboolean xs_sidplay2_init(xs_status_t *); +gboolean xs_sidplay2_initsong(xs_status_t *); +guint xs_sidplay2_fillbuffer(xs_status_t *, gchar *, guint); +gboolean xs_sidplay2_load(xs_status_t *, gchar *); +void xs_sidplay2_delete(xs_status_t *); +xs_tuneinfo_t* xs_sidplay2_getinfo(const gchar *); +gboolean xs_sidplay2_updateinfo(xs_status_t *); +void xs_sidplay2_flush(xs_status_t *); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_slsup.c --- a/src/xs_slsup.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_slsup.c Wed Apr 02 22:10:05 2008 +0300 @@ -35,92 +35,92 @@ */ gint xs_stil_init(void) { - XS_MUTEX_LOCK(xs_cfg); + XS_MUTEX_LOCK(xs_cfg); - if (!xs_cfg.stilDBPath) { - XS_MUTEX_UNLOCK(xs_cfg); - return -1; - } + if (!xs_cfg.stilDBPath) { + XS_MUTEX_UNLOCK(xs_cfg); + return -1; + } - XS_MUTEX_LOCK(xs_stildb_db); + XS_MUTEX_LOCK(xs_stildb_db); - /* Check if already initialized */ - if (xs_stildb_db) - xs_stildb_free(xs_stildb_db); + /* Check if already initialized */ + if (xs_stildb_db) + xs_stildb_free(xs_stildb_db); - /* Allocate database */ - xs_stildb_db = (xs_stildb_t *) g_malloc0(sizeof(xs_stildb_t)); - if (!xs_stildb_db) { - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); - return -2; - } + /* Allocate database */ + xs_stildb_db = (xs_stildb_t *) g_malloc0(sizeof(xs_stildb_t)); + if (!xs_stildb_db) { + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_stildb_db); + return -2; + } - /* Read the database */ - if (xs_stildb_read(xs_stildb_db, xs_cfg.stilDBPath) != 0) { - xs_stildb_free(xs_stildb_db); - xs_stildb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); - return -3; - } + /* Read the database */ + if (xs_stildb_read(xs_stildb_db, xs_cfg.stilDBPath) != 0) { + xs_stildb_free(xs_stildb_db); + xs_stildb_db = NULL; + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_stildb_db); + return -3; + } - /* Create index */ - if (xs_stildb_index(xs_stildb_db) != 0) { - xs_stildb_free(xs_stildb_db); - xs_stildb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); - return -4; - } + /* Create index */ + if (xs_stildb_index(xs_stildb_db) != 0) { + xs_stildb_free(xs_stildb_db); + xs_stildb_db = NULL; + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_stildb_db); + return -4; + } - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_stildb_db); - return 0; + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_stildb_db); + return 0; } void xs_stil_close(void) { - XS_MUTEX_LOCK(xs_stildb_db); - xs_stildb_free(xs_stildb_db); - xs_stildb_db = NULL; - XS_MUTEX_UNLOCK(xs_stildb_db); + XS_MUTEX_LOCK(xs_stildb_db); + xs_stildb_free(xs_stildb_db); + xs_stildb_db = NULL; + XS_MUTEX_UNLOCK(xs_stildb_db); } stil_node_t *xs_stil_get(gchar *filename) { - stil_node_t *result; - gchar *tmpFilename; + stil_node_t *result; + gchar *tmpFilename; - XS_MUTEX_LOCK(xs_stildb_db); - XS_MUTEX_LOCK(xs_cfg); + XS_MUTEX_LOCK(xs_stildb_db); + XS_MUTEX_LOCK(xs_cfg); - if (xs_cfg.stilDBEnable && xs_stildb_db) { - if (xs_cfg.hvscPath) { - /* Remove postfixed directory separator from HVSC-path */ - tmpFilename = xs_strrchr(xs_cfg.hvscPath, '/'); - if (tmpFilename && (tmpFilename[1] == 0)) - tmpFilename[0] = 0; + if (xs_cfg.stilDBEnable && xs_stildb_db) { + if (xs_cfg.hvscPath) { + /* Remove postfixed directory separator from HVSC-path */ + tmpFilename = xs_strrchr(xs_cfg.hvscPath, '/'); + if (tmpFilename && (tmpFilename[1] == 0)) + tmpFilename[0] = 0; - /* Remove HVSC location-prefix from filename */ - tmpFilename = strstr(filename, xs_cfg.hvscPath); - if (tmpFilename) - tmpFilename += strlen(xs_cfg.hvscPath); - else - tmpFilename = filename; - } else - tmpFilename = filename; + /* Remove HVSC location-prefix from filename */ + tmpFilename = strstr(filename, xs_cfg.hvscPath); + if (tmpFilename) + tmpFilename += strlen(xs_cfg.hvscPath); + else + tmpFilename = filename; + } else + tmpFilename = filename; - result = xs_stildb_get_node(xs_stildb_db, tmpFilename); - } else - result = NULL; + result = xs_stildb_get_node(xs_stildb_db, tmpFilename); + } else + result = NULL; - XS_MUTEX_UNLOCK(xs_stildb_db); - XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_stildb_db); + XS_MUTEX_UNLOCK(xs_cfg); - return result; + return result; } @@ -128,146 +128,146 @@ */ gint xs_songlen_init(void) { - XS_MUTEX_LOCK(xs_cfg); + XS_MUTEX_LOCK(xs_cfg); - if (!xs_cfg.songlenDBPath) { - XS_MUTEX_UNLOCK(xs_cfg); - return -1; - } + if (!xs_cfg.songlenDBPath) { + XS_MUTEX_UNLOCK(xs_cfg); + return -1; + } - XS_MUTEX_LOCK(xs_sldb_db); + XS_MUTEX_LOCK(xs_sldb_db); - /* Check if already initialized */ - if (xs_sldb_db) - xs_sldb_free(xs_sldb_db); + /* Check if already initialized */ + if (xs_sldb_db) + xs_sldb_free(xs_sldb_db); - /* Allocate database */ - xs_sldb_db = (xs_sldb_t *) g_malloc0(sizeof(xs_sldb_t)); - if (!xs_sldb_db) { - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); - return -2; - } + /* Allocate database */ + xs_sldb_db = (xs_sldb_t *) g_malloc0(sizeof(xs_sldb_t)); + if (!xs_sldb_db) { + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_sldb_db); + return -2; + } - /* Read the database */ - if (xs_sldb_read(xs_sldb_db, xs_cfg.songlenDBPath) != 0) { - xs_sldb_free(xs_sldb_db); - xs_sldb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); - return -3; - } + /* Read the database */ + if (xs_sldb_read(xs_sldb_db, xs_cfg.songlenDBPath) != 0) { + xs_sldb_free(xs_sldb_db); + xs_sldb_db = NULL; + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_sldb_db); + return -3; + } - /* Create index */ - if (xs_sldb_index(xs_sldb_db) != 0) { - xs_sldb_free(xs_sldb_db); - xs_sldb_db = NULL; - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); - return -4; - } + /* Create index */ + if (xs_sldb_index(xs_sldb_db) != 0) { + xs_sldb_free(xs_sldb_db); + xs_sldb_db = NULL; + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_sldb_db); + return -4; + } - XS_MUTEX_UNLOCK(xs_cfg); - XS_MUTEX_UNLOCK(xs_sldb_db); - return 0; + XS_MUTEX_UNLOCK(xs_cfg); + XS_MUTEX_UNLOCK(xs_sldb_db); + return 0; } void xs_songlen_close(void) { - XS_MUTEX_LOCK(xs_sldb_db); - xs_sldb_free(xs_sldb_db); - xs_sldb_db = NULL; - XS_MUTEX_UNLOCK(xs_sldb_db); + XS_MUTEX_LOCK(xs_sldb_db); + xs_sldb_free(xs_sldb_db); + xs_sldb_db = NULL; + XS_MUTEX_UNLOCK(xs_sldb_db); } sldb_node_t *xs_songlen_get(const gchar * filename) { - sldb_node_t *result; + sldb_node_t *result; - XS_MUTEX_LOCK(xs_sldb_db); + XS_MUTEX_LOCK(xs_sldb_db); - if (xs_cfg.songlenDBEnable && xs_sldb_db) - result = xs_sldb_get(xs_sldb_db, filename); - else - result = NULL; + if (xs_cfg.songlenDBEnable && xs_sldb_db) + result = xs_sldb_get(xs_sldb_db, filename); + else + result = NULL; - XS_MUTEX_UNLOCK(xs_sldb_db); + XS_MUTEX_UNLOCK(xs_sldb_db); - return result; + return result; } /* Allocate a new tune information structure */ xs_tuneinfo_t *xs_tuneinfo_new(const gchar * filename, - gint nsubTunes, gint startTune, const gchar * sidName, - const gchar * sidComposer, const gchar * sidCopyright, - gint loadAddr, gint initAddr, gint playAddr, - gint dataFileLen, const gchar *sidFormat, gint sidModel) + gint nsubTunes, gint startTune, const gchar * sidName, + const gchar * sidComposer, const gchar * sidCopyright, + gint loadAddr, gint initAddr, gint playAddr, + gint dataFileLen, const gchar *sidFormat, gint sidModel) { - xs_tuneinfo_t *result; - sldb_node_t *tmpLength; - gint i; + xs_tuneinfo_t *result; + sldb_node_t *tmpLength; + gint i; - /* Allocate structure */ - result = (xs_tuneinfo_t *) g_malloc0(sizeof(xs_tuneinfo_t)); - if (!result) { - xs_error("Could not allocate memory for tuneinfo ('%s')\n", - filename); - return NULL; - } + /* Allocate structure */ + result = (xs_tuneinfo_t *) g_malloc0(sizeof(xs_tuneinfo_t)); + if (!result) { + xs_error("Could not allocate memory for tuneinfo ('%s')\n", + filename); + return NULL; + } - result->sidFilename = XS_CS_FILENAME(filename); - if (!result->sidFilename) { - xs_error("Could not allocate sidFilename ('%s')\n", - filename); - g_free(result); - return NULL; - } + result->sidFilename = XS_CS_FILENAME(filename); + if (!result->sidFilename) { + xs_error("Could not allocate sidFilename ('%s')\n", + filename); + g_free(result); + return NULL; + } - /* Allocate space for subtune information */ - result->subTunes = g_malloc0(sizeof(xs_subtuneinfo_t) * (nsubTunes + 1)); - if (!result->subTunes) { - xs_error("Could not allocate memory for subtuneinfo ('%s', %i)\n", - filename, nsubTunes); + /* Allocate space for subtune information */ + result->subTunes = g_malloc0(sizeof(xs_subtuneinfo_t) * (nsubTunes + 1)); + if (!result->subTunes) { + xs_error("Could not allocate memory for subtuneinfo ('%s', %i)\n", + filename, nsubTunes); - g_free(result->sidFilename); - g_free(result); - return NULL; - } + g_free(result->sidFilename); + g_free(result); + return NULL; + } - /* The following allocations don't matter if they fail */ - result->sidName = XS_CS_SID(sidName); - result->sidComposer = XS_CS_SID(sidComposer); - result->sidCopyright = XS_CS_SID(sidCopyright); + /* The following allocations don't matter if they fail */ + result->sidName = XS_CS_SID(sidName); + result->sidComposer = XS_CS_SID(sidComposer); + result->sidCopyright = XS_CS_SID(sidCopyright); - result->nsubTunes = nsubTunes; - result->startTune = startTune; + result->nsubTunes = nsubTunes; + result->startTune = startTune; - result->loadAddr = loadAddr; - result->initAddr = initAddr; - result->playAddr = playAddr; - result->dataFileLen = dataFileLen; - result->sidFormat = XS_CS_SID(sidFormat); - - result->sidModel = sidModel; + result->loadAddr = loadAddr; + result->initAddr = initAddr; + result->playAddr = playAddr; + result->dataFileLen = dataFileLen; + result->sidFormat = XS_CS_SID(sidFormat); + + result->sidModel = sidModel; - /* Get length information (NOTE: Do not free this!) */ - tmpLength = xs_songlen_get(filename); - - /* Fill in sub-tune information */ - for (i = 0; i < result->nsubTunes; i++) { - if (tmpLength && (i < tmpLength->nlengths)) - result->subTunes[i].tuneLength = tmpLength->lengths[i]; - else - result->subTunes[i].tuneLength = -1; - - result->subTunes[i].tuneSpeed = -1; - } - - return result; + /* Get length information (NOTE: Do not free this!) */ + tmpLength = xs_songlen_get(filename); + + /* Fill in sub-tune information */ + for (i = 0; i < result->nsubTunes; i++) { + if (tmpLength && (i < tmpLength->nlengths)) + result->subTunes[i].tuneLength = tmpLength->lengths[i]; + else + result->subTunes[i].tuneLength = -1; + + result->subTunes[i].tuneSpeed = -1; + } + + return result; } @@ -275,13 +275,13 @@ */ void xs_tuneinfo_free(xs_tuneinfo_t * tune) { - if (!tune) return; + if (!tune) return; - g_free(tune->subTunes); - g_free(tune->sidFilename); - g_free(tune->sidName); - g_free(tune->sidComposer); - g_free(tune->sidCopyright); - g_free(tune->sidFormat); - g_free(tune); + g_free(tune->subTunes); + g_free(tune->sidFilename); + g_free(tune->sidName); + g_free(tune->sidComposer); + g_free(tune->sidCopyright); + g_free(tune->sidFormat); + g_free(tune); } diff -r 04ea91a61225 -r b0743dc9165d src/xs_slsup.h --- a/src/xs_slsup.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_slsup.h Wed Apr 02 22:10:05 2008 +0300 @@ -9,20 +9,20 @@ extern "C" { #endif -gint xs_stil_init(void); -void xs_stil_close(void); -stil_node_t *xs_stil_get(gchar *filename); +gint xs_stil_init(void); +void xs_stil_close(void); +stil_node_t *xs_stil_get(gchar *filename); -gint xs_songlen_init(void); -void xs_songlen_close(void); -sldb_node_t *xs_songlen_get(const gchar *); +gint xs_songlen_init(void); +void xs_songlen_close(void); +sldb_node_t *xs_songlen_get(const gchar *); -xs_tuneinfo_t *xs_tuneinfo_new(const gchar * pcFilename, - gint nsubTunes, gint startTune, const gchar * sidName, - const gchar * sidComposer, const gchar * sidCopyright, - gint loadAddr, gint initAddr, gint playAddr, - gint dataFileLen, const gchar *sidFormat, gint sidModel); -void xs_tuneinfo_free(xs_tuneinfo_t *); +xs_tuneinfo_t *xs_tuneinfo_new(const gchar * pcFilename, + gint nsubTunes, gint startTune, const gchar * sidName, + const gchar * sidComposer, const gchar * sidCopyright, + gint loadAddr, gint initAddr, gint playAddr, + gint dataFileLen, const gchar *sidFormat, gint sidModel); +void xs_tuneinfo_free(xs_tuneinfo_t *); #ifdef __cplusplus diff -r 04ea91a61225 -r b0743dc9165d src/xs_stil.c --- a/src/xs_stil.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_stil.c Wed Apr 02 22:10:05 2008 +0300 @@ -32,90 +32,90 @@ */ static gboolean xs_stildb_node_realloc(stil_node_t *node, gint nsubTunes) { - if (!node) return FALSE; + if (!node) return FALSE; - /* Re-allocate subTune structure if needed */ - if (nsubTunes > node->nsubTunes) { - gint clearIndex, clearLength; - - node->subTunes = - (stil_subnode_t **) g_realloc(node->subTunes, - (nsubTunes + 1) * sizeof(stil_subnode_t **)); + /* Re-allocate subTune structure if needed */ + if (nsubTunes > node->nsubTunes) { + gint clearIndex, clearLength; + + node->subTunes = + (stil_subnode_t **) g_realloc(node->subTunes, + (nsubTunes + 1) * sizeof(stil_subnode_t **)); - if (!node->subTunes) { - xs_error("SubTune pointer structure realloc failed.\n"); - return FALSE; - } - - /* Clear the newly allocated memory */ - if (node->nsubTunes == 0) { - clearIndex = 0; - clearLength = nsubTunes + 1; - } else { - clearIndex = node->nsubTunes + 1; - clearLength = (nsubTunes - clearIndex + 1); - } - memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(stil_subnode_t **)); - - node->nsubTunes = nsubTunes; - } + if (!node->subTunes) { + xs_error("SubTune pointer structure realloc failed.\n"); + return FALSE; + } + + /* Clear the newly allocated memory */ + if (node->nsubTunes == 0) { + clearIndex = 0; + clearLength = nsubTunes + 1; + } else { + clearIndex = node->nsubTunes + 1; + clearLength = (nsubTunes - clearIndex + 1); + } + memset(&(node->subTunes[clearIndex]), 0, clearLength * sizeof(stil_subnode_t **)); + + node->nsubTunes = nsubTunes; + } - /* Allocate memory for subTune */ - if (!node->subTunes[nsubTunes]) { - node->subTunes[nsubTunes] = (stil_subnode_t *) - g_malloc0(sizeof(stil_subnode_t)); - - if (!node->subTunes[nsubTunes]) { - xs_error("SubTune structure malloc failed!\n"); - return FALSE; - } - } + /* Allocate memory for subTune */ + if (!node->subTunes[nsubTunes]) { + node->subTunes[nsubTunes] = (stil_subnode_t *) + g_malloc0(sizeof(stil_subnode_t)); + + if (!node->subTunes[nsubTunes]) { + xs_error("SubTune structure malloc failed!\n"); + return FALSE; + } + } - return TRUE; + return TRUE; } static void xs_stildb_node_free(stil_node_t *node) { - gint i; - stil_subnode_t *subnode; + gint i; + stil_subnode_t *subnode; - if (!node) return; + if (!node) return; - /* Free subtune information */ - for (i = 0; i <= node->nsubTunes; i++) { - subnode = node->subTunes[i]; - if (subnode) { - g_free(subnode->name); - g_free(subnode->author); - g_free(subnode->info); - g_free(subnode->title); - g_free(subnode); - } - } - g_free(node->subTunes); - g_free(node->filename); - g_free(node); + /* Free subtune information */ + for (i = 0; i <= node->nsubTunes; i++) { + subnode = node->subTunes[i]; + if (subnode) { + g_free(subnode->name); + g_free(subnode->author); + g_free(subnode->info); + g_free(subnode->title); + g_free(subnode); + } + } + g_free(node->subTunes); + g_free(node->filename); + g_free(node); } static stil_node_t *xs_stildb_node_new(gchar *filename) { - stil_node_t *result; + stil_node_t *result; - /* Allocate memory for new node */ - result = (stil_node_t *) g_malloc0(sizeof(stil_node_t)); - if (!result) - return NULL; + /* Allocate memory for new node */ + result = (stil_node_t *) g_malloc0(sizeof(stil_node_t)); + if (!result) + return NULL; - /* Allocate filename and initial space for one subtune */ - result->filename = g_strdup(filename); - if (!result->filename || !xs_stildb_node_realloc(result, 1)) { - xs_stildb_node_free(result); - return NULL; - } - - return result; + /* Allocate filename and initial space for one subtune */ + result->filename = g_strdup(filename); + if (!result->filename || !xs_stildb_node_realloc(result, 1)) { + xs_stildb_node_free(result); + return NULL; + } + + return result; } @@ -123,204 +123,204 @@ */ static void xs_stildb_node_insert(xs_stildb_t *db, stil_node_t *node) { - assert(db != NULL); + assert(db != NULL); - if (db->nodes) { - /* The first node's pPrev points to last node */ - LPREV = db->nodes->prev; /* New node's prev = Previous last node */ - db->nodes->prev->next = node; /* Previous last node's next = New node */ - db->nodes->prev = node; /* New last node = New node */ - LNEXT = NULL; /* But next is NULL! */ - } else { - db->nodes = node; /* First node ... */ - LPREV = node; /* ... it's also last */ - LNEXT = NULL; /* But next is NULL! */ - } + if (db->nodes) { + /* The first node's pPrev points to last node */ + LPREV = db->nodes->prev; /* New node's prev = Previous last node */ + db->nodes->prev->next = node; /* Previous last node's next = New node */ + db->nodes->prev = node; /* New last node = New node */ + LNEXT = NULL; /* But next is NULL! */ + } else { + db->nodes = node; /* First node ... */ + LPREV = node; /* ... it's also last */ + LNEXT = NULL; /* But next is NULL! */ + } } /* Read database (additively) to given db-structure */ -#define XS_STILDB_MULTI \ - if (isMulti) { \ - isMulti = FALSE; \ - xs_pstrcat(&(tmnode->subTunes[subEntry]->info), "\n");\ - } +#define XS_STILDB_MULTI \ + if (isMulti) { \ + isMulti = FALSE; \ + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), "\n");\ + } static void XS_STILDB_ERR(gint lineNum, gchar *inLine, const char *fmt, ...) { - va_list ap; + va_list ap; - va_start(ap, fmt); - xs_error(fmt, ap); - va_end(ap); - - fprintf(stderr, "#%d: '%s'\n", lineNum, inLine); + va_start(ap, fmt); + xs_error(fmt, ap); + va_end(ap); + + fprintf(stderr, "#%d: '%s'\n", lineNum, inLine); } gint xs_stildb_read(xs_stildb_t *db, gchar *dbFilename) { - FILE *inFile; - gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */ - size_t lineNum; - stil_node_t *tmnode; - gboolean isError, isMulti; - gint subEntry; - gchar *tmpLine = inLine; - assert(db != NULL); + FILE *inFile; + gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */ + size_t lineNum; + stil_node_t *tmnode; + gboolean isError, isMulti; + gint subEntry; + gchar *tmpLine = inLine; + assert(db != NULL); - /* Try to open the file */ - if ((inFile = fopen(dbFilename, "ra")) == NULL) { - xs_error("Could not open STILDB '%s'\n", dbFilename); - return -1; - } + /* Try to open the file */ + if ((inFile = fopen(dbFilename, "ra")) == NULL) { + xs_error("Could not open STILDB '%s'\n", dbFilename); + return -1; + } - /* Read and parse the data */ - lineNum = 0; - isError = FALSE; - isMulti = FALSE; - tmnode = NULL; - subEntry = 0; + /* Read and parse the data */ + lineNum = 0; + isError = FALSE; + isMulti = FALSE; + tmnode = NULL; + subEntry = 0; - while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { - size_t linePos = 0, eolPos = 0; - xs_findeol(inLine, &eolPos); - inLine[eolPos] = 0; - lineNum++; - - tmpLine = XS_CS_STIL(inLine); + while (!isError && fgets(inLine, XS_BUF_SIZE, inFile) != NULL) { + size_t linePos = 0, eolPos = 0; + xs_findeol(inLine, &eolPos); + inLine[eolPos] = 0; + lineNum++; + + tmpLine = XS_CS_STIL(inLine); - switch (tmpLine[0]) { - case '/': - /* Check if we are already parsing entry */ - isMulti = FALSE; - if (tmnode) { - XS_STILDB_ERR(lineNum, tmpLine, - "New entry found before end of current ('%s')!\n", - tmnode->filename); - xs_stildb_node_free(tmnode); - } + switch (tmpLine[0]) { + case '/': + /* Check if we are already parsing entry */ + isMulti = FALSE; + if (tmnode) { + XS_STILDB_ERR(lineNum, tmpLine, + "New entry found before end of current ('%s')!\n", + tmnode->filename); + xs_stildb_node_free(tmnode); + } - /* A new node */ - subEntry = 0; - tmnode = xs_stildb_node_new(tmpLine); - if (!tmnode) { - /* Allocation failed */ - XS_STILDB_ERR(lineNum, tmpLine, - "Could not allocate new STILdb-node!\n"); - isError = TRUE; - } - break; + /* A new node */ + subEntry = 0; + tmnode = xs_stildb_node_new(tmpLine); + if (!tmnode) { + /* Allocation failed */ + XS_STILDB_ERR(lineNum, tmpLine, + "Could not allocate new STILdb-node!\n"); + isError = TRUE; + } + break; - case '(': - /* A new sub-entry */ - isMulti = FALSE; - linePos++; - if (tmpLine[linePos] == '#') { - linePos++; - if (isdigit(tmpLine[linePos])) { - size_t savePos = linePos; - xs_findnum(tmpLine, &linePos); - tmpLine[linePos] = 0; - subEntry = atol(&tmpLine[savePos]); + case '(': + /* A new sub-entry */ + isMulti = FALSE; + linePos++; + if (tmpLine[linePos] == '#') { + linePos++; + if (isdigit(tmpLine[linePos])) { + size_t savePos = linePos; + xs_findnum(tmpLine, &linePos); + tmpLine[linePos] = 0; + subEntry = atol(&tmpLine[savePos]); - /* Sanity check */ - if (subEntry < 1) { - XS_STILDB_ERR(lineNum, tmpLine, - "Number of subEntry (%i) for '%s' is invalid\n", - subEntry, tmnode->filename); - subEntry = 0; - } - } else { - XS_STILDB_ERR(lineNum, tmpLine, - "Syntax error, expected subEntry number.\n"); - subEntry = 0; - } - } else { - XS_STILDB_ERR(lineNum, tmpLine, - "Syntax error, expected '#' before subEntry number.\n"); - subEntry = 0; - } + /* Sanity check */ + if (subEntry < 1) { + XS_STILDB_ERR(lineNum, tmpLine, + "Number of subEntry (%i) for '%s' is invalid\n", + subEntry, tmnode->filename); + subEntry = 0; + } + } else { + XS_STILDB_ERR(lineNum, tmpLine, + "Syntax error, expected subEntry number.\n"); + subEntry = 0; + } + } else { + XS_STILDB_ERR(lineNum, tmpLine, + "Syntax error, expected '#' before subEntry number.\n"); + subEntry = 0; + } - break; + break; - case 0: - case '#': - case '\n': - case '\r': - /* End of entry/field */ - isMulti = FALSE; - if (tmnode) { - /* Insert to database */ - xs_stildb_node_insert(db, tmnode); - tmnode = NULL; - } - break; + case 0: + case '#': + case '\n': + case '\r': + /* End of entry/field */ + isMulti = FALSE; + if (tmnode) { + /* Insert to database */ + xs_stildb_node_insert(db, tmnode); + tmnode = NULL; + } + break; - default: - /* Check if we are parsing an entry */ - xs_findnext(tmpLine, &linePos); - - if (!tmnode) { - XS_STILDB_ERR(lineNum, tmpLine, - "Entry data encountered outside of entry or syntax error!\n"); - break; - } + default: + /* Check if we are parsing an entry */ + xs_findnext(tmpLine, &linePos); + + if (!tmnode) { + XS_STILDB_ERR(lineNum, tmpLine, + "Entry data encountered outside of entry or syntax error!\n"); + break; + } - if (!xs_stildb_node_realloc(tmnode, subEntry)) { - XS_STILDB_ERR(lineNum, tmpLine, - "Could not (re)allocate memory for subEntries!\n"); - isError = TRUE; - break; - } - - /* Some other type */ - if (strncmp(tmpLine, " NAME:", 8) == 0) { - XS_STILDB_MULTI; - g_free(tmnode->subTunes[subEntry]->name); - tmnode->subTunes[subEntry]->name = g_strdup(&tmpLine[9]); - } else if (strncmp(tmpLine, " TITLE:", 8) == 0) { - XS_STILDB_MULTI; - isMulti = TRUE; - if (!tmnode->subTunes[subEntry]->title) - tmnode->subTunes[subEntry]->title = g_strdup(&tmpLine[9]); - xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[2]); - } else if (strncmp(tmpLine, " AUTHOR:", 8) == 0) { - XS_STILDB_MULTI; - g_free(tmnode->subTunes[subEntry]->author); - tmnode->subTunes[subEntry]->author = g_strdup(&tmpLine[9]); - } else if (strncmp(tmpLine, " ARTIST:", 8) == 0) { - XS_STILDB_MULTI; - isMulti = TRUE; - xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[1]); - } else if (strncmp(tmpLine, "COMMENT:", 8) == 0) { - XS_STILDB_MULTI; - isMulti = TRUE; - xs_pstrcat(&(tmnode->subTunes[subEntry]->info), tmpLine); - } else { - if (isMulti) { - xs_pstrcat(&(tmnode->subTunes[subEntry]->info), " "); - xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[linePos]); - } else { - XS_STILDB_ERR(lineNum, tmpLine, - "Entry continuation found when isMulti == FALSE.\n"); - } - } - break; - } - - XS_CS_FREE(tmpLine); + if (!xs_stildb_node_realloc(tmnode, subEntry)) { + XS_STILDB_ERR(lineNum, tmpLine, + "Could not (re)allocate memory for subEntries!\n"); + isError = TRUE; + break; + } + + /* Some other type */ + if (strncmp(tmpLine, " NAME:", 8) == 0) { + XS_STILDB_MULTI; + g_free(tmnode->subTunes[subEntry]->name); + tmnode->subTunes[subEntry]->name = g_strdup(&tmpLine[9]); + } else if (strncmp(tmpLine, " TITLE:", 8) == 0) { + XS_STILDB_MULTI; + isMulti = TRUE; + if (!tmnode->subTunes[subEntry]->title) + tmnode->subTunes[subEntry]->title = g_strdup(&tmpLine[9]); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[2]); + } else if (strncmp(tmpLine, " AUTHOR:", 8) == 0) { + XS_STILDB_MULTI; + g_free(tmnode->subTunes[subEntry]->author); + tmnode->subTunes[subEntry]->author = g_strdup(&tmpLine[9]); + } else if (strncmp(tmpLine, " ARTIST:", 8) == 0) { + XS_STILDB_MULTI; + isMulti = TRUE; + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[1]); + } else if (strncmp(tmpLine, "COMMENT:", 8) == 0) { + XS_STILDB_MULTI; + isMulti = TRUE; + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), tmpLine); + } else { + if (isMulti) { + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), " "); + xs_pstrcat(&(tmnode->subTunes[subEntry]->info), &tmpLine[linePos]); + } else { + XS_STILDB_ERR(lineNum, tmpLine, + "Entry continuation found when isMulti == FALSE.\n"); + } + } + break; + } + + XS_CS_FREE(tmpLine); - } /* while */ + } /* while */ - /* Check if there is one remaining node */ - if (tmnode) - xs_stildb_node_insert(db, tmnode); + /* Check if there is one remaining node */ + if (tmnode) + xs_stildb_node_insert(db, tmnode); - /* Close the file */ - fclose(inFile); + /* Close the file */ + fclose(inFile); - return 0; + return 0; } @@ -328,10 +328,10 @@ */ static gint xs_stildb_cmp(const void *node1, const void *node2) { - /* We assume here that we never ever get NULL-pointers or similar */ - return strcmp( - (*(stil_node_t **) node1)->filename, - (*(stil_node_t **) node2)->filename); + /* We assume here that we never ever get NULL-pointers or similar */ + return strcmp( + (*(stil_node_t **) node1)->filename, + (*(stil_node_t **) node2)->filename); } @@ -339,43 +339,43 @@ */ gint xs_stildb_index(xs_stildb_t *db) { - stil_node_t *curr; - size_t i; + stil_node_t *curr; + size_t i; - /* Free old index */ - if (db->pindex) { - g_free(db->pindex); - db->pindex = NULL; - } + /* Free old index */ + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; + } - /* Get size of db */ - curr = db->nodes; - db->n = 0; - while (curr) { - db->n++; - curr = curr->next; - } + /* Get size of db */ + curr = db->nodes; + db->n = 0; + while (curr) { + db->n++; + curr = curr->next; + } - /* Check number of nodes */ - if (db->n > 0) { - /* Allocate memory for index-table */ - db->pindex = (stil_node_t **) g_malloc(sizeof(stil_node_t *) * db->n); - if (!db->pindex) - return -1; + /* Check number of nodes */ + if (db->n > 0) { + /* Allocate memory for index-table */ + db->pindex = (stil_node_t **) g_malloc(sizeof(stil_node_t *) * db->n); + if (!db->pindex) + return -1; - /* Get node-pointers to table */ - i = 0; - curr = db->nodes; - while (curr && (i < db->n)) { - db->pindex[i++] = curr; - curr = curr->next; - } + /* Get node-pointers to table */ + i = 0; + curr = db->nodes; + while (curr && (i < db->n)) { + db->pindex[i++] = curr; + curr = curr->next; + } - /* Sort the indexes */ - qsort(db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp); - } + /* Sort the indexes */ + qsort(db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp); + } - return 0; + return 0; } @@ -383,30 +383,30 @@ */ void xs_stildb_free(xs_stildb_t *db) { - stil_node_t *curr, *next; + stil_node_t *curr, *next; - if (!db) - return; + if (!db) + return; - /* Free the memory allocated for nodes */ - curr = db->nodes; - while (curr) { - next = curr->next; - xs_stildb_node_free(curr); - curr = next; - } + /* Free the memory allocated for nodes */ + curr = db->nodes; + while (curr) { + next = curr->next; + xs_stildb_node_free(curr); + curr = next; + } - db->nodes = NULL; + db->nodes = NULL; - /* Free memory allocated for index */ - if (db->pindex) { - g_free(db->pindex); - db->pindex = NULL; - } + /* Free memory allocated for index */ + if (db->pindex) { + g_free(db->pindex); + db->pindex = NULL; + } - /* Free structure */ - db->n = 0; - g_free(db); + /* Free structure */ + db->n = 0; + g_free(db); } @@ -414,18 +414,18 @@ */ stil_node_t *xs_stildb_get_node(xs_stildb_t *db, gchar *filename) { - stil_node_t keyItem, *key, **item; + stil_node_t keyItem, *key, **item; - /* Check the database pointers */ - if (!db || !db->nodes || !db->pindex) - return NULL; + /* Check the database pointers */ + if (!db || !db->nodes || !db->pindex) + return NULL; - /* Look-up index using binary search */ - keyItem.filename = filename; - key = &keyItem; - item = bsearch(&key, db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp); - if (item) - return *item; - else - return NULL; + /* Look-up index using binary search */ + keyItem.filename = filename; + key = &keyItem; + item = bsearch(&key, db->pindex, db->n, sizeof(stil_node_t *), xs_stildb_cmp); + if (item) + return *item; + else + return NULL; } diff -r 04ea91a61225 -r b0743dc9165d src/xs_stil.h --- a/src/xs_stil.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_stil.h Wed Apr 02 22:10:05 2008 +0300 @@ -10,34 +10,34 @@ /* Types */ typedef struct { - gchar *name, - *author, - *title, - *info; + gchar *name, + *author, + *title, + *info; } stil_subnode_t; typedef struct _stil_node_t { - gchar *filename; - gint nsubTunes; - stil_subnode_t **subTunes; - struct _stil_node_t *prev, *next; + gchar *filename; + gint nsubTunes; + stil_subnode_t **subTunes; + struct _stil_node_t *prev, *next; } stil_node_t; typedef struct { - stil_node_t *nodes, - **pindex; - size_t n; + stil_node_t *nodes, + **pindex; + size_t n; } xs_stildb_t; /* Functions */ -gint xs_stildb_read(xs_stildb_t *, gchar *); -gint xs_stildb_index(xs_stildb_t *); -void xs_stildb_free(xs_stildb_t *); -stil_node_t * xs_stildb_get_node(xs_stildb_t *, gchar *); +gint xs_stildb_read(xs_stildb_t *, gchar *); +gint xs_stildb_index(xs_stildb_t *); +void xs_stildb_free(xs_stildb_t *); +stil_node_t * xs_stildb_get_node(xs_stildb_t *, gchar *); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_support.c --- a/src/xs_support.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_support.c Wed Apr 02 22:10:05 2008 +0300 @@ -26,16 +26,16 @@ guint16 xs_fread_be16(xs_file_t *f) { - return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); + return (((guint16) xs_fgetc(f)) << 8) | ((guint16) xs_fgetc(f)); } guint32 xs_fread_be32(xs_file_t *f) { - return (((guint32) xs_fgetc(f)) << 24) | - (((guint32) xs_fgetc(f)) << 16) | - (((guint32) xs_fgetc(f)) << 8) | - ((guint32) xs_fgetc(f)); + return (((guint32) xs_fgetc(f)) << 24) | + (((guint32) xs_fgetc(f)) << 16) | + (((guint32) xs_fgetc(f)) << 8) | + ((guint32) xs_fgetc(f)); } @@ -43,47 +43,47 @@ */ gint xs_fload_buffer(const gchar *filename, guint8 **buf, size_t *bufSize) { - xs_file_t *f; - glong seekPos; - - /* Open file, get file size */ - if ((f = xs_fopen(filename, "rb")) == NULL) - return -1; + xs_file_t *f; + glong seekPos; + + /* Open file, get file size */ + if ((f = xs_fopen(filename, "rb")) == NULL) + return -1; - xs_fseek(f, 0, SEEK_END); - seekPos = xs_ftell(f); - - if (seekPos > 0) { - size_t readSize = seekPos; - if (readSize >= *bufSize || *buf == NULL) { - /* Only re-allocate if the required size > current */ - if (*buf != NULL) { - g_free(*buf); - *buf = NULL; - } - - *bufSize = seekPos; - - *buf = (guint8 *) g_malloc(*bufSize * sizeof(guint8)); - if (*buf == NULL) { - xs_fclose(f); - return -2; - } - } - - /* Read data */ - xs_fseek(f, 0, SEEK_SET); - readSize = xs_fread(*buf, sizeof(guint8), *bufSize, f); - xs_fclose(f); - - if (readSize != *bufSize) - return -3; - else - return 0; - } else { - xs_fclose(f); - return -4; - } + xs_fseek(f, 0, SEEK_END); + seekPos = xs_ftell(f); + + if (seekPos > 0) { + size_t readSize = seekPos; + if (readSize >= *bufSize || *buf == NULL) { + /* Only re-allocate if the required size > current */ + if (*buf != NULL) { + g_free(*buf); + *buf = NULL; + } + + *bufSize = seekPos; + + *buf = (guint8 *) g_malloc(*bufSize * sizeof(guint8)); + if (*buf == NULL) { + xs_fclose(f); + return -2; + } + } + + /* Read data */ + xs_fseek(f, 0, SEEK_SET); + readSize = xs_fread(*buf, sizeof(guint8), *bufSize, f); + xs_fclose(f); + + if (readSize != *bufSize) + return -3; + else + return 0; + } else { + xs_fclose(f); + return -4; + } } @@ -91,33 +91,33 @@ */ gchar *xs_strncpy(gchar *pDest, const gchar *pSource, size_t n) { - const gchar *s; - gchar *d; - size_t i; + const gchar *s; + gchar *d; + size_t i; - /* Check the string pointers */ - if (!pSource || !pDest) - return pDest; + /* Check the string pointers */ + if (!pSource || !pDest) + return pDest; - /* Copy to the destination */ - i = n; - s = pSource; - d = pDest; - while (*s && (i > 0)) { - *(d++) = *(s++); - i--; - } + /* Copy to the destination */ + i = n; + s = pSource; + d = pDest; + while (*s && (i > 0)) { + *(d++) = *(s++); + i--; + } - /* Fill rest of space with zeros */ - while (i > 0) { - *(d++) = 0; - i--; - } + /* Fill rest of space with zeros */ + while (i > 0) { + *(d++) = 0; + i--; + } - /* Ensure that last is always zero */ - pDest[n - 1] = 0; + /* Ensure that last is always zero */ + pDest[n - 1] = 0; - return pDest; + return pDest; } @@ -125,21 +125,21 @@ */ gint xs_pstrcpy(gchar **ppResult, const gchar *pStr) { - /* Check the string pointers */ - if (!ppResult || !pStr) - return -1; + /* Check the string pointers */ + if (!ppResult || !pStr) + return -1; - /* Allocate memory for destination */ - if (*ppResult) - g_free(*ppResult); - *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); - if (!*ppResult) - return -2; + /* Allocate memory for destination */ + if (*ppResult) + g_free(*ppResult); + *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); + if (!*ppResult) + return -2; - /* Copy to the destination */ - strcpy(*ppResult, pStr); + /* Copy to the destination */ + strcpy(*ppResult, pStr); - return 0; + return 0; } @@ -147,23 +147,23 @@ */ gint xs_pstrcat(gchar **ppResult, const gchar *pStr) { - /* Check the string pointers */ - if (!ppResult || !pStr) - return -1; + /* Check the string pointers */ + if (!ppResult || !pStr) + return -1; - if (*ppResult != NULL) { - *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); - if (*ppResult == NULL) - return -1; - strcat(*ppResult, pStr); - } else { - *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); - if (*ppResult == NULL) - return -1; - strcpy(*ppResult, pStr); - } + if (*ppResult != NULL) { + *ppResult = (gchar *) g_realloc(*ppResult, strlen(*ppResult) + strlen(pStr) + 1); + if (*ppResult == NULL) + return -1; + strcat(*ppResult, pStr); + } else { + *ppResult = (gchar *) g_malloc(strlen(pStr) + 1); + if (*ppResult == NULL) + return -1; + strcpy(*ppResult, pStr); + } - return 0; + return 0; } @@ -172,38 +172,38 @@ */ void xs_pnstrcat(gchar *pDest, size_t iSize, const gchar *pStr) { - size_t i, n; - const gchar *s; - gchar *d; + size_t i, n; + const gchar *s; + gchar *d; - d = pDest; - i = 0; - while (*d && (i < iSize)) { - i++; - d++; - } + d = pDest; + i = 0; + while (*d && (i < iSize)) { + i++; + d++; + } - s = pStr; - while (*s && (*s != '\n') && (i < iSize)) { - *d = *s; - d++; - s++; - i++; - } + s = pStr; + while (*s && (*s != '\n') && (i < iSize)) { + *d = *s; + d++; + s++; + i++; + } - *d = 0; + *d = 0; - if (i >= iSize) { - i--; - d--; - n = 3; - while ((i > 0) && (n > 0)) { - *d = '.'; - d--; - i--; - n--; - } - } + if (i >= iSize) { + i--; + d--; + n = 3; + while ((i > 0) && (n > 0)) { + *d = '.'; + d--; + i--; + n--; + } + } } @@ -211,35 +211,35 @@ */ gchar *xs_strrchr(gchar *pcStr, const gchar ch) { - gchar *lastPos = NULL; + gchar *lastPos = NULL; - while (*pcStr) { - if (*pcStr == ch) - lastPos = pcStr; - pcStr++; - } + while (*pcStr) { + if (*pcStr == ch) + lastPos = pcStr; + pcStr++; + } - return lastPos; + return lastPos; } void xs_findnext(const gchar *pcStr, size_t *piPos) { - while (pcStr[*piPos] && isspace(pcStr[*piPos])) - (*piPos)++; + while (pcStr[*piPos] && isspace(pcStr[*piPos])) + (*piPos)++; } void xs_findeol(const gchar *pcStr, size_t *piPos) { - while (pcStr[*piPos] && (pcStr[*piPos] != '\n') && (pcStr[*piPos] != '\r')) - (*piPos)++; + while (pcStr[*piPos] && (pcStr[*piPos] != '\n') && (pcStr[*piPos] != '\r')) + (*piPos)++; } void xs_findnum(const gchar *pcStr, size_t *piPos) { - while (pcStr[*piPos] && isdigit(pcStr[*piPos])) - (*piPos)++; + while (pcStr[*piPos] && isdigit(pcStr[*piPos])) + (*piPos)++; } diff -r 04ea91a61225 -r b0743dc9165d src/xs_support.h --- a/src/xs_support.h Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_support.h Wed Apr 02 22:10:05 2008 +0300 @@ -89,19 +89,19 @@ #endif guint16 xs_fread_be16(xs_file_t *); guint32 xs_fread_be32(xs_file_t *); -gint xs_fload_buffer(const gchar *, guint8 **, size_t *); +gint xs_fload_buffer(const gchar *, guint8 **, size_t *); /* Misc functions */ -gchar *xs_strncpy(gchar *, const gchar *, size_t); -gint xs_pstrcpy(gchar **, const gchar *); -gint xs_pstrcat(gchar **, const gchar *); -void xs_pnstrcat(gchar *, size_t, const gchar *); -gchar *xs_strrchr(gchar *, const gchar); -void xs_findnext(const gchar *, size_t *); -void xs_findeol(const gchar *, size_t *); -void xs_findnum(const gchar *, size_t *); +gchar *xs_strncpy(gchar *, const gchar *, size_t); +gint xs_pstrcpy(gchar **, const gchar *); +gint xs_pstrcat(gchar **, const gchar *); +void xs_pnstrcat(gchar *, size_t, const gchar *); +gchar *xs_strrchr(gchar *, const gchar); +void xs_findnext(const gchar *, size_t *); +void xs_findeol(const gchar *, size_t *); +void xs_findnum(const gchar *, size_t *); #ifdef __cplusplus } diff -r 04ea91a61225 -r b0743dc9165d src/xs_title.c --- a/src/xs_title.c Wed Apr 02 21:29:26 2008 +0300 +++ b/src/xs_title.c Wed Apr 02 22:10:05 2008 +0300 @@ -27,195 +27,195 @@ 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; + 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); + /* Filename */ + *tmpFilename = xs_strrchr(path, '/'); + if (*tmpFilename) + *tmpFilename = g_strdup(*tmpFilename + 1); + else + *tmpFilename = g_strdup(path); - tmpStr = xs_strrchr(*tmpFilename, '.'); - tmpStr[0] = 0; + tmpStr = xs_strrchr(*tmpFilename, '.'); + tmpStr[0] = 0; - /* Extension */ - *tmpFileExt = xs_strrchr(path, '.'); + /* Extension */ + *tmpFileExt = xs_strrchr(path, '.'); } /* Create a title string based on given information and settings. */ -#define VPUTCH(MCH) \ - if (index < XS_BUF_SIZE) tmpBuf[index++] = MCH; +#define VPUTCH(MCH) \ + if (index < XS_BUF_SIZE) tmpBuf[index++] = MCH; -#define VPUTSTR(MSTR) { \ - if (MSTR) { \ - if ((index + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ - strcpy(&tmpBuf[index], MSTR); \ - index += strlen(MSTR); \ - } else \ - index = XS_BUF_SIZE; \ - } \ +#define VPUTSTR(MSTR) { \ + if (MSTR) { \ + if ((index + strlen(MSTR) + 1) < XS_BUF_SIZE) {\ + strcpy(&tmpBuf[index], MSTR); \ + index += strlen(MSTR); \ + } else \ + index = XS_BUF_SIZE; \ + } \ } gchar *xs_make_titlestring(xs_tuneinfo_t *p, gint subTune) { - gchar *tmpFilename, *tmpFilePath, *tmpFileExt, - *str, *result, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; - xs_subtuneinfo_t *subInfo; - gint index; + gchar *tmpFilename, *tmpFilePath, *tmpFileExt, + *str, *result, tmpStr[XS_BUF_SIZE], tmpBuf[XS_BUF_SIZE]; + xs_subtuneinfo_t *subInfo; + gint index; - /* 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; + /* 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; - /* Check if the titles are overridden or not */ + /* Check if the titles are overridden or not */ #ifdef HAVE_XMMSEXTRA - if (!xs_cfg.titleOverride) { - TitleInput *pTuple; - - pTuple = (TitleInput *) g_malloc0(sizeof(TitleInput)); - pTuple->__size = XMMS_TITLEINPUT_SIZE; - pTuple->__version = XMMS_TITLEINPUT_VERSION; - - /* Create the input fields */ - pTuple->file_name = tmpFilename; - pTuple->file_ext = tmpFileExt; - pTuple->file_path = tmpFilePath; + if (!xs_cfg.titleOverride) { + TitleInput *pTuple; + + pTuple = (TitleInput *) g_malloc0(sizeof(TitleInput)); + pTuple->__size = XMMS_TITLEINPUT_SIZE; + pTuple->__version = XMMS_TITLEINPUT_VERSION; + + /* Create the input fields */ + pTuple->file_name = tmpFilename; + pTuple->file_ext = tmpFileExt; + pTuple->file_path = tmpFilePath; - pTuple->track_name = g_strdup(p->sidName); - pTuple->track_number = subTune; - pTuple->album_name = NULL; - pTuple->performer = g_strdup(p->sidComposer); - pTuple->date = g_strdup((p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"); + pTuple->track_name = g_strdup(p->sidName); + pTuple->track_number = subTune; + pTuple->album_name = NULL; + pTuple->performer = g_strdup(p->sidComposer); + pTuple->date = g_strdup((p->sidModel == XS_SIDMODEL_6581) ? "SID6581" : "SID8580"); - pTuple->year = 0; - pTuple->genre = g_strdup("SID-tune"); - pTuple->comment = g_strdup(p->sidCopyright); + pTuple->year = 0; + pTuple->genre = g_strdup("SID-tune"); + pTuple->comment = g_strdup(p->sidCopyright); - result = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); + result = xmms_get_titlestring(xmms_get_gentitle_format(), pTuple); - g_free(pTuple->track_name); - g_free(pTuple->album_name); - g_free(pTuple->performer); - g_free(pTuple->date); - g_free(pTuple->genre); - g_free(pTuple->comment); - g_free(pTuple); - } else + g_free(pTuple->track_name); + g_free(pTuple->album_name); + g_free(pTuple->performer); + g_free(pTuple->date); + g_free(pTuple->genre); + g_free(pTuple->comment); + g_free(pTuple); + } else #endif - { - /* Create the string */ - str = xs_cfg.titleFormat; - index = 0; - while (*str && (index < XS_BUF_SIZE)) { - if (*str == '%') { - str++; - switch (*str) { - case '%': - VPUTCH('%'); - break; - case 'f': - VPUTSTR(tmpFilename); - break; - case 'F': - VPUTSTR(tmpFilePath); - break; - case 'e': - VPUTSTR(tmpFileExt); - break; - case 'p': - VPUTSTR(p->sidComposer); - break; - case 't': - VPUTSTR(p->sidName); - break; - case 'c': - VPUTSTR(p->sidCopyright); - break; - case 's': - VPUTSTR(p->sidFormat); - break; - case 'm': - switch (p->sidModel) { - case XS_SIDMODEL_6581: - VPUTSTR("6581"); - break; - case XS_SIDMODEL_8580: - VPUTSTR("8580"); - break; - case XS_SIDMODEL_ANY: - VPUTSTR("ANY"); - break; - default: - VPUTSTR("?"); - break; - } - break; - case 'C': - if (subInfo && (subInfo->tuneSpeed > 0)) { - switch (subInfo->tuneSpeed) { - case XS_CLOCK_PAL: - VPUTSTR("PAL"); - break; - case XS_CLOCK_NTSC: - VPUTSTR("NTSC"); - break; - case XS_CLOCK_ANY: - VPUTSTR("ANY"); - break; - case XS_CLOCK_VBI: - VPUTSTR("VBI"); - break; - case XS_CLOCK_CIA: - VPUTSTR("CIA"); - break; - default: - g_snprintf(tmpStr, XS_BUF_SIZE, - "%iHz", subInfo->tuneSpeed); - VPUTSTR(tmpStr); - } - } else - VPUTSTR("?"); - break; - case 'n': - g_snprintf(tmpStr, XS_BUF_SIZE, "%i", subTune); - VPUTSTR(tmpStr); - break; - case 'N': - g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); - VPUTSTR(tmpStr); - break; - } - } else - VPUTCH(*str); + { + /* Create the string */ + str = xs_cfg.titleFormat; + index = 0; + while (*str && (index < XS_BUF_SIZE)) { + if (*str == '%') { + str++; + switch (*str) { + case '%': + VPUTCH('%'); + break; + case 'f': + VPUTSTR(tmpFilename); + break; + case 'F': + VPUTSTR(tmpFilePath); + break; + case 'e': + VPUTSTR(tmpFileExt); + break; + case 'p': + VPUTSTR(p->sidComposer); + break; + case 't': + VPUTSTR(p->sidName); + break; + case 'c': + VPUTSTR(p->sidCopyright); + break; + case 's': + VPUTSTR(p->sidFormat); + break; + case 'm': + switch (p->sidModel) { + case XS_SIDMODEL_6581: + VPUTSTR("6581"); + break; + case XS_SIDMODEL_8580: + VPUTSTR("8580"); + break; + case XS_SIDMODEL_ANY: + VPUTSTR("ANY"); + break; + default: + VPUTSTR("?"); + break; + } + break; + case 'C': + if (subInfo && (subInfo->tuneSpeed > 0)) { + switch (subInfo->tuneSpeed) { + case XS_CLOCK_PAL: + VPUTSTR("PAL"); + break; + case XS_CLOCK_NTSC: + VPUTSTR("NTSC"); + break; + case XS_CLOCK_ANY: + VPUTSTR("ANY"); + break; + case XS_CLOCK_VBI: + VPUTSTR("VBI"); + break; + case XS_CLOCK_CIA: + VPUTSTR("CIA"); + break; + default: + g_snprintf(tmpStr, XS_BUF_SIZE, + "%iHz", subInfo->tuneSpeed); + VPUTSTR(tmpStr); + } + } else + VPUTSTR("?"); + break; + case 'n': + g_snprintf(tmpStr, XS_BUF_SIZE, "%i", subTune); + VPUTSTR(tmpStr); + break; + case 'N': + g_snprintf(tmpStr, XS_BUF_SIZE, "%i", p->nsubTunes); + VPUTSTR(tmpStr); + break; + } + } else + VPUTCH(*str); - str++; - } + str++; + } - tmpBuf[index] = 0; + tmpBuf[index] = 0; - /* Make resulting string */ - result = g_strdup(tmpBuf); - } + /* Make resulting string */ + result = g_strdup(tmpBuf); + } - /* Free temporary strings */ - g_free(tmpFilename); - g_free(tmpFilePath); + /* Free temporary strings */ + g_free(tmpFilename); + g_free(tmpFilePath); - return result; + return result; }