Mercurial > audlegacy-plugins
changeset 1013:177d47add6dd trunk
[svn] lastfn's metadata seems to wotk, but still it has some glitches
enjoy!
author | majeru |
---|---|
date | Fri, 11 May 2007 06:08:46 -0700 |
parents | d0d99b22e393 |
children | af586df84c9b |
files | ChangeLog src/lastfm/lastfm.c |
diffstat | 2 files changed, 127 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri May 11 01:15:39 2007 -0700 +++ b/ChangeLog Fri May 11 06:08:46 2007 -0700 @@ -1,3 +1,27 @@ +2007-05-11 08:15:39 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> + revision [2188] + import major update by Aleksander Djuric (the original author). + - major code cleanups + - fix for badly playlist names + - remove unnecessary functions + - remove no-longer-needed files + + trunk/src/tta/Makefile | 2 + trunk/src/tta/Readme | 35 - + trunk/src/tta/aud-support.h | 24 - + trunk/src/tta/aud-tta.c | 1019 -------------------------------------------- + trunk/src/tta/crc32.h | 114 ---- + trunk/src/tta/filters.h | 110 ---- + trunk/src/tta/id3.c | 80 --- + trunk/src/tta/id3genre.h | 155 ------ + trunk/src/tta/libtta.c | 861 +++++++++++++++++++++++++++++++++++++ + trunk/src/tta/ttadec.c | 230 ++++++--- + trunk/src/tta/ttadec.h | 128 ++++- + trunk/src/tta/ttaid3tag.h | 97 ---- + trunk/src/tta/ttalib.h | 74 ++- + 13 files changed, 1175 insertions(+), 1754 deletions(-) + + 2007-05-11 05:27:38 +0000 Yoshiki Yazawa <yaz@cc.rim.or.jp> revision [2186] - replace xmms_remote_*() with playlist functions.
--- a/src/lastfm/lastfm.c Fri May 11 01:15:39 2007 -0700 +++ b/src/lastfm/lastfm.c Fri May 11 06:08:46 2007 -0700 @@ -26,9 +26,9 @@ LastFM *LastFMGlobalData; - /*this keeps the login data in a global place since - * we cannot login on every fopen call* if anyone - * has a better solution to this any hint is welcome */ +/*this keeps the login data in a global place since + * we cannot login on every fopen call* if anyone + * has a better solution to this any hint is welcome */ static size_t lastfm_store_res(void *ptr, size_t size, size_t nmemb, void *udata) { @@ -142,8 +142,7 @@ return ret; } - -gpointer lastfm_get_metadata(LastFM * handle) +static void * lastfm_get_metadata(LastFM * handle) { gint status, i; @@ -154,7 +153,8 @@ return NULL; snprintf(tmp, sizeof(tmp), LASTFM_METADATA_URL, handle->lastfm_session_id); - for (;;) + gboolean opened_file=TRUE; + while (opened_file) { handle->lastfm_duration = 0; handle->lastfm_progress = 0; @@ -213,7 +213,6 @@ } g_string_erase(res, 0, -1); - int sleep_time; if (handle->lastfm_progress == 0) //if i don't know track duration i'm polling for metadata every 10 seconds sleep_time = 10; @@ -224,12 +223,21 @@ #endif sleep(sleep_time); + if(handle->proxy_fd==NULL) + opened_file=FALSE; } - return NULL; //we'll never get here + +#ifdef DEBUG + g_print("Exiting a thread\n"); +#endif + + + return NULL; } VFSFile *lastfm_vfs_fopen_impl(const gchar * path, const gchar * mode) { + static GThread * th; VFSFile *file; LastFM *handle; file = g_new0(VFSFile, 1); @@ -251,97 +259,108 @@ handle->lastfm_station_name = g_strdup(LastFMGlobalData->lastfm_station_name); if (lastfm_adjust(path)) - g_thread_create(lastfm_get_metadata, handle, FALSE, NULL); - + { + if((th= g_thread_create(lastfm_get_metadata, handle, FALSE, NULL))==NULL) + { #ifdef DEBUG - else - g_print("Cannot tune to given channel\n"); - g_print("The metadata thread has just been created\n"); + g_print("Error creating metadata thread!!!\n"); +#endif + return NULL; + } + else +#ifdef DEBUG + g_print("The metadata thread has just been created\n"); +#endif + } +#ifdef DEBUG + else + g_print("Cannot tune to given channel\n"); #endif - handle->proxy_fd = vfs_fopen(handle->lastfm_mp3_stream_url, mode); - file->handle = handle; - - return file; -} + handle->proxy_fd = vfs_fopen(handle->lastfm_mp3_stream_url, mode); + file->handle = handle; -gint lastfm_vfs_fclose_impl(VFSFile * file) -{ - gint ret = 0; - + return file; + } - if (file == NULL) - return -1; - - LastFM *handle = file->handle; - ret = vfs_fclose(handle->proxy_fd); + gint lastfm_vfs_fclose_impl(VFSFile * file) + { + gint ret = 0; - return ret; -} + if (file == NULL) + return -1; -size_t lastfm_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file) -{ + LastFM *handle = file->handle; + ret = vfs_fclose(handle->proxy_fd); + if(!ret) + handle->proxy_fd=NULL; - LastFM *handle = file->handle; - size_t ret = vfs_fread(ptr, size, nmemb, handle->proxy_fd); - return ret; -} + return ret; + } + + size_t lastfm_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file) + { -size_t lastfm_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file) -{ - return -1; -} + LastFM *handle = file->handle; + size_t ret = vfs_fread(ptr, size, nmemb, handle->proxy_fd); + return ret; + } + + size_t lastfm_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file) + { + return -1; + } -gint lastfm_vfs_getc_impl(VFSFile * stream) -{ - LastFM *handle = stream->handle; - return vfs_getc(handle->proxy_fd); -} + gint lastfm_vfs_getc_impl(VFSFile * stream) + { + LastFM *handle = stream->handle; + return vfs_getc(handle->proxy_fd); + } -gint lastfm_vfs_ungetc_impl(gint c, VFSFile * stream) -{ - LastFM *handle = stream->handle; + gint lastfm_vfs_ungetc_impl(gint c, VFSFile * stream) + { + LastFM *handle = stream->handle; - return vfs_ungetc(c, handle->proxy_fd); -} + return vfs_ungetc(c, handle->proxy_fd); + } -gint lastfm_vfs_fseek_impl(VFSFile * file, glong offset, gint whence) -{ - return -1; -} + gint lastfm_vfs_fseek_impl(VFSFile * file, glong offset, gint whence) + { + return -1; + } -void lastfm_vfs_rewind_impl(VFSFile * file) -{ - return; -} + void lastfm_vfs_rewind_impl(VFSFile * file) + { + return; + } -glong lastfm_vfs_ftell_impl(VFSFile * file) -{ - LastFM *handle = file->handle; + glong lastfm_vfs_ftell_impl(VFSFile * file) + { + LastFM *handle = file->handle; - return vfs_ftell(handle->proxy_fd); -} + return vfs_ftell(handle->proxy_fd); + } -gboolean lastfm_vfs_feof_impl(VFSFile * file) -{ - LastFM *handle = file->handle; + gboolean lastfm_vfs_feof_impl(VFSFile * file) + { + LastFM *handle = file->handle; - return vfs_feof(handle->proxy_fd); -} + return vfs_feof(handle->proxy_fd); + } -gint lastfm_vfs_truncate_impl(VFSFile * file, glong size) -{ - return -1; -} + gint lastfm_vfs_truncate_impl(VFSFile * file, glong size) + { + return -1; + } -off_t lastfm_vfs_fsize_impl(VFSFile * file) -{ - return -1; -} + off_t lastfm_vfs_fsize_impl(VFSFile * file) + { + return -1; + } -gchar *lastfm_vfs_metadata_impl(VFSFile * file, const gchar * field) -{ + gchar *lastfm_vfs_metadata_impl(VFSFile * file, const gchar * field) + { LastFM *handle = file->handle; #ifdef DEBUG @@ -356,13 +375,17 @@ if (handle->lastfm_title != NULL) g_print("%s\n", handle->lastfm_title); - g_print("%ul\n\n", handle->lastfm_duration); + g_print("%u\n\n", handle->lastfm_duration); #endif - if (!g_ascii_strncasecmp(field, "stream-name", 12) && (handle->lastfm_station_name != NULL)) + if (!g_ascii_strncasecmp(field, "stream-name", 11) && (handle->lastfm_station_name != NULL)) return g_strdup(handle->lastfm_station_name); - if (!g_ascii_strncasecmp(field, "track-name", 11) && (handle->lastfm_title != NULL) && (handle->lastfm_artist != NULL)) + if (!g_ascii_strncasecmp(field, "track-name", 10) && (handle->lastfm_title != NULL) && (handle->lastfm_artist != NULL)) return g_strdup_printf("%s - %s", handle->lastfm_artist, handle->lastfm_title); + if (!g_ascii_strncasecmp(field, "content-length",14)) + return g_strdup_printf("%d", handle->lastfm_duration); + + return NULL; }