diff options
Diffstat (limited to 'src/xine-engine')
-rw-r--r-- | src/xine-engine/Makefile.am | 6 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 2 | ||||
-rw-r--r-- | src/xine-engine/buffer.c | 19 | ||||
-rw-r--r-- | src/xine-engine/configfile.c | 21 | ||||
-rw-r--r-- | src/xine-engine/demux.c | 5 | ||||
-rw-r--r-- | src/xine-engine/load_plugins.c | 56 | ||||
-rw-r--r-- | src/xine-engine/metronom.c | 2 | ||||
-rw-r--r-- | src/xine-engine/osd.c | 13 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 2 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 34 |
10 files changed, 112 insertions, 48 deletions
diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am index 5792b667d..e32f2d2f4 100644 --- a/src/xine-engine/Makefile.am +++ b/src/xine-engine/Makefile.am @@ -1,7 +1,8 @@ include $(top_srcdir)/misc/Makefile.common include $(top_srcdir)/lib/Makefile.common -AM_CFLAGS = $(DEFAULT_OCFLAGS) $(X_CFLAGS) $(FT2_CFLAGS) $(FONTCONFIG_CFLAGS) $(VISIBILITY_FLAG) +AM_CFLAGS = $(DEFAULT_OCFLAGS) $(X_CFLAGS) $(FT2_CFLAGS) $(FONTCONFIG_CFLAGS) \ + $(AVUTIL_CFLAGS) $(VISIBILITY_FLAG) AM_CPPFLAGS = $(XDG_BASEDIR_CPPFLAGS) $(ZLIB_CPPFLAGS) -DXINE_LIBRARY_COMPILE XINEUTILS_LIB = $(top_builddir)/src/xine-utils/libxineutils.la @@ -31,7 +32,8 @@ libxine_la_DEPENDENCIES = $(XINEUTILS_LIB) $(XDG_BASEDIR_DEPS) \ $(pthread_dep) $(LIBXINEPOSIX) libxine_la_LIBADD = $(PTHREAD_LIBS) $(DYNAMIC_LD_LIBS) $(LTLIBINTL) $(ZLIB_LIBS) \ -lm $(XINEUTILS_LIB) $(LTLIBICONV) $(FT2_LIBS) $(FONTCONFIG_LIBS) \ - $(LIBXINEPOSIX) $(RT_LIBS) $(NET_LIBS) $(XDG_BASEDIR_LIBS) + $(LIBXINEPOSIX) $(RT_LIBS) $(NET_LIBS) $(XDG_BASEDIR_LIBS) \ + $(AVUTIL_LIBS) libxine_la_LDFLAGS = $(AM_LDFLAGS) $(def_ldflags) $(GCSECTIONS) \ -version-info $(XINE_LT_CURRENT):$(XINE_LT_REVISION):$(XINE_LT_AGE) diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 8671c60ce..f16f482aa 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -294,7 +294,7 @@ struct audio_fifo_s { static int ao_get_property (xine_audio_port_t *this_gen, int property); static int ao_set_property (xine_audio_port_t *this_gen, int property, int value); -static audio_fifo_t *fifo_new (xine_t *xine) { +static audio_fifo_t *XINE_MALLOC fifo_new (xine_t *xine) { audio_fifo_t *fifo; diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c index defa572db..bf2ea41e9 100644 --- a/src/xine-engine/buffer.c +++ b/src/xine-engine/buffer.c @@ -36,6 +36,12 @@ #include <stdlib.h> #include <assert.h> +#ifdef HAVE_FFMPEG_AVUTIL_H +# include <mem.h> +#else +# include <libavutil/mem.h> +#endif + /********** logging **********/ #define LOG_MODULE "buffer" #define LOG_VERBOSE @@ -358,7 +364,7 @@ static void fifo_buffer_dispose (fifo_buffer_t *this) { received++; } - free (this->buffer_pool_base); + av_free (this->buffer_pool_base); pthread_mutex_destroy(&this->mutex); pthread_cond_destroy(&this->not_empty); pthread_mutex_destroy(&this->buffer_pool_mutex); @@ -497,7 +503,6 @@ fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) { fifo_buffer_t *this; int i; - int alignment = 2048; unsigned char *multi_buffer = NULL; this = calloc(1, sizeof(fifo_buffer_t)); @@ -527,15 +532,11 @@ fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) { */ - if (buf_size % alignment != 0) - buf_size += alignment - (buf_size % alignment); - /* - printf ("Allocating %d buffers of %ld bytes in one chunk (alignment = %d)\n", - num_buffers, (long int) buf_size, alignment); + printf ("Allocating %d buffers of %ld bytes in one chunk\n", + num_buffers, (long int) buf_size); */ - multi_buffer = xine_xmalloc_aligned (alignment, num_buffers * buf_size, - &this->buffer_pool_base); + multi_buffer = this->buffer_pool_base = av_mallocz (num_buffers * buf_size); this->buffer_pool_top = NULL; diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 0de7c7e8e..f18cf6661 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -33,7 +33,11 @@ #include <unistd.h> #include <xine/configfile.h> #include "bswap.h" -#include "base64.h" +#ifdef HAVE_FFMPEG_AVUTIL_H +# include <base64.h> +#else +# include <libavutil/base64.h> +#endif #define LOG_MODULE "configfile" #define LOG_VERBOSE @@ -319,7 +323,7 @@ static void config_insert(config_values_t *this, cfg_entry_t *new_entry) { this->first = new_entry; } -static cfg_entry_t *config_add (config_values_t *this, const char *key, int exp_level) { +static cfg_entry_t *XINE_MALLOC config_add (config_values_t *this, const char *key, int exp_level) { cfg_entry_t *entry; @@ -1341,7 +1345,12 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key } /* and now the output encoding */ - output = _x_base64_encode (buffer, total_len, &output_len); + /* We're going to encode total_len bytes in base64 + * libavutil's base64 encoding functions want the size to + * be at least len * 4 / 3 + 12, so let's use that! + */ + output = malloc(total_len * 4 / 3 + 12); + av_base64_encode(output, total_len * 4 / 3 + 12, buffer, total_len); free(buffer); } @@ -1409,11 +1418,13 @@ static char* config_register_serialized_entry (config_values_t *this, const char int bytes; int pos; void *output = NULL; - unsigned long output_len; + size_t output_len; int value_count = 0; int i; - output = _x_base64_decode (value, strlen(value), &output_len); + output_len = strlen(value) * 3 / 4 + 1; + output = malloc(output_len); + av_base64_decode(output, value, output_len); pos = 0; pos += bytes = get_int(output, output_len, pos, &type); diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index e581126fa..5e1bb0ff0 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -47,11 +47,6 @@ #include <winsock.h> #endif -#ifdef MIN -#undef MIN -#endif -#define MIN(a,b) ( (a) < (b) ) ? (a) : (b) - /* * Flush audio and video buffers. It is called from demuxers on * seek/stop, and may be useful when user input changes a stream and diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index c30fac308..2ff9f494f 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -99,7 +99,7 @@ static void remove_segv_handler(void){ #endif #endif /* 0 */ -#define CACHE_CATALOG_VERSION 3 +#define CACHE_CATALOG_VERSION 4 static const int plugin_iface_versions[] = { INPUT_PLUGIN_IFACE_VERSION, @@ -468,7 +468,7 @@ static int _plugin_node_comparator(void *a, void *b) { } } -static plugin_catalog_t *_new_catalog(void){ +static plugin_catalog_t *XINE_MALLOC _new_catalog(void){ plugin_catalog_t *catalog; int i; @@ -1346,6 +1346,26 @@ void _x_free_input_plugin (xine_stream_t *stream, input_plugin_t *input) { } } +static int probe_mime_type (xine_t *self, plugin_node_t *node, const char *mime_type) +{ + /* catalog->lock is expected to be locked */ + if (node->plugin_class || _load_plugin_class(self, node, NULL)) + { + const unsigned int mime_type_len = strlen (mime_type); + demux_class_t *cls = (demux_class_t *)node->plugin_class; + const char *mime = cls->mimetypes; + while (mime) + { + while (*mime == ';' || isspace (*mime)) + ++mime; + if (!strncasecmp (mime, mime_type, mime_type_len) && + (!mime[mime_type_len] || mime[mime_type_len] == ':' || mime[mime_type_len] == ';')) + return 1; + mime = strchr (mime, ';'); + } + } + return 0; +} static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int method2, input_plugin_t *input) { @@ -1368,8 +1388,6 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth while (methods[i] != -1 && !plugin) { int list_id, list_size; - stream->content_detection_method = methods[i]; - pthread_mutex_lock (&catalog->lock); list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]); @@ -1381,6 +1399,25 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: probing demux '%s'\n", node->info->id); if (node->plugin_class || _load_plugin_class(stream->xine, node, NULL)) { + const char *mime_type; + + /* If detecting by MRL, try the MIME type first (but not text/plain)... */ + stream->content_detection_method = METHOD_EXPLICIT; + if (methods[i] == METHOD_BY_MRL && + stream->input_plugin->get_optional_data && + stream->input_plugin->get_optional_data (stream->input_plugin, NULL, INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED && + stream->input_plugin->get_optional_data (stream->input_plugin, &mime_type, INPUT_OPTIONAL_DATA_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED && + mime_type && strcasecmp (mime_type, "text/plain") && + probe_mime_type (stream->xine, node, mime_type) && + (plugin = ((demux_class_t *)node->plugin_class)->open_plugin (node->plugin_class, stream, input))) + { + inc_node_ref(node); + plugin->node = node; + break; + } + + /* ... then try the extension */ + stream->content_detection_method = methods[i]; if ( stream->content_detection_method == METHOD_BY_MRL && ! _x_demux_check_extension(input->get_mrl(input), ((demux_class_t *)node->plugin_class)->extensions) @@ -2670,15 +2707,12 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); for (list_id = 0; (list_id < list_size) && !id; list_id++) { - demux_class_t *cls; node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id); - if (node->plugin_class || _load_plugin_class(self, node, NULL)) { - - cls = (demux_class_t *)node->plugin_class; - - if (cls->mimetypes && strcasestr(cls->mimetypes, mime_type) ) - id = strdup(node->info->id); + if (probe_mime_type (self, node, mime_type)) + { + free (id); + id = strdup(node->info->id); } } diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index 158e2cbc8..b120181b4 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.c @@ -172,7 +172,7 @@ static void unixscr_exit (scr_plugin_t *scr) { free(this); } -static scr_plugin_t* unixscr_init () { +static scr_plugin_t *XINE_MALLOC unixscr_init () { unixscr_t *this; this = calloc(1, sizeof(unixscr_t)); diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 480a3f380..f0fe25e29 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -83,17 +83,6 @@ # define UCS2_ENCODING "UCS-2LE" #endif -#ifdef MAX -#undef MAX -#endif -#define MAX(a,b) ( (a) > (b) ) ? (a) : (b) - -#ifdef MIN -#undef MIN -#endif -#define MIN(a,b) ( (a) < (b) ) ? (a) : (b) - - #if (FREETYPE_MAJOR > 2) || \ (FREETYPE_MAJOR == 2 && FREETYPE_MINOR > 1) || \ (FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 3) @@ -237,7 +226,7 @@ struct osd_ft2context_s { * for the sake of simplicity) */ -static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height) { +static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width, int height) { osd_object_t *osd; diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 29c435e79..6a2d751bd 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -142,7 +142,7 @@ typedef struct { * frame queue (fifo) util functions */ -static img_buf_fifo_t *vo_new_img_buf_queue () { +static img_buf_fifo_t *XINE_MALLOC vo_new_img_buf_queue () { img_buf_fifo_t *queue; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 56b5d0605..1e7c5c2c7 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -338,7 +338,7 @@ static void ticket_dispose(xine_ticket_t *this) { free(this); } -static xine_ticket_t *ticket_init(void) { +static xine_ticket_t *XINE_MALLOC ticket_init(void) { xine_ticket_t *port_ticket; port_ticket = calloc(1, sizeof(xine_ticket_t)); @@ -1228,6 +1228,27 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { /* enable buffered input plugin (request optimizer) */ stream->input_plugin = _x_cache_plugin_get_instance(stream); + /* Let the plugin request a specific demuxer (if the user hasn't). + * This overrides find-by-content & find-by-extension. + */ + if (!stream->demux_plugin) + { + char *default_demux = NULL; + stream->input_plugin->get_optional_data (stream->input_plugin, &default_demux, INPUT_OPTIONAL_DATA_DEMUXER); + if (default_demux) + { + stream->demux_plugin = _x_find_demux_plugin_by_name (stream, default_demux, stream->input_plugin); + if (stream->demux_plugin) + { + lprintf ("demux and input plugin found\n"); + _x_meta_info_set_utf8 (stream, XINE_META_INFO_SYSTEMLAYER, + stream->demux_plugin->demux_class->identifier); + } + else + xine_log (stream->xine, XINE_LOG_MSG, _("xine: couldn't load plugin-specified demux %s for >%s<\n"), default_demux, mrl); + } + } + if (!stream->demux_plugin) { /* @@ -2278,6 +2299,9 @@ void xine_log (xine_t *this, int buf, const char *format, ...) { printf("%s", buffer); va_end (argp); } + + if (this->log_cb) + this->log_cb (this->log_cb_user_data, buf); } void xine_vlog(xine_t *this, int buf, const char *format, @@ -2286,6 +2310,9 @@ void xine_vlog(xine_t *this, int buf, const char *format, check_log_alloc (this, buf); this->log_buffers[buf]->scratch_printf(this->log_buffers[buf], format, args); + + if (this->log_cb) + this->log_cb (this->log_cb_user_data, buf); } char *const *xine_get_log (xine_t *this, int buf) { @@ -2299,6 +2326,11 @@ char *const *xine_get_log (xine_t *this, int buf) { return NULL; } +void xine_register_log_cb (xine_t *this, xine_log_cb_t cb, void *user_data) { + this->log_cb = cb; + this->log_cb_user_data = user_data; +} + int xine_get_error (xine_stream_t *stream) { return stream->err; } |