Mercurial > audlegacy-plugins
changeset 1744:46cda76dcd2a
Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Wed, 19 Sep 2007 09:06:52 -0500 |
parents | 3572d3444a7c (current diff) 4f4634573e41 (diff) |
children | 3d4a09dbaa17 |
files | |
diffstat | 6 files changed, 114 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cue/cuesheet.c Wed Sep 19 09:06:40 2007 -0500 +++ b/src/cue/cuesheet.c Wed Sep 19 09:06:52 2007 -0500 @@ -47,7 +47,6 @@ static void cue_pause(InputPlayback *data, short); static Tuple *get_tuple(gchar *uri); static Tuple *get_tuple_uri(gchar *uri); -static void get_song_info(gchar *uri, gchar **title, gint *length); static void cue_init(void); static void cue_cleanup(void); static gpointer watchdog_func(gpointer data); @@ -102,7 +101,6 @@ .seek = seek, .get_time = get_time, .cleanup = cue_cleanup, /* cleanup */ - .get_song_info = get_song_info, /* XXX get_song_info iface */ .get_song_tuple = get_tuple, }; @@ -298,28 +296,6 @@ return out; } -static void get_song_info(gchar *uri, gchar **title, gint *length) -{ - Tuple *tuple; - - /* this isn't a cue:// uri? */ - if (strncasecmp("cue://", uri, 6)) - { - gchar *tmp = g_strdup_printf("cue://%s?0", uri); - tuple = get_tuple_uri(tmp); - g_free(tmp); - } - else - tuple = get_tuple_uri(uri); - - g_return_if_fail(tuple != NULL); - - *title = tuple_formatter_make_title_string(tuple, get_gentitle_format()); - *length = tuple_get_int(tuple, FIELD_LENGTH, NULL); - - tuple_free(tuple); -} - static void seek(InputPlayback * data, gint time) { g_mutex_lock(cue_target_time_mutex); @@ -458,11 +434,10 @@ { gchar *path2 = g_strdup(uri + 6); // "cue://" is stripped. gchar *_path = strchr(path2, '?'); - gint file_length = 0; gint track = 0; - gchar *dummy = NULL; ProbeResult *pr; InputPlugin *real_ip_plugin; + Tuple *tuple = NULL; #ifdef DEBUG g_print("f: play_cue_uri\n"); @@ -532,10 +507,12 @@ #ifdef DEBUG g_print("cue: play_cue_uri: target_time = %d\n", target_time); #endif - /* in some plugins, NULL as 2nd arg causes crash. */ - real_ip->plugin->get_song_info(cue_file, &dummy, &file_length); - g_free(dummy); - cue_tracks[last_cue_track].index = file_length; + + tuple = real_ip->plugin->get_song_tuple(cue_file); + if(tuple) { + cue_tracks[last_cue_track].index = tuple_get_int(tuple, FIELD_LENGTH, NULL); + tuple_free(tuple); tuple = NULL; + } /* kick watchdog thread */ g_mutex_lock(cue_mutex);
--- a/src/madplug/Makefile Wed Sep 19 09:06:40 2007 -0500 +++ b/src/madplug/Makefile Wed Sep 19 09:06:52 2007 -0500 @@ -20,6 +20,6 @@ CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) $(SIMD_CFLAGS) -I../../intl -I../.. -Wall LDFLAGS += $(AUDLDFLAGS) -LIBADD = -L/opt/local/lib -L$(plugindir) -laudid3tag -lmad $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) +LIBADD = -L/opt/local/lib -L$(libdir) -laudid3tag -lmad $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) include ../../mk/objective.mk
--- a/src/madplug/plugin.c Wed Sep 19 09:06:40 2007 -0500 +++ b/src/madplug/plugin.c Wed Sep 19 09:06:52 2007 -0500 @@ -520,10 +520,10 @@ *title = g_strdup(tuple_get_string(myinfo.tuple, -1, "track-name")); else *title = g_strdup(url); - if(tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL) == -1) + + *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); + if(*length == -1) *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); - else - *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); } else { *title = g_strdup(url); @@ -553,10 +553,9 @@ } if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { - if(tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL) == -1) + *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); + if(*length == -1) *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); - else - *length = tuple_get_int(myinfo.tuple, FIELD_LENGTH, NULL); } else { *length = -1;
--- a/src/neon/neon.c Wed Sep 19 09:06:40 2007 -0500 +++ b/src/neon/neon.c Wed Sep 19 09:06:52 2007 -0500 @@ -5,6 +5,7 @@ #include <ne_utils.h> #include <ne_redirect.h> #include <ne_request.h> +#include <ne_auth.h> #include "debug.h" #include "neon.h" @@ -67,6 +68,7 @@ h->icy_metadata.stream_name = NULL; h->icy_metadata.stream_title = NULL; h->icy_metadata.stream_url = NULL; + h->icy_metadata.stream_contenttype = NULL; h->reader = NULL; h->reader_status.mutex = g_mutex_new(); h->reader_status.cond = g_cond_new(); @@ -87,6 +89,18 @@ ne_uri_free(h->purl); destroy_rb(&h->rb); + if (NULL != h->icy_metadata.stream_name) { + free(h->icy_metadata.stream_name); + } + if (NULL != h->icy_metadata.stream_title) { + free(h->icy_metadata.stream_title); + } + if (NULL != h->icy_metadata.stream_url) { + free(h->icy_metadata.stream_url); + } + if (NULL != h->icy_metadata.stream_contenttype) { + free(h->icy_metadata.stream_contenttype); + } free(h); _LEAVE; @@ -160,15 +174,13 @@ * ----- */ -#define TAGSIZE 4096 - static void parse_icy(struct icy_metadata* m, gchar* metadata, int len) { gchar* p; gchar* tstart; gchar* tend; - gchar name[TAGSIZE]; - gchar value[TAGSIZE]; + gchar name[4096]; + gchar value[4096]; int state; int pos; @@ -192,7 +204,7 @@ * End of tag name. */ *p = '\0'; - g_strlcpy(name, tstart, TAGSIZE); + strcpy(name, tstart); _DEBUG("Found tag name: %s", name); state = 2; } else { @@ -221,7 +233,7 @@ * End of value */ *p = '\0'; - g_strlcpy(value, tstart, TAGSIZE); + strcpy(value, tstart); _DEBUG("Found tag value: %s", value); add_icy(m, name, value); state = 4; @@ -275,6 +287,50 @@ * ----- */ +static int auth_callback(void* userdata, const char* realm, int attempt, char* username, char* password) { + + struct neon_handle* h = (struct neon_handle*)userdata; + gchar* authcpy; + gchar** authtok; + + _ENTER; + + if ((NULL == h->purl->userinfo) || ('\0' == *(h->purl->userinfo))) { + _ERROR("Authentication required, but no credentials set"); + _LEAVE 1; + } + + if (NULL == (authcpy = g_strdup(h->purl->userinfo))) { + /* + * No auth data + */ + _ERROR("Could not allocate memory for authentication data"); + _LEAVE 1; + } + + authtok = g_strsplit(authcpy, ":", 2); + if ((strlen(authtok[1]) > (NE_ABUFSIZ-1)) || (strlen(authtok[0]) > (NE_ABUFSIZ-1))) { + _ERROR("Username/Password too long"); + g_strfreev(authtok); + free(authcpy); + _LEAVE 1; + } + + strncpy(username, authtok[0], NE_ABUFSIZ); + strncpy(password, authtok[1], NE_ABUFSIZ); + + _DEBUG("Authenticating: Username: %s, Password: %s", username, password); + + g_strfreev(authtok); + free(authcpy); + + _LEAVE attempt; +} + +/* + * ----- + */ + static void handle_headers(struct neon_handle* h) { const gchar* name; @@ -296,6 +352,8 @@ _DEBUG("server can_ranges"); h->can_ranges = TRUE; } + + continue; } if (0 == g_ascii_strncasecmp("content-length", name, 14)) { @@ -312,6 +370,21 @@ } else { _ERROR("Invalid content length header: %s", value); } + + continue; + } + + if (0 == g_ascii_strncasecmp("content-type", name, 12)) { + /* + * The server sent us a content type. Save it for later + */ + _DEBUG("Content-Type: %s", value); + if (NULL != h->icy_metadata.stream_contenttype) { + free(h->icy_metadata.stream_contenttype); + } + h->icy_metadata.stream_contenttype = g_strdup(value); + + continue; } if (0 == g_ascii_strncasecmp("icy-metaint", name, 11)) { @@ -329,6 +402,8 @@ } else { _ERROR("Invalid ICY MetaInt header: %s", value); } + + continue; } if (0 == g_ascii_strncasecmp("icy-name", name, 8)) { @@ -341,6 +416,8 @@ } h->icy_metadata.stream_name = g_strdup(value); } + + continue; } _LEAVE; @@ -353,6 +430,7 @@ static int open_request(struct neon_handle* handle, unsigned long startbyte) { int ret; + const ne_status* status; _ENTER; @@ -365,6 +443,16 @@ */ _DEBUG("Connecting..."); ret = ne_begin_request(handle->request); + status = ne_get_status(handle->request); + if ((NE_OK == ret) && (401 == status->code)) { + /* + * Authorization required. Reconnect to + * authenticate + */ + _DEBUG("Reconnecting due to 401"); + ne_end_request(handle->request); + ret = ne_begin_request(handle->request); + } switch (ret) { case NE_OK: @@ -427,6 +515,7 @@ _DEBUG("Creating session"); handle->session = ne_session_create(handle->purl->scheme, handle->purl->host, handle->purl->port); + ne_add_server_auth(handle->session, NE_AUTH_BASIC, auth_callback, (void *)handle); ne_set_session_flag(handle->session, NE_SESSFLAG_ICYPROTO, 1); ne_set_session_flag(handle->session, NE_SESSFLAG_PERSIST, 0); ne_set_connect_timeout(handle->session, 10); @@ -1088,6 +1177,10 @@ _LEAVE g_strdup(h->icy_metadata.stream_name); } + if (0 == g_ascii_strncasecmp(field, "content-type", 12)) { + _LEAVE g_strdup(h->icy_metadata.stream_contenttype); + } + _LEAVE NULL; }
--- a/src/neon/neon.h Wed Sep 19 09:06:40 2007 -0500 +++ b/src/neon/neon.h Wed Sep 19 09:06:52 2007 -0500 @@ -47,6 +47,7 @@ gchar* stream_name; gchar* stream_title; gchar* stream_url; + gchar* stream_contenttype; }; struct neon_handle {
--- a/src/tta/Makefile Wed Sep 19 09:06:40 2007 -0500 +++ b/src/tta/Makefile Wed Sep 19 09:06:52 2007 -0500 @@ -12,6 +12,6 @@ CFLAGS += -fPIC -DPIC $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I../../intl -I../.. LDFLAGS += $(AUDLDFLAGS) -LIBADD = -L$(plugindir) -laudid3tag $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) +LIBADD = -L$(libdir) -laudid3tag $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) include ../../mk/objective.mk