Mercurial > audlegacy-plugins
changeset 1595:a08203b533da
Branch merge.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Sep 2007 02:23:09 +0300 |
parents | 78d8dd386d0b (diff) 0b19f8924500 (current diff) |
children | 9ad9b3479b38 |
files | |
diffstat | 5 files changed, 117 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/src/sid/xmms-sid.c Wed Sep 05 00:29:16 2007 +0200 +++ b/src/sid/xmms-sid.c Wed Sep 05 02:23:09 2007 +0300 @@ -28,7 +28,6 @@ #include <stdarg.h> #include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> #include "xs_config.h" #include "xs_length.h" @@ -125,6 +124,8 @@ gint iPlayer; gboolean isInitialized; + XSDEBUG("xs_reinit() thread = %p\n", g_thread_self()); + /* Stop playing, if we are */ XS_MUTEX_LOCK(xs_status); if (xs_status.isPlaying) { @@ -220,7 +221,6 @@ XSDEBUG("xs_init()\n"); /* Initialize and get configuration */ - xs_memset(&xs_cfg, 0, sizeof(xs_cfg)); xs_init_configuration(); xs_read_configuration(); @@ -353,10 +353,9 @@ */ void xs_play_file(InputPlayback *pb) { - t_xs_status myStatus; - t_xs_tuneinfo *myTune; + t_xs_tuneinfo *tmpTune; gboolean audioOpen = FALSE; - gint audioGot, songLength, i, subTune; + gint audioGot, tmpLength, i, subTune; gchar *tmpFilename, *audioBuffer = NULL, *oversampleBuffer = NULL, *tmpTitle; Tuple *tmpTuple; @@ -369,14 +368,15 @@ /* Get tune information */ xs_get_trackinfo(pb->filename, &tmpFilename, &subTune); - if ((xs_status.tuneInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename)) == NULL) { + XS_MUTEX_UNLOCK(xs_status); g_free(tmpFilename); return; } /* Initialize the tune */ if (!xs_status.sidPlayer->plrLoadSID(&xs_status, tmpFilename)) { + XS_MUTEX_UNLOCK(xs_status); g_free(tmpFilename); xs_tuneinfo_free(xs_status.tuneInfo); xs_status.tuneInfo = NULL; @@ -391,7 +391,7 @@ /* Set general status information */ xs_status.isPlaying = TRUE; xs_status.isError = FALSE; - myTune = xs_status.tuneInfo; + tmpTune = xs_status.tuneInfo; if (subTune < 1 || subTune > xs_status.tuneInfo->nsubTunes) xs_status.currSong = xs_status.tuneInfo->startTune; @@ -399,12 +399,11 @@ xs_status.currSong = subTune; XSDEBUG("subtune #%i selected (#%d wanted), initializing...\n", xs_status.currSong, subTune); - memcpy(&myStatus, &xs_status, sizeof(t_xs_status)); - XS_MUTEX_UNLOCK(xs_status); /* We are ready */ xs_decode_thread = g_thread_self(); + XSDEBUG("playing thread = %p\n", xs_decode_thread); pb->set_pb_ready(pb); @@ -412,43 +411,45 @@ audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); if (audioBuffer == NULL) { xs_error(_("Couldn't allocate memory for audio data buffer!\n")); + XS_MUTEX_UNLOCK(xs_status); goto xs_err_exit; } - - if (myStatus.oversampleEnable) { - oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor); + + if (xs_status.oversampleEnable) { + oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * xs_status.oversampleFactor); if (oversampleBuffer == NULL) { xs_error(_("Couldn't allocate memory for audio oversampling buffer!\n")); + XS_MUTEX_UNLOCK(xs_status); goto xs_err_exit; } } /* 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; + tmpLength = tmpTune->subTunes[xs_status.currSong - 1].tuneLength; + if (xs_cfg.playMinTimeEnable && (tmpLength >= 0)) { + if (tmpLength < xs_cfg.playMinTime) + tmpLength = xs_cfg.playMinTime; } /* Initialize song */ - if (!myStatus.sidPlayer->plrInitSong(&myStatus)) { + if (!xs_status.sidPlayer->plrInitSong(&xs_status)) { xs_error(_("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n"), - myTune->sidFilename, myStatus.currSong); + tmpTune->sidFilename, xs_status.currSong); + XS_MUTEX_UNLOCK(xs_status); goto xs_err_exit; } /* Open the audio output */ XSDEBUG("open audio output (%d, %d, %d)\n", - myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); + xs_status.audioFormat, xs_status.audioFrequency, xs_status.audioChannels); - if (!pb->output->open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) { + if (!pb->output->open_audio(xs_status.audioFormat, xs_status.audioFrequency, xs_status.audioChannels)) { xs_error(_("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n"), - myStatus.audioFormat, - myStatus.audioFrequency, - myStatus.audioChannels); + xs_status.audioFormat, + xs_status.audioFrequency, + xs_status.audioChannels); - XS_MUTEX_LOCK(xs_status); xs_status.isError = TRUE; XS_MUTEX_UNLOCK(xs_status); goto xs_err_exit; @@ -457,73 +458,81 @@ audioOpen = TRUE; /* Set song information for current subtune */ - XSDEBUG("foobar\n"); - myStatus.sidPlayer->plrUpdateSIDInfo(&myStatus); - - tmpTuple = xs_get_song_tuple_info(myTune->sidFilename, myStatus.currSong); + XSDEBUG("foobar #1\n"); + xs_status.sidPlayer->plrUpdateSIDInfo(&xs_status); + XSDEBUG("foobar #2\n"); + XS_MUTEX_UNLOCK(xs_status); + tmpTuple = xs_get_song_tuple_info(tmpTune->sidFilename, xs_status.currSong); + XSDEBUG("foobar #3\n"); tmpTitle = tuple_formatter_process_string(tmpTuple, get_gentitle_format()); + XSDEBUG("foobar #4\n"); + XS_MUTEX_LOCK(xs_status); xs_plugin_ip.set_info( tmpTitle, - (songLength > 0) ? (songLength * 1000) : 0, + (tmpLength > 0) ? (tmpLength * 1000) : 0, -1, - myStatus.audioFrequency, - myStatus.audioChannels); + xs_status.audioFrequency, + xs_status.audioChannels); g_free(tmpTitle); - + XS_MUTEX_UNLOCK(xs_status); XSDEBUG("playing\n"); - while (xs_status.isPlaying && myStatus.isPlaying) { + while (xs_status.isPlaying) { /* Render audio data */ - if (myStatus.oversampleEnable) { + XS_MUTEX_LOCK(xs_status); + if (xs_status.oversampleEnable) { /* Perform oversampled rendering */ - audioGot = myStatus.sidPlayer->plrFillBuffer( - &myStatus, + audioGot = xs_status.sidPlayer->plrFillBuffer( + &xs_status, oversampleBuffer, - (XS_AUDIOBUF_SIZE * myStatus.oversampleFactor)); + (XS_AUDIOBUF_SIZE * xs_status.oversampleFactor)); - audioGot /= myStatus.oversampleFactor; + audioGot /= xs_status.oversampleFactor; /* Execute rate-conversion with filtering */ if (xs_filter_rateconv(audioBuffer, oversampleBuffer, - myStatus.audioFormat, myStatus.oversampleFactor, audioGot) < 0) { + xs_status.audioFormat, xs_status.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); + audioGot = xs_status.sidPlayer->plrFillBuffer( + &xs_status, audioBuffer, XS_AUDIOBUF_SIZE); } /* I <3 visualice/haujobb */ produce_audio(pb->output->written_time(), - myStatus.audioFormat, myStatus.audioChannels, + xs_status.audioFormat, xs_status.audioChannels, audioGot, audioBuffer, NULL); + + XS_MUTEX_UNLOCK(xs_status); /* Wait a little */ while (xs_status.isPlaying && (pb->output->buffer_free() < audioGot)) xmms_usleep(500); /* Check if we have played enough */ + XS_MUTEX_LOCK(xs_status); if (xs_cfg.playMaxTimeEnable) { if (xs_cfg.playMaxTimeUnknown) { - if ((songLength < 0) && + if ((tmpLength < 0) && (pb->output->output_time() >= (xs_cfg.playMaxTime * 1000))) - myStatus.isPlaying = FALSE; + xs_status.isPlaying = FALSE; } else { if (pb->output->output_time() >= (xs_cfg.playMaxTime * 1000)) - myStatus.isPlaying = FALSE; + xs_status.isPlaying = FALSE; } } - if (songLength >= 0) { - if (pb->output->output_time() >= (songLength * 1000)) - myStatus.isPlaying = FALSE; + if (tmpLength >= 0) { + if (pb->output->output_time() >= (tmpLength * 1000)) + xs_status.isPlaying = FALSE; } + XS_MUTEX_UNLOCK(xs_status); } xs_err_exit:
--- a/src/sid/xmms-sid.h Wed Sep 05 00:29:16 2007 +0200 +++ b/src/sid/xmms-sid.h Wed Sep 05 02:23:09 2007 +0300 @@ -35,7 +35,7 @@ /* #define to enable spurious debugging messages for development * purposes. Output goes to stderr. See also DEBUG_NP below. */ -#define DEBUG +#undef DEBUG /* Define to ISO C99 macro for debugging instead of varargs function. * This provides more useful information, but is incompatible with @@ -106,10 +106,20 @@ #define XS_THREAD_EXIT(M) g_thread_exit(M) #define XS_THREAD_JOIN(M) g_thread_join(M) #define XS_MPP(M) M ## _mutex -#define XS_MUTEX(M) GStaticMutex XS_MPP(M) = G_STATIC_MUTEX_INIT +#define XS_MUTEX(M) GStaticMutex XS_MPP(M) = G_STATIC_MUTEX_INIT #define XS_MUTEX_H(M) extern GStaticMutex XS_MPP(M) -#define XS_MUTEX_LOCK(M) g_static_mutex_lock(&XS_MPP(M)) -#define XS_MUTEX_UNLOCK(M) g_static_mutex_unlock(&XS_MPP(M)) +#ifdef XS_MUTEX_DEBUG +# define XS_MUTEX_LOCK(M) { \ + gboolean tmpRes; \ + XSDEBUG("XS_MUTEX_TRYLOCK(" #M ")\n"); \ + tmpRes = g_static_mutex_trylock(&XS_MPP(M)); \ + XSDEBUG("[" #M "] = %s\n", tmpRes ? "TRUE" : "FALSE"); \ + } +# define XS_MUTEX_UNLOCK(M) { XSDEBUG("XS_MUTEX_UNLOCK(" #M ")\n"); g_static_mutex_unlock(&XS_MPP(M)); } +#else +# define XS_MUTEX_LOCK(M) g_static_mutex_lock(&XS_MPP(M)) +# define XS_MUTEX_UNLOCK(M) g_static_mutex_unlock(&XS_MPP(M)) +#endif /* Character set conversion helper macros */
--- a/src/sid/xs_config.c Wed Sep 05 00:29:16 2007 +0200 +++ b/src/sid/xs_config.c Wed Sep 05 02:23:09 2007 +0300 @@ -74,13 +74,13 @@ /* Samplerates */ -static gchar *xs_samplerates_table[] = { +static const gchar *xs_samplerates_table[] = { "8000", "11025", "22050", "44100", "48000", "64000", "96000" }; -static gint xs_nsamplerates_table = (sizeof(xs_samplerates_table) / sizeof(xs_samplerates_table[0])); +static const gint xs_nsamplerates_table = (sizeof(xs_samplerates_table) / sizeof(xs_samplerates_table[0])); /* * Configuration specific stuff
--- a/src/sid/xs_fileinfo.c Wed Sep 05 00:29:16 2007 +0200 +++ b/src/sid/xs_fileinfo.c Wed Sep 05 02:23:09 2007 +0300 @@ -122,7 +122,6 @@ { t_xs_stil_subnode *tmpNode; GtkWidget *tmpText; - gint tmpIndex; gchar *subName, *subAuthor, *subInfo; (void) widget; @@ -137,12 +136,9 @@ #endif /* Get subtune information */ - tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, gtk_menu_get_active(GTK_MENU(data))); - - if (xs_fileinfostil && tmpIndex <= xs_fileinfostil->nsubTunes) - tmpNode = xs_fileinfostil->subTunes[tmpIndex]; - else - tmpNode = NULL; + tmpNode = (t_xs_stil_subnode *) data; + if (!tmpNode && xs_fileinfostil) + tmpNode = xs_fileinfostil->subTunes[0]; if (tmpNode) { if (tmpNode->pName) @@ -178,6 +174,7 @@ { GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; t_xs_tuneinfo *tmpInfo; + t_xs_stil_subnode *tmpNode; gchar tmpStr[256], *tmpFilename; gint n; @@ -238,38 +235,53 @@ tmpMenuItem = gtk_menu_item_new_with_label(_("General info")); gtk_widget_show(tmpMenuItem); gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); - XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpMenu); + 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]) { - t_xs_stil_subnode *tmpNode = xs_fileinfostil->subTunes[n]; + gboolean isSet = FALSE; + tmpNode = xs_fileinfostil->subTunes[n]; g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); - if (tmpNode->pName) + if (tmpNode->pName) { xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName); - else if (tmpNode->pTitle) - xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pTitle); - else if (tmpNode->pInfo) - xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo); - else + isSet = TRUE; + } + + if (tmpNode->pTitle) { + xs_pnstrcat(tmpStr, sizeof(tmpStr), + isSet ? " [*]" : tmpNode->pTitle); + isSet = TRUE; + } + + if (tmpNode->pInfo) { + xs_pnstrcat(tmpStr, sizeof(tmpStr), + isSet ? " [!]" : tmpNode->pInfo); + isSet = TRUE; + } + + if (!isSet) xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); - } else { - g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i"), n); + + 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, tmpMenu); } gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu); gtk_widget_show(tmpOptionMenu); /* Set the subtune information */ - xs_fileinfo_subtune(tmpOptionMenu, tmpMenu); + xs_fileinfo_subtune(tmpOptionMenu, NULL); /* Free temporary tuneinfo */ xs_tuneinfo_free(tmpInfo);
--- a/src/xspf/xspf.c Wed Sep 05 00:29:16 2007 +0200 +++ b/src/xspf/xspf.c Wed Sep 05 02:23:09 2007 +0300 @@ -112,16 +112,16 @@ if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"location")) { gchar *str = (gchar *)xmlNodeGetContent(nptr); - gchar *tmp = NULL; - // tmp is escaped uri or a part of escaped uri. - tmp = g_strdup_printf("%s%s", base ? base : "", str); - location = g_filename_from_uri(tmp, NULL, NULL); - if(!location) // http:// or something. - location = g_strdup(tmp); - - xmlFree(str); str = NULL; - g_free(tmp); tmp = NULL; + location = g_strdup_printf("%s%s", base ? base : "", str); + xmlFree(str); + str = g_filename_from_uri(location, NULL, NULL); + if (str) { + g_free(location); + location = g_strdup_printf("file://%s", str); + } + + g_free(str); } else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"title")) {