From d94d8644cea8a985895291a77becefbe61d629d6 Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Sun, 14 Dec 2003 00:28:02 +0000 Subject: add _x_meta_info_set_multi function, will be used very soon. Don't parse va_arg two times in _x_message function. CVS patchset: 5907 CVS date: 2003/12/14 00:28:02 --- src/xine-engine/info_helper.c | 48 +++++++++++++++++++++++++++++++++++++++- src/xine-engine/info_helper.h | 12 ++++++++++ src/xine-engine/xine_interface.c | 45 ++++++++++++++++++++----------------- 3 files changed, 84 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c index fb2a087f6..bb9d1bc9e 100644 --- a/src/xine-engine/info_helper.c +++ b/src/xine-engine/info_helper.c @@ -20,7 +20,7 @@ * stream metainfo helper functions * hide some xine engine details from demuxers and reduce code duplication * - * $Id: info_helper.c,v 1.7 2003/12/13 11:35:08 valtri Exp $ + * $Id: info_helper.c,v 1.8 2003/12/14 00:28:02 f1rmb Exp $ */ #ifdef HAVE_CONFIG_H @@ -29,6 +29,7 @@ #include #include +#include #define XINE_ENGINE_INTERNAL @@ -233,6 +234,51 @@ void _x_meta_info_n_set(xine_stream_t *stream, int info, const char *buf, int le pthread_mutex_unlock(&stream->meta_mutex); } +/* + * Set private meta info value, from multiple arguments. + */ +void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) { + + pthread_mutex_lock(&stream->meta_mutex); + if(__meta_valid(info)) { + va_list ap; + char *args[1024]; + char *buf; + int n, len; + + len = n = 0; + + va_start(ap, info); + while((buf = va_arg(ap, char *)) && (n < 1024)) { + len += strlen(buf) + 1; + args[n] = buf; + n++; + } + va_end(ap); + + args[n] = NULL; + + if(len) { + char *p, *meta; + + p = meta = (char *) xine_xmalloc(len + 1); + + n = 0; + while(args[n]) { + strcpy(meta, args[n]); + meta += strlen(args[n]) + 1; + n++; + } + + *meta = '\0'; + + __meta_info_set_unlocked(stream, info, (const char *) p); + } + + } + pthread_mutex_unlock(&stream->meta_mutex); +} + /* * Retrieve private info value. */ diff --git a/src/xine-engine/info_helper.h b/src/xine-engine/info_helper.h index 6e7052390..44a994599 100644 --- a/src/xine-engine/info_helper.h +++ b/src/xine-engine/info_helper.h @@ -26,6 +26,7 @@ #ifndef INFO_HELPER_H #define INFO_HELPER_H +#include #include "xine_internal.h" /* @@ -90,6 +91,17 @@ uint32_t _x_stream_info_get_public(xine_stream_t *stream, int info); */ void _x_meta_info_set(xine_stream_t *stream, int info, const char *str); +/* + * set a stream meta multiple info + * + * params: + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * ... one or more meta info, followed by a NULL pointer + * + */ +void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...); + /* * set a stream meta info * diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 871639a7a..22d707082 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_interface.c,v 1.73 2003/12/09 00:02:38 f1rmb Exp $ + * $Id: xine_interface.c,v 1.74 2003/12/14 00:28:02 f1rmb Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -783,8 +783,8 @@ int _x_message(xine_stream_t *stream, int type, ...) { int n; va_list ap; char *s, *params; - - static char *std_explanation[] = { + char *args[1024]; + static char *std_explanation[] = { "", "Warning:", "Unknown host:", @@ -809,43 +809,48 @@ int _x_message(xine_stream_t *stream, int type, ...) { n = 0; va_start(ap, type); - while( (s = va_arg(ap, char *)) != NULL ) { + while(((s = va_arg(ap, char *)) != NULL) && (n < 1024)) { size += strlen(s) + 1; + args[n] = s; n++; } va_end(ap); + args[n] = NULL; + size += sizeof(xine_ui_message_data_t) + 1; data = xine_xmalloc( size ); - strcpy(data->compatibility.str, - "Upgrade your frontend to see the error messages"); - data->type = type; + + strcpy(data->compatibility.str, "Upgrade your frontend to see the error messages"); + data->type = type; data->num_parameters = n; if( explanation ) { - strcpy (data->messages, explanation); + strcpy(data->messages, explanation); data->explanation = data->messages - (char *)data; params = data->messages + strlen(explanation) + 1; } else { data->explanation = 0; - params = data->messages; + params = data->messages; } - data->parameters = params - (char *)data; - params[0] = '\0'; - va_start(ap, type); - while( (s = va_arg(ap, char *)) != NULL ) { - strcpy(params, s); - params += strlen(s) + 1; + data->parameters = params - (char *)data; + + n = 0; + *params = '\0'; + + while(args[n]) { + strcpy(params, args[n]); + params += strlen(args[n]) + 1; + n++; } - va_end(ap); - params[0] = '\0'; + *params = '\0'; - event.type = XINE_EVENT_UI_MESSAGE; - event.stream = stream; + event.type = XINE_EVENT_UI_MESSAGE; + event.stream = stream; event.data_length = size; - event.data = data; + event.data = data; xine_event_send(stream, &event); free(data); -- cgit v1.2.3