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.c403
1 files changed, 333 insertions, 70 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 32c2d7672..c6dc8a2ce 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -15,9 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* 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.c,v 1.342 2007/02/20 00:37:02 dgp85 Exp $
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
/*
@@ -37,7 +35,8 @@
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
-#if defined (__linux__)
+#include <ctype.h>
+#if defined (__linux__) || defined (__GLIBC__)
#include <endian.h>
#elif defined (__FreeBSD__)
#include <machine/endian.h>
@@ -47,6 +46,8 @@
#include <locale.h>
#endif
+#include <basedir.h>
+
#define LOG_MODULE "xine"
#define LOG_VERBOSE
/*
@@ -58,26 +59,29 @@
#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 "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);
@@ -128,25 +132,97 @@ void _x_extra_info_merge( extra_info_t *dst, extra_info_t *src ) {
}
}
-static void ticket_acquire(xine_ticket_t *this, int irrevocable) {
+static int acquire_allowed_to_block(xine_ticket_t *this) {
+ pthread_t own_id = pthread_self();
+ unsigned entry;
+ unsigned new_size;
+
+ for(entry = 0; entry < this->holder_thread_count; ++entry) {
+ if(this->holder_threads[entry].holder == own_id) {
+ /* This thread may already hold this ticket */
+ this->holder_threads[entry].count++;
+ return (this->holder_threads[entry].count == 1);
+ }
+ }
+ /* If we get this far, this thread hasn't claimed this ticket before.
+ We need to give it a new entry in the list, then return true */
+ for(entry = 0; entry < this->holder_thread_count; ++entry) {
+ if(this->holder_threads[entry].count == 0) {
+ this->holder_threads[entry].holder = own_id;
+ this->holder_threads[entry].count = 1;
+ return 1;
+ }
+ }
+ /* List too small. Realloc to larger size */
+ new_size = this->holder_thread_count * 2;
+ lprintf("Reallocing from %d to %d entries\n", this->holder_thread_count, new_size);
+
+ this->holder_threads = realloc(this->holder_threads, sizeof(*this->holder_threads) * new_size);
+ memset(this->holder_threads + this->holder_thread_count, 0, this->holder_thread_count);
+
+ /* Old size is equivalent to index of first newly allocated entry*/
+ this->holder_threads[this->holder_thread_count].count = 1;
+ this->holder_threads[this->holder_thread_count].holder = own_id;
+ this->holder_thread_count = new_size;
+
+ return 1;
+}
+
+static int ticket_acquire_internal(xine_ticket_t *this, int irrevocable, int nonblocking) {
+ int must_wait = 0;
pthread_mutex_lock(&this->lock);
+ int allowed_to_block = acquire_allowed_to_block(this);
if (this->ticket_revoked && !this->irrevocable_tickets)
- pthread_cond_wait(&this->issued, &this->lock);
+ must_wait = !nonblocking;
else if (this->atomic_revoke && !pthread_equal(this->atomic_revoker_thread, pthread_self()))
+ must_wait = 1;
+
+ if (must_wait && allowed_to_block) {
+ if (nonblocking) {
+ pthread_mutex_unlock(&this->lock);
+ return 0;
+ }
+
pthread_cond_wait(&this->issued, &this->lock);
+ }
this->tickets_granted++;
if (irrevocable)
this->irrevocable_tickets++;
pthread_mutex_unlock(&this->lock);
+ return 1;
}
-static void ticket_release(xine_ticket_t *this, int irrevocable) {
+static int ticket_acquire_nonblocking(xine_ticket_t *this, int irrevocable) {
+ return ticket_acquire_internal(this, irrevocable, 1);
+}
+
+static void ticket_acquire(xine_ticket_t *this, int irrevocable) {
+ ticket_acquire_internal(this, irrevocable, 0);
+}
+
+static int release_allowed_to_block(xine_ticket_t *this) {
+ pthread_t own_id = pthread_self();
+ unsigned entry;
+
+ for(entry = 0; entry < this->holder_thread_count; ++entry) {
+ if(this->holder_threads[entry].holder == own_id) {
+ this->holder_threads[entry].count--;
+ return this->holder_threads[entry].count == 0;
+ }
+ }
+ lprintf("BUG! Ticket 0x%p released by a thread that never took it! Allowing code to continue\n", this);
+ _x_assert(0);
+ return 1;
+}
+
+static void ticket_release_internal(xine_ticket_t *this, int irrevocable, int nonblocking) {
pthread_mutex_lock(&this->lock);
+ int allowed_to_block = release_allowed_to_block(this);
this->tickets_granted--;
if (irrevocable)
@@ -154,12 +230,22 @@ static void ticket_release(xine_ticket_t *this, int irrevocable) {
if (this->ticket_revoked && !this->tickets_granted)
pthread_cond_broadcast(&this->revoked);
- if (this->ticket_revoked && !this->irrevocable_tickets)
- pthread_cond_wait(&this->issued, &this->lock);
+ if (allowed_to_block) {
+ if (this->ticket_revoked && !this->irrevocable_tickets && !nonblocking)
+ pthread_cond_wait(&this->issued, &this->lock);
+ }
pthread_mutex_unlock(&this->lock);
}
+static void ticket_release_nonblocking(xine_ticket_t *this, int irrevocable) {
+ ticket_release_internal(this, irrevocable, 1);
+}
+
+static void ticket_release(xine_ticket_t *this, int irrevocable) {
+ ticket_release_internal(this, irrevocable, 0);
+}
+
static void ticket_renew(xine_ticket_t *this, int irrevocable) {
pthread_mutex_lock(&this->lock);
@@ -213,8 +299,37 @@ static void ticket_revoke(xine_ticket_t *this, int atomic) {
pthread_mutex_unlock(&this->revoke_lock);
}
+static int ticket_lock_port_rewiring(xine_ticket_t *this, int ms_timeout) {
+
+ if (ms_timeout >= 0) {
+ struct timespec abstime;
+
+ struct timeval now;
+ gettimeofday(&now, 0);
+
+ abstime.tv_sec = now.tv_sec + ms_timeout / 1000;
+ abstime.tv_nsec = now.tv_usec * 1000 + (ms_timeout % 1000) * 1e6;
+
+ if (abstime.tv_nsec > 1e9) {
+ abstime.tv_nsec -= 1e9;
+ abstime.tv_sec++;
+ }
+
+ return (0 == pthread_mutex_timedlock(&this->port_rewiring_lock, &abstime));
+ }
+
+ pthread_mutex_lock(&this->port_rewiring_lock);
+ return 1;
+}
+
+static void ticket_unlock_port_rewiring(xine_ticket_t *this) {
+
+ pthread_mutex_unlock(&this->port_rewiring_lock);
+}
+
static void ticket_dispose(xine_ticket_t *this) {
+ pthread_mutex_destroy(&this->port_rewiring_lock);
pthread_mutex_destroy(&this->lock);
pthread_mutex_destroy(&this->revoke_lock);
pthread_cond_destroy(&this->issued);
@@ -228,15 +343,22 @@ static xine_ticket_t *ticket_init(void) {
port_ticket = (xine_ticket_t *) xine_xmalloc(sizeof(xine_ticket_t));
- port_ticket->acquire = ticket_acquire;
- port_ticket->release = ticket_release;
- port_ticket->renew = ticket_renew;
- port_ticket->issue = ticket_issue;
- port_ticket->revoke = ticket_revoke;
- port_ticket->dispose = ticket_dispose;
+ port_ticket->acquire_nonblocking = ticket_acquire_nonblocking;
+ port_ticket->acquire = ticket_acquire;
+ port_ticket->release_nonblocking = ticket_release_nonblocking;
+ port_ticket->release = ticket_release;
+ port_ticket->renew = ticket_renew;
+ port_ticket->issue = ticket_issue;
+ port_ticket->revoke = ticket_revoke;
+ port_ticket->lock_port_rewiring = ticket_lock_port_rewiring;
+ port_ticket->unlock_port_rewiring = ticket_unlock_port_rewiring;
+ port_ticket->dispose = ticket_dispose;
+ port_ticket->holder_thread_count = XINE_MAX_TICKET_HOLDER_THREADS;
+ port_ticket->holder_threads = calloc(XINE_MAX_TICKET_HOLDER_THREADS,sizeof(*port_ticket->holder_threads));
pthread_mutex_init(&port_ticket->lock, NULL);
pthread_mutex_init(&port_ticket->revoke_lock, NULL);
+ pthread_mutex_init(&port_ticket->port_rewiring_lock, NULL);
pthread_cond_init(&port_ticket->issued, NULL);
pthread_cond_init(&port_ticket->revoked, NULL);
@@ -430,16 +552,18 @@ static int stream_rewire_audio(xine_post_out_t *output, void *data)
if (!data)
return 0;
+ stream->xine->port_ticket->lock_port_rewiring(stream->xine->port_ticket, -1);
stream->xine->port_ticket->revoke(stream->xine->port_ticket, 1);
if (stream->audio_out->status(stream->audio_out, stream, &bits, &rate, &mode)) {
/* register our stream at the new output port */
- new_port->open(new_port, stream, bits, rate, mode);
+ (new_port->open) (new_port, stream, bits, rate, mode);
stream->audio_out->close(stream->audio_out, stream);
}
stream->audio_out = new_port;
stream->xine->port_ticket->issue(stream->xine->port_ticket, 1);
+ stream->xine->port_ticket->unlock_port_rewiring(stream->xine->port_ticket);
return 1;
}
@@ -454,21 +578,23 @@ static int stream_rewire_video(xine_post_out_t *output, void *data)
if (!data)
return 0;
+ stream->xine->port_ticket->lock_port_rewiring(stream->xine->port_ticket, -1);
stream->xine->port_ticket->revoke(stream->xine->port_ticket, 1);
if (stream->video_out->status(stream->video_out, stream, &width, &height, &img_duration)) {
/* register our stream at the new output port */
- new_port->open(new_port, stream);
+ (new_port->open) (new_port, stream);
stream->video_out->close(stream->video_out, stream);
}
stream->video_out = new_port;
stream->xine->port_ticket->issue(stream->xine->port_ticket, 1);
+ stream->xine->port_ticket->unlock_port_rewiring(stream->xine->port_ticket);
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) {
@@ -607,9 +733,10 @@ xine_stream_t *xine_stream_new (xine_t *this,
/*
* osd
*/
- if (vo)
+ if (vo) {
+ _x_spu_misc_init (this);
stream->osd_renderer = _x_osd_renderer_init(stream);
- else
+ } else
stream->osd_renderer = NULL;
/*
@@ -648,7 +775,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
return stream;
}
-static void mrl_unescape(char *mrl) {
+void _x_mrl_unescape(char *mrl) {
int i, len = strlen(mrl);
for (i = 0; i < len; i++) {
@@ -696,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) {
@@ -723,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
@@ -739,16 +885,16 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
int res;
xine_log (stream->xine, XINE_LOG_MSG, _("xine: found input plugin : %s\n"),
- stream->input_plugin->input_class->get_description(stream->input_plugin->input_class));
+ dgettext(stream->input_plugin->input_class->textdomain ? : XINE_TEXTDOMAIN,
+ stream->input_plugin->input_class->description));
if (stream->input_plugin->input_class->eject_media)
stream->eject_class = stream->input_plugin->input_class;
_x_meta_info_set_utf8(stream, XINE_META_INFO_INPUT_PLUGIN,
- (stream->input_plugin->input_class->get_identifier (stream->input_plugin->input_class)));
+ stream->input_plugin->input_class->identifier);
- res = stream->input_plugin->open(stream->input_plugin);
+ 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);
@@ -761,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) {
@@ -778,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) {
@@ -796,7 +937,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(demux_name, tmp, strlen(tmp));
demux_name[strlen(tmp)] = '\0';
}
- mrl_unescape(demux_name);
+ _x_mrl_unescape(demux_name);
if (!(stream->demux_plugin = _x_find_demux_plugin_by_name(stream, demux_name, stream->input_plugin))) {
xine_log(stream->xine, XINE_LOG_MSG, _("xine: specified demuxer %s failed to start\n"), demux_name);
stream->err = XINE_ERROR_NO_DEMUX_PLUGIN;
@@ -806,7 +947,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
}
_x_meta_info_set_utf8(stream, XINE_META_INFO_SYSTEMLAYER,
- (stream->demux_plugin->demux_class->get_identifier(stream->demux_plugin->demux_class)));
+ stream->demux_plugin->demux_class->identifier);
free(demux_name);
} else {
xprintf(stream->xine, XINE_VERBOSITY_LOG, _("xine: error while parsing mrl\n"));
@@ -833,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);
@@ -870,7 +1012,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(demux_name, tmp, strlen(tmp));
demux_name[strlen(tmp)] = '\0';
}
- mrl_unescape(demux_name);
+ _x_mrl_unescape(demux_name);
if (!(stream->demux_plugin = _x_find_demux_plugin_last_probe(stream, demux_name, stream->input_plugin))) {
xine_log(stream->xine, XINE_LOG_MSG, _("xine: last_probed demuxer %s failed to start\n"), demux_name);
stream->err = XINE_ERROR_NO_DEMUX_PLUGIN;
@@ -881,7 +1023,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
lprintf ("demux and input plugin found\n");
_x_meta_info_set_utf8(stream, XINE_META_INFO_SYSTEMLAYER,
- (stream->demux_plugin->demux_class->get_identifier(stream->demux_plugin->demux_class)));
+ stream->demux_plugin->demux_class->identifier);
free(demux_name);
} else {
xprintf(stream->xine, XINE_VERBOSITY_LOG, _("xine: error while parsing mrl\n"));
@@ -957,7 +1099,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(volume, tmp, strlen(tmp));
volume[strlen(tmp)] = '\0';
}
- mrl_unescape(volume);
+ _x_mrl_unescape(volume);
xine_set_param(stream, XINE_PARAM_AUDIO_VOLUME, atoi(volume));
free(volume);
} else {
@@ -982,7 +1124,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(compression, tmp, strlen(tmp));
compression[strlen(tmp)] = '\0';
}
- mrl_unescape(compression);
+ _x_mrl_unescape(compression);
xine_set_param(stream, XINE_PARAM_AUDIO_COMPR_LEVEL, atoi(compression));
free(compression);
} else {
@@ -1007,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';
}
- 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 ) ) {
@@ -1042,7 +1186,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
memcpy(config_entry, tmp, strlen(tmp));
config_entry[strlen(tmp)] = '\0';
}
- mrl_unescape(config_entry);
+ _x_mrl_unescape(config_entry);
retval = _x_config_change_opt(stream->xine->config, config_entry);
if (retval <= 0) {
if (retval == 0) {
@@ -1087,11 +1231,12 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
lprintf ("demux and input plugin found\n");
_x_meta_info_set_utf8(stream, XINE_META_INFO_SYSTEMLAYER,
- (stream->demux_plugin->demux_class->get_identifier(stream->demux_plugin->demux_class)));
+ stream->demux_plugin->demux_class->identifier);
}
xine_log (stream->xine, XINE_LOG_MSG, _("xine: found demuxer plugin: %s\n"),
- stream->demux_plugin->demux_class->get_description(stream->demux_plugin->demux_class));
+ dgettext(stream->demux_plugin->demux_class->textdomain ? : XINE_TEXTDOMAIN,
+ stream->demux_plugin->demux_class->description));
_x_extra_info_reset( stream->current_extra_info );
_x_extra_info_reset( stream->video_decoder_extra_info );
@@ -1110,7 +1255,11 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
stream->demux_plugin->send_headers (stream->demux_plugin);
if (stream->demux_plugin->get_status(stream->demux_plugin) != DEMUX_OK) {
- xine_log (stream->xine, XINE_LOG_MSG, _("xine: demuxer failed to start\n"));
+ if (stream->demux_plugin->get_status(stream->demux_plugin) == DEMUX_FINISHED) {
+ xine_log (stream->xine, XINE_LOG_MSG, _("xine: demuxer is already done. that was fast!\n"));
+ } else {
+ xine_log (stream->xine, XINE_LOG_MSG, _("xine: demuxer failed to start\n"));
+ }
_x_free_demux_plugin(stream, stream->demux_plugin);
stream->demux_plugin = NULL;
@@ -1315,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;
@@ -1411,6 +1560,8 @@ void xine_exit (xine_t *this) {
WSACleanup();
#endif
+ xdgFreeHandle(this->basedir_handle);
+
free (this);
}
@@ -1509,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, "/.") ||
@@ -1531,13 +1681,15 @@ 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;
}
void xine_init (xine_t *this) {
- static const char *demux_strategies[] = {"default", "reverse", "content",
- "extension", NULL};
+ static const char *const demux_strategies[] = {"default", "reverse", "content",
+ "extension", NULL};
+
+ /* First of all, initialise libxdg-basedir as it's used by plugins. */
+ this->basedir_handle = xdgAllocHandle();
/* initialize color conversion tables and functions */
init_yuv_conversion();
@@ -1970,6 +2122,9 @@ const char *const *xine_get_log_names (xine_t *this) {
static inline void check_log_alloc (xine_t *this, int buf)
{
+ if ( this->log_buffers[buf] )
+ return;
+
pthread_mutex_lock (&this->log_lock);
if ( ! this->log_buffers[buf] )
@@ -2041,3 +2196,111 @@ int xine_stream_master_slave(xine_stream_t *master, xine_stream_t *slave,
slave->master = master->master;
return 1;
}
+
+int _x_query_buffer_usage(xine_stream_t *stream, int *num_video_buffers, int *num_audio_buffers, int *num_video_frames, int *num_audio_frames)
+{
+ int ticket_acquired = -1;
+
+ if (num_video_buffers)
+ *num_video_buffers = (stream->video_fifo ? stream->video_fifo->size(stream->video_fifo) : 0);
+
+ if (num_audio_buffers)
+ *num_audio_buffers = (stream->audio_fifo ? stream->audio_fifo->size(stream->audio_fifo) : 0);
+
+ if ((num_video_frames && stream->video_out)
+ || (num_audio_frames && stream->audio_out)) {
+
+ ticket_acquired = stream->xine->port_ticket->acquire_nonblocking(stream->xine->port_ticket, 1);
+ }
+
+ if (num_video_frames)
+ *num_video_frames = ((ticket_acquired && stream->video_out) ? stream->video_out->get_property(stream->video_out, VO_PROP_BUFS_IN_FIFO) : 0);
+
+ if (num_audio_frames)
+ *num_audio_frames = ((ticket_acquired && stream->audio_out) ? stream->audio_out->get_property(stream->audio_out, AO_PROP_BUFS_IN_FIFO) : 0);
+
+ if (ticket_acquired > 0)
+ stream->xine->port_ticket->release_nonblocking(stream->xine->port_ticket, 1);
+
+ return ticket_acquired != 0;
+}
+
+int _x_lock_port_rewiring(xine_t *xine, int ms_timeout)
+{
+ return xine->port_ticket->lock_port_rewiring(xine->port_ticket, ms_timeout);
+}
+
+void _x_unlock_port_rewiring(xine_t *xine)
+{
+ xine->port_ticket->unlock_port_rewiring(xine->port_ticket);
+}
+
+int _x_lock_frontend(xine_stream_t *stream, int ms_to_time_out)
+{
+ if (ms_to_time_out >= 0) {
+ struct timespec abstime;
+
+ struct timeval now;
+ gettimeofday(&now, 0);
+
+ abstime.tv_sec = now.tv_sec + ms_to_time_out / 1000;
+ abstime.tv_nsec = now.tv_usec * 1000 + (ms_to_time_out % 1000) * 1e6;
+
+ if (abstime.tv_nsec > 1e9) {
+ abstime.tv_nsec -= 1e9;
+ abstime.tv_sec++;
+ }
+
+ return (0 == pthread_mutex_timedlock(&stream->frontend_lock, &abstime));
+ }
+
+ pthread_mutex_lock(&stream->frontend_lock);
+ return 1;
+}
+
+void _x_unlock_frontend(xine_stream_t *stream)
+{
+ pthread_mutex_unlock(&stream->frontend_lock);
+}
+
+int _x_query_unprocessed_osd_events(xine_stream_t *stream)
+{
+ video_overlay_manager_t *ovl;
+ int redraw_needed;
+
+ if (!stream->xine->port_ticket->acquire_nonblocking(stream->xine->port_ticket, 1))
+ return -1;
+
+ ovl = stream->video_out->get_overlay_manager(stream->video_out);
+ redraw_needed = ovl->redraw_needed(ovl, 0);
+
+ if (redraw_needed)
+ stream->video_out->trigger_drawing(stream->video_out);
+
+ stream->xine->port_ticket->release_nonblocking(stream->xine->port_ticket, 1);
+
+ return redraw_needed;
+}
+
+int _x_demux_seek(xine_stream_t *stream, off_t start_pos, int start_time, int playing)
+{
+ if (!stream->demux_plugin)
+ return -1;
+ return stream->demux_plugin->seek(stream->demux_plugin, start_pos, start_time, playing);
+}
+
+int _x_continue_stream_processing(xine_stream_t *stream)
+{
+ return stream->status != XINE_STATUS_STOP
+ && stream->status != XINE_STATUS_QUIT;
+}
+
+void _x_trigger_relaxed_frame_drop_mode(xine_stream_t *stream)
+{
+ stream->first_frame_flag = 2;
+}
+
+void _x_reset_relaxed_frame_drop_mode(xine_stream_t *stream)
+{
+ stream->first_frame_flag = 1;
+}