summaryrefslogtreecommitdiff
path: root/src/xine-engine/xine.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine/xine.c')
-rw-r--r--src/xine-engine/xine.c92
1 files changed, 55 insertions, 37 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 17ea5d679..c6dc8a2ce 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -35,6 +35,7 @@
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
+#include <ctype.h>
#if defined (__linux__) || defined (__GLIBC__)
#include <endian.h>
#elif defined (__FreeBSD__)
@@ -51,33 +52,36 @@
#define LOG_VERBOSE
/*
#define LOG
+#define DEBUG
*/
#define XINE_ENABLE_EXPERIMENTAL_FEATURES
#define XINE_ENGINE_INTERNAL
#define METRONOM_CLOCK_INTERNAL
-#include "xine_internal.h"
-#include "plugin_catalog.h"
-#include "audio_out.h"
-#include "video_out.h"
-#include "demuxers/demux.h"
-#include "buffer.h"
-#include "spu_decoder.h"
-#include "input/input_plugin.h"
-#include "metronom.h"
-#include "configfile.h"
-#include "osd.h"
-#include "spu.h"
-
-#include "xineutils.h"
-#include "compat.h"
+#include <xine/xine_internal.h>
+#include <xine/plugin_catalog.h>
+#include <xine/audio_out.h>
+#include <xine/video_out.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
+#include <xine/spu_decoder.h>
+#include <xine/input_plugin.h>
+#include <xine/metronom.h>
+#include <xine/configfile.h>
+#include <xine/osd.h>
+#include <xine/spu.h>
+
+#include <xine/xineutils.h>
+#include <xine/compat.h>
#ifdef WIN32
# include <fcntl.h>
# include <winsock.h>
#endif /* WIN32 */
+#include "load_plugins.h"
+
static void mutex_cleanup (void *mutex) {
pthread_mutex_unlock ((pthread_mutex_t *) mutex);
@@ -590,7 +594,7 @@ static int stream_rewire_video(xine_post_out_t *output, void *data)
return 1;
}
-void xine_dispose_internal (xine_stream_t *stream);
+static void xine_dispose_internal (xine_stream_t *stream);
xine_stream_t *xine_stream_new (xine_t *this,
xine_audio_port_t *ao, xine_video_port_t *vo) {
@@ -819,9 +823,22 @@ void _x_flush_events_queues (xine_stream_t *stream) {
pthread_mutex_unlock (&stream->event_queues_lock);
}
+static inline int _x_path_looks_like_mrl (const char *path)
+{
+ if ((*path & 0xDF) < 'A' || (*path & 0xDF) > 'Z')
+ return 0;
+
+ for (++path; *path; ++path)
+ if ((*path != '-' && *path < '0') || (*path > '9' && *path < 'A') ||
+ (*path > 'Z' && *path < 'a') || *path > 'z')
+ break;
+
+ return path[0] == ':' && path[1] == '/';
+}
+
static int open_internal (xine_stream_t *stream, const char *mrl) {
- const char *stream_setup;
+ const char *stream_setup = NULL;
int no_cache = 0;
if (!mrl) {
@@ -846,13 +863,19 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
* look for a stream_setup in MRL and try finding an input plugin
*/
- stream_setup = mrl;
- /* look for the next '#' or try the whole MRL, if none is found */
- while (*stream_setup &&
- (stream_setup = (strchr(stream_setup, '#') ? strchr(stream_setup, '#') : strlen(mrl) + mrl))) {
- char *input_source = (char *)malloc(stream_setup - mrl + 1);
- memcpy(input_source, mrl, stream_setup - mrl);
- input_source[stream_setup - mrl] = '\0';
+ if (isalpha (*mrl))
+ {
+ stream_setup = mrl + 1;
+ while (isalnum (*stream_setup) || *stream_setup == '+' || *stream_setup == '-' || *stream_setup == '.')
+ ++stream_setup;
+ if (stream_setup[0] == ':' && stream_setup[1] == '/')
+ stream_setup = strchr (mrl, '#');
+ else
+ stream_setup = NULL;
+ }
+
+ {
+ char *input_source = strndup (mrl, stream_setup ? stream_setup - mrl : strlen (mrl));
/*
* find an input plugin
@@ -872,7 +895,6 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
res = (stream->input_plugin->open) (stream->input_plugin);
switch(res) {
case 1: /* Open successfull */
- free(input_source);
break;
case -1: /* Open unsuccessfull, but correct plugin */
free(input_source);
@@ -885,14 +907,9 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
stream->input_plugin = NULL;
stream->err = XINE_ERROR_INPUT_FAILED;
}
- if ( res ) break;
}
free(input_source);
- /* if we fail when passing up to the first '#' to the input plugins,
- * maybe the user stated a (invalid) MRL, with a '#' belonging to the
- * input source -> look for the next '#' and try again */
- if (*stream_setup) stream_setup++;
}
if (!stream->input_plugin) {
@@ -902,7 +919,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
return 0;
}
- if (*stream_setup) {
+ if (stream_setup) {
while (stream_setup && *stream_setup && *(++stream_setup)) {
if (strncasecmp(stream_setup, "demux", 5) == 0) {
@@ -957,6 +974,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(filename, tmp, strlen(tmp));
filename[strlen(tmp)] = '\0';
}
+ _x_mrl_unescape(filename);
xine_log(stream->xine, XINE_LOG_MSG, _("xine: join rip input plugin\n"));
input_saver = _x_rip_plugin_get_instance (stream, filename);
@@ -1131,7 +1149,9 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(subtitle_mrl, tmp, strlen(tmp));
subtitle_mrl[strlen(tmp)] = '\0';
}
- _x_mrl_unescape(subtitle_mrl);
+ /* unescape for xine_open() if the MRL looks like a raw pathname */
+ if (!_x_path_looks_like_mrl(subtitle_mrl))
+ _x_mrl_unescape(subtitle_mrl);
stream->slave = xine_stream_new (stream->xine, NULL, stream->video_out );
stream->slave_affection = XINE_MASTER_SLAVE_PLAY | XINE_MASTER_SLAVE_STOP;
if( xine_open( stream->slave, subtitle_mrl ) ) {
@@ -1444,7 +1464,7 @@ int xine_eject (xine_stream_t *stream) {
return status;
}
-void xine_dispose_internal (xine_stream_t *stream) {
+static void xine_dispose_internal (xine_stream_t *stream) {
xine_list_iterator_t *ite;
@@ -1640,9 +1660,8 @@ static void config_demux_strategy_cb (void *this_gen, xine_cfg_entry_t *entry) {
static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
xine_t *this = (xine_t *)this_gen;
- char *homedir_trail_slash;
+ char homedir_trail_slash[strlen(xine_get_homedir()) + 2];
- homedir_trail_slash = (char *)malloc(strlen(xine_get_homedir()) + 2);
sprintf(homedir_trail_slash, "%s/", xine_get_homedir());
if (entry->str_value[0] &&
(entry->str_value[0] != '/' || strstr(entry->str_value, "/.") ||
@@ -1662,7 +1681,6 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
pthread_mutex_unlock(&this->streams_lock);
}
- free(homedir_trail_slash);
this->save_path = entry->str_value;
}
@@ -1682,7 +1700,7 @@ void xine_init (xine_t *this) {
/*
* plugins
*/
- _x_scan_plugins(this);
+ XINE_PROFILE(_x_scan_plugins(this));
#ifdef HAVE_SETLOCALE
if (!setlocale(LC_CTYPE, ""))