diff options
Diffstat (limited to 'src/xine-engine')
-rw-r--r-- | src/xine-engine/audio_out.c | 53 | ||||
-rw-r--r-- | src/xine-engine/broadcaster.c | 38 | ||||
-rw-r--r-- | src/xine-engine/events.c | 55 | ||||
-rw-r--r-- | src/xine-engine/load_plugins.c | 356 | ||||
-rw-r--r-- | src/xine-engine/plugin_catalog.h | 7 | ||||
-rw-r--r-- | src/xine-engine/post.c | 25 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 67 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 31 | ||||
-rw-r--r-- | src/xine-engine/xine_interface.c | 20 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 3 |
10 files changed, 368 insertions, 287 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index d7567994c..a3e8e70be 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.194 2005/10/30 02:18:35 miguelfreitas Exp $ + * $Id: audio_out.c,v 1.195 2006/01/27 07:46:15 tmattern Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -1049,12 +1049,15 @@ static void *ao_loop (void *this_gen) { pthread_mutex_unlock( &this->driver_lock ); if (in_buf && in_buf->num_frames) { + xine_list_iterator_t ite; + xprintf(this->xine, XINE_VERBOSITY_LOG, _("audio_out: delay calculation impossible with an unavailable audio device\n")); pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams); - stream; stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); + ite; ite = xine_list_next(this->streams, ite)) { + stream = xine_list_get_value (this->streams, ite); if( !stream->emergency_brake ) { stream->emergency_brake = 1; _x_message (stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL); @@ -1134,11 +1137,12 @@ static void *ao_loop (void *this_gen) { cur_time > (last_sync_time + SYNC_TIME_INVERVAL) && bufs_since_sync >= SYNC_BUF_INTERVAL && !this->resample_sync_method ) { - xine_stream_t *stream; + xine_list_iterator_t *ite; lprintf ("audio_loop: ADJ_VPTS\n"); pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams); stream; - stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + xine_stream_t *stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM) continue; stream->metronom->set_option(stream->metronom, METRONOM_ADJ_VPTS_OFFSET, -gap/SYNC_GAP_RATE ); @@ -1230,11 +1234,13 @@ int xine_get_next_audio_frame (xine_audio_port_t *this_gen, lprintf ("get_next_audio_frame\n"); while (!in_buf || !stream) { - stream = xine_list_first_content(this->streams); - if (!stream) { + xine_list_iterator_t ite = xine_list_front (this->streams); + + if (!ite) { xine_usec_sleep (5000); continue; } + stream = xine_list_get_value(this->streams, ite); /* FIXME: ugly, use conditions and locks instead? */ @@ -1445,7 +1451,7 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, } pthread_mutex_lock(&this->streams_lock); - xine_list_append_content(this->streams, stream); + xine_list_push_back(this->streams, stream); pthread_mutex_unlock(&this->streams_lock); return this->output.rate; @@ -1512,23 +1518,25 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { aos_t *this = (aos_t *) this_gen; - xine_stream_t *cur; + xine_list_iterator_t ite; xprintf (this->xine, XINE_VERBOSITY_DEBUG, "ao_close\n"); /* unregister stream */ pthread_mutex_lock(&this->streams_lock); - for (cur = xine_list_first_content(this->streams); cur; - cur = xine_list_next_content(this->streams)) + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + xine_stream_t *cur = xine_list_get_value(this->streams, ite); if (cur == stream) { - xine_list_delete_current(this->streams); + xine_list_remove(this->streams, ite); break; } - cur = xine_list_first_content(this->streams); + } + ite = xine_list_front(this->streams); pthread_mutex_unlock(&this->streams_lock); /* close driver if no streams left */ - if (!cur && !this->grab_only && !stream->gapless_switch) { + if (!ite && !this->grab_only && !stream->gapless_switch) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: no streams left, closing driver\n"); if (this->audio_loop_running) { @@ -1584,7 +1592,7 @@ static void ao_exit(xine_audio_port_t *this_gen) { pthread_mutex_destroy(&this->driver_lock); pthread_mutex_destroy(&this->driver_action_lock); pthread_mutex_destroy(&this->streams_lock); - xine_list_free(this->streams); + xine_list_delete(this->streams); free (this->frame_buf[0]->mem); free (this->frame_buf[0]->extra_info); @@ -1659,7 +1667,6 @@ static uint32_t ao_get_capabilities (xine_audio_port_t *this_gen) { static int ao_get_property (xine_audio_port_t *this_gen, int property) { aos_t *this = (aos_t *) this_gen; - xine_stream_t *cur; int ret; switch (property) { @@ -1672,11 +1679,8 @@ static int ao_get_property (xine_audio_port_t *this_gen, int property) { break; case AO_PROP_NUM_STREAMS: - ret = 0; pthread_mutex_lock(&this->streams_lock); - for (cur = xine_list_first_content(this->streams); cur; - cur = xine_list_next_content(this->streams)) - ret++; + ret = xine_list_size(this->streams); pthread_mutex_unlock(&this->streams_lock); break; @@ -1912,10 +1916,12 @@ static int ao_status (xine_audio_port_t *this_gen, xine_stream_t *stream, aos_t *this = (aos_t *) this_gen; xine_stream_t *cur; int ret = 0; + xine_list_iterator_t ite; pthread_mutex_lock(&this->streams_lock); - for (cur = xine_list_first_content(this->streams); cur; - cur = xine_list_next_content(this->streams)) + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + cur = xine_list_get_value(this->streams, ite); if (cur == stream || !stream) { *bits = this->input.bits; *rate = this->input.rate; @@ -1923,6 +1929,7 @@ static int ao_status (xine_audio_port_t *this_gen, xine_stream_t *stream, ret = !!stream; /* return false for a NULL stream, true otherwise */ break; } + } pthread_mutex_unlock(&this->streams_lock); return ret; diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c index 59c6ba6c4..68168a80c 100644 --- a/src/xine-engine/broadcaster.c +++ b/src/xine-engine/broadcaster.c @@ -19,7 +19,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: broadcaster.c,v 1.8 2004/07/22 14:25:05 mroi Exp $ + * $Id: broadcaster.c,v 1.9 2006/01/27 07:46:15 tmattern Exp $ * * broadcaster.c - xine network broadcaster * @@ -156,10 +156,14 @@ static int sock_string_write(xine_t *xine, int socket, char *msg, ...) { * it sends data to every connected client (slaves). */ static void broadcaster_data_write(broadcaster_t *this, char *buf, int len) { - int *psock; + xine_list_iterator_t ite; - psock = xine_list_first_content (this->connections); - while (psock) { + ite = xine_list_front (this->connections); + while (ite) { + + int *psock = xine_list_get_value(this->connections, ite); + + ite = xine_list_next(this->connections, ite); /* in case of failure remove from list */ if( sock_data_write(this->stream->xine, *psock, buf, len) < 0 ) { @@ -167,13 +171,9 @@ static void broadcaster_data_write(broadcaster_t *this, char *buf, int len) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: closing socket %d\n", *psock); close(*psock); free(psock); - if( this->connections->cur->next ) - psock = this->connections->cur->next->content; - else - psock = NULL; - xine_list_delete_current (this->connections); - } else - psock = xine_list_next_content (this->connections); + + xine_list_remove (this->connections, xine_list_prev(this->connections, ite)); + } } } @@ -227,7 +227,7 @@ static void *manager_loop (void *this_gen) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: new connection socket %d\n", *psock); - xine_list_append_content(this->connections, psock); + xine_list_push_back(this->connections, psock); } } } @@ -343,20 +343,16 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) void _x_close_broadcaster(broadcaster_t *this) { - int *psock; + xine_list_iterator_t ite; - psock = xine_list_first_content (this->connections); - while (psock) { + while ( (ite = xine_list_front(this->connections)) ) { + int *psock = xine_list_get_value(this->connections, ite); xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: closing socket %d\n", *psock); close(*psock); free(psock); - xine_list_delete_current (this->connections); - if( this->connections->cur ) - psock = this->connections->cur->content; - else - psock = NULL; + xine_list_remove (this->connections, ite); } - xine_list_free(this->connections); + xine_list_delete(this->connections); this->running = 0; close(this->msock); diff --git a/src/xine-engine/events.c b/src/xine-engine/events.c index ef399b5c6..ed2858b91 100644 --- a/src/xine-engine/events.c +++ b/src/xine-engine/events.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: events.c,v 1.28 2005/09/19 16:14:02 valtri Exp $ + * $Id: events.c,v 1.29 2006/01/27 07:46:15 tmattern Exp $ * * Event handling functions * @@ -34,12 +34,13 @@ xine_event_t *xine_event_get (xine_event_queue_t *queue) { xine_event_t *event; + xine_list_iterator_t ite; pthread_mutex_lock (&queue->lock); - - event = (xine_event_t *) xine_list_first_content (queue->events); + ite = xine_list_front (queue->events); + event = xine_list_get_value (queue->events, ite); if (event) - xine_list_delete_current (queue->events); + xine_list_remove (queue->events, ite); pthread_mutex_unlock (&queue->lock); @@ -49,14 +50,17 @@ xine_event_t *xine_event_get (xine_event_queue_t *queue) { xine_event_t *xine_event_wait (xine_event_queue_t *queue) { xine_event_t *event; + xine_list_iterator_t ite; pthread_mutex_lock (&queue->lock); - while (!(event = (xine_event_t *) xine_list_first_content (queue->events))) { + while ( !(ite = xine_list_front (queue->events)) ) { pthread_cond_wait (&queue->new_event, &queue->lock); } - xine_list_delete_current (queue->events); + event = xine_list_get_value (queue->events, ite); + + xine_list_remove (queue->events, ite); pthread_mutex_unlock (&queue->lock); @@ -70,16 +74,17 @@ void xine_event_free (xine_event_t *event) { void xine_event_send (xine_stream_t *stream, const xine_event_t *event) { - xine_event_queue_t *queue; + xine_list_iterator_t ite; pthread_mutex_lock (&stream->event_queues_lock); - queue = (xine_event_queue_t *)xine_list_first_content (stream->event_queues); + ite = xine_list_front (stream->event_queues); - while (queue) { - + while (ite) { + xine_event_queue_t *queue; xine_event_t *cevent; + queue = xine_list_get_value(stream->event_queues, ite); cevent = malloc (sizeof (xine_event_t)); cevent->type = event->type; cevent->stream = stream; @@ -93,11 +98,11 @@ void xine_event_send (xine_stream_t *stream, const xine_event_t *event) { gettimeofday (&cevent->tv, NULL); pthread_mutex_lock (&queue->lock); - xine_list_append_content (queue->events, cevent); + xine_list_push_back (queue->events, cevent); pthread_cond_signal (&queue->new_event); pthread_mutex_unlock (&queue->lock); - queue=(xine_event_queue_t *)xine_list_next_content (stream->event_queues); + ite = xine_list_next (stream->event_queues, ite); } pthread_mutex_unlock (&stream->event_queues_lock); @@ -119,7 +124,7 @@ xine_event_queue_t *xine_event_new_queue (xine_stream_t *stream) { queue->callback_running = 0; pthread_mutex_lock (&stream->event_queues_lock); - xine_list_append_content (stream->event_queues, queue); + xine_list_push_back (stream->event_queues, queue); pthread_mutex_unlock (&stream->event_queues_lock); return queue; @@ -127,17 +132,21 @@ xine_event_queue_t *xine_event_new_queue (xine_stream_t *stream) { void xine_event_dispose_queue (xine_event_queue_t *queue) { - xine_stream_t *stream = queue->stream; - xine_event_t *event; - xine_event_t *qevent; - xine_event_queue_t *q; + xine_stream_t *stream = queue->stream; + xine_event_t *event; + xine_event_t *qevent; + xine_event_queue_t *q; + xine_list_iterator_t ite; pthread_mutex_lock (&stream->event_queues_lock); - q = (xine_event_queue_t *) xine_list_first_content (stream->event_queues); + ite = xine_list_front (stream->event_queues); + q = xine_list_get_value (stream->event_queues, ite); - while (q && (q != queue)) - q = (xine_event_queue_t *) xine_list_next_content (stream->event_queues); + while (ite && (q != queue)) { + ite = xine_list_next (stream->event_queues, ite); + q = xine_list_get_value (stream->event_queues, ite); + } if (!q) { xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "events: tried to dispose queue which is not in list\n"); @@ -146,7 +155,7 @@ void xine_event_dispose_queue (xine_event_queue_t *queue) { return; } - xine_list_delete_current (stream->event_queues); + xine_list_remove (stream->event_queues, ite); pthread_mutex_unlock (&stream->event_queues_lock); /* @@ -161,7 +170,7 @@ void xine_event_dispose_queue (xine_event_queue_t *queue) { gettimeofday (&qevent->tv, NULL); pthread_mutex_lock (&queue->lock); - xine_list_append_content (queue->events, qevent); + xine_list_push_back (queue->events, qevent); pthread_cond_signal (&queue->new_event); pthread_mutex_unlock (&queue->lock); @@ -212,7 +221,7 @@ static void *listener_loop (void *queue_gen) { xine_event_free (event); pthread_mutex_lock (&queue->lock); - if (xine_list_is_empty (queue->events)) { + if (xine_list_empty (queue->events)) { pthread_cond_signal (&queue->events_processed); } pthread_mutex_unlock (&queue->lock); diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index f7f243938..19df1b662 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.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: load_plugins.c,v 1.217 2005/11/28 12:25:21 valtri Exp $ + * $Id: load_plugins.c,v 1.218 2006/01/27 07:46:15 tmattern Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -106,17 +106,16 @@ static int plugin_iface_versions[] = { POST_PLUGIN_IFACE_VERSION }; -static void _build_list_typed_plugins(plugin_catalog_t **catalog, xine_list_t *type) { +static void _build_list_typed_plugins(plugin_catalog_t **catalog, xine_sarray_t *type) { plugin_node_t *node; - int i = 0; - - node = xine_list_first_content (type); - while (node) { - (*catalog)->ids[i] = node->info->id; - i++; - node = xine_list_next_content (type); + int list_id, list_size; + + list_size = xine_sarray_size (type); + for (list_id = 0; list_id < list_size; list_id++) { + node = xine_sarray_get(type, list_id); + (*catalog)->ids[list_id] = node->info->id; } - (*catalog)->ids[i] = NULL; + (*catalog)->ids[list_id] = NULL; } static void inc_file_ref(plugin_file_t *file) { @@ -164,10 +163,10 @@ static int get_decoder_priority(xine_t *this, plugin_node_t *node) { } static void map_decoder_list (xine_t *this, - xine_list_t *decoder_list, + xine_sarray_t *decoder_list, plugin_node_t *decoder_map[DECODER_MAX][PLUGINS_PER_TYPE]) { int i; - plugin_node_t *node; + int list_id, list_size; /* init */ for (i = 0; i < DECODER_MAX; i++) { @@ -177,9 +176,10 @@ static void map_decoder_list (xine_t *this, /* * map decoders */ - node = xine_list_first_content (decoder_list); - while (node) { + list_size = xine_sarray_size(decoder_list); + for (list_id = 0; list_id < list_size; list_id++) { + plugin_node_t *node = xine_sarray_get(decoder_list, list_id); uint32_t *type = ((decoder_info_t *)node->info->special_info)->supported_types; int priority = get_decoder_priority(this, node); @@ -209,8 +209,6 @@ static void map_decoder_list (xine_t *this, type++; } - - node = xine_list_next_content (decoder_list); } } @@ -238,11 +236,12 @@ static void _decoder_priority_cb(void *data, xine_cfg_entry_t *cfg) { static plugin_info_t *_get_cached_info (xine_t *this, char *filename, off_t filesize, time_t filemtime, plugin_info_t *previous_info) { - plugin_node_t *node; - xine_list_t *list = this->plugin_catalog->cache_list; + xine_sarray_t *list = this->plugin_catalog->cache_list; + int list_id, list_size; - node = xine_list_first_content (list); - while (node) { + list_size = xine_sarray_size (list); + for (list_id = 0; list_id < list_size; list_id++) { + plugin_node_t *node = xine_sarray_get (list, list_id); if( !previous_info && node->file->filesize == filesize && node->file->filemtime == filemtime && @@ -255,7 +254,6 @@ static plugin_info_t *_get_cached_info (xine_t *this, if( node->info == previous_info ) previous_info = NULL; - node = xine_list_next_content (list); } return NULL; } @@ -276,13 +274,13 @@ static plugin_file_t *_insert_file (xine_t *this, entry->ref = 0; entry->no_unload = 0; - xine_list_append_content (list, entry); + xine_list_push_back (list, entry); return entry; } static void _insert_node (xine_t *this, - xine_list_t *list, + xine_sarray_t *list, plugin_file_t *file, plugin_info_t *info, int api_version){ @@ -296,7 +294,6 @@ static void _insert_node (xine_t *this, demuxer_info_t *demux_new, *demux_old; input_info_t *input_new, *input_old; uint32_t *types; - int priority = 0; char key[80]; char desc[100]; int i; @@ -318,13 +315,14 @@ static void _insert_node (xine_t *this, entry->plugin_class = NULL; entry->file = file; entry->ref = 0; + entry->priority = 0; /* default priority */ switch (info->type & PLUGIN_TYPE_MASK){ case PLUGIN_VIDEO_OUT: vo_old = info->special_info; vo_new = xine_xmalloc(sizeof(vo_info_t)); - priority = vo_new->priority = vo_old->priority; + entry->priority = vo_new->priority = vo_old->priority; vo_new->visual_type = vo_old->visual_type; entry->info->special_info = vo_new; break; @@ -332,7 +330,7 @@ static void _insert_node (xine_t *this, case PLUGIN_AUDIO_OUT: ao_old = info->special_info; ao_new = xine_xmalloc(sizeof(ao_info_t)); - priority = ao_new->priority = ao_old->priority; + entry->priority = ao_new->priority = ao_old->priority; entry->info->special_info = ao_new; break; @@ -358,7 +356,7 @@ static void _insert_node (xine_t *this, types[i] = decoder_old->supported_types[i]; } decoder_new->supported_types = types; - priority = decoder_new->priority = decoder_old->priority; + entry->priority = decoder_new->priority = decoder_old->priority; snprintf(key, sizeof(key), "engine.decoder_priorities.%s", info->id); snprintf(desc, sizeof(desc), _("priority for %s decoder"), info->id); @@ -396,14 +394,14 @@ static void _insert_node (xine_t *this, demux_new = xine_xmalloc(sizeof(demuxer_info_t)); if (demux_old) { - priority = demux_new->priority = demux_old->priority; + entry->priority = demux_new->priority = demux_old->priority; lprintf("demux: %s, priority: %d\n", info->id, priority); } else { xprintf(this, XINE_VERBOSITY_LOG, _("load_plugins: demuxer plugin %s does not provide a priority," " xine-lib will use the default priority.\n"), info->id); - priority = demux_new->priority = 0; + entry->priority = demux_new->priority = 0; } entry->info->special_info = demux_new; break; @@ -413,14 +411,14 @@ static void _insert_node (xine_t *this, input_new = xine_xmalloc(sizeof(input_info_t)); if (input_old) { - priority = input_new->priority = input_old->priority; + entry->priority = input_new->priority = input_old->priority; lprintf("input: %s, priority: %d\n", info->id, priority); } else { xprintf(this, XINE_VERBOSITY_LOG, _("load_plugins: input plugin %s does not provide a priority," " xine-lib will use the default priority.\n"), info->id); - priority = input_new->priority = 0; + entry->priority = input_new->priority = 0; } entry->info->special_info = input_new; break; @@ -430,10 +428,23 @@ static void _insert_node (xine_t *this, file->no_unload = 1; } - xine_list_append_priority_content (list, entry, priority); + xine_sarray_add(list, entry); } +static int _plugin_node_comparator(void *a, void *b) { + plugin_node_t *node_a = (plugin_node_t *)a; + plugin_node_t *node_b = (plugin_node_t *)b; + + if (node_a->priority < node_b->priority) { + return -1; + } else if (node_a->priority == node_b->priority) { + return 0; + } else { + return 1; + } +} + static plugin_catalog_t *_new_catalog(void){ plugin_catalog_t *catalog; @@ -442,10 +453,10 @@ static plugin_catalog_t *_new_catalog(void){ catalog = xine_xmalloc(sizeof(plugin_catalog_t)); for (i = 0; i < PLUGIN_TYPE_MAX; i++) { - catalog->plugin_lists[i] = xine_list_new(); + catalog->plugin_lists[i] = xine_sarray_new(0, _plugin_node_comparator); } - catalog->cache_list = xine_list_new(); + catalog->cache_list = xine_sarray_new(0, _plugin_node_comparator); catalog->file_list = xine_list_new(); pthread_mutex_init (&catalog->lock, NULL); @@ -456,7 +467,7 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, plugin _x_assert(this); _x_assert(info); - while ( info && info->type != PLUGIN_NONE ){ + while ( info && info->type != PLUGIN_NONE ) { if (file) xine_log (this, XINE_LOG_PLUGIN, @@ -739,27 +750,29 @@ static void _dispose_plugin_class(plugin_node_t *node) { * load input+demuxer plugins * load plugins that asked to be initialized */ -static void _load_required_plugins(xine_t *this, xine_list_t *list) { +static void _load_required_plugins(xine_t *this, xine_sarray_t *list) { - plugin_node_t *node; + int list_id = 0; + int list_size; - node = xine_list_first_content (list); - while (node) { + list_size = xine_sarray_size(list); + while (list_id < list_size) { + plugin_node_t *node = xine_sarray_get(list, list_id); - if( (node->info->type & PLUGIN_MUST_PRELOAD) && !node->plugin_class ) { + if( (node->info->type & PLUGIN_MUST_PRELOAD) && !node->plugin_class ) { lprintf("preload plugin %s from %s\n", node->info->id, node->file->filename); if (! _load_plugin_class (this, node, NULL)) { /* in case of failure remove from list */ - xine_list_delete_current (list); - node = list->cur ? list->cur->content : NULL; + xine_sarray_remove(list, list_id); + list_size = xine_sarray_size(list); } else - node = xine_list_next_content (list); - } else - node = xine_list_next_content (list); + list_id++; + } else + list_id++; } } @@ -776,7 +789,7 @@ static void load_required_plugins(xine_t *this) { /* * save plugin list information to file (cached catalog) */ -static void save_plugin_list(FILE *fp, xine_list_t *plugins) { +static void save_plugin_list(FILE *fp, xine_sarray_t *list) { plugin_node_t *node; plugin_file_t *file; @@ -788,9 +801,12 @@ static void save_plugin_list(FILE *fp, xine_list_t *plugins) { post_info_t *post_info; int i; + int list_id = 0; + int list_size; - node = xine_list_first_content (plugins); - while (node) { + list_size = xine_sarray_size (list); + while (list_id < list_size) { + node = xine_sarray_get(list, list_id); file = node->file; fprintf(fp, "[%s]\n", file->filename ); @@ -843,14 +859,14 @@ static void save_plugin_list(FILE *fp, xine_list_t *plugins) { } fprintf(fp, "\n"); - node = xine_list_next_content (plugins); + list_id++; } } /* * load plugin list information from file (cached catalog) */ -static void load_plugin_list(FILE *fp, xine_list_t *plugins) { +static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) { plugin_node_t *node; plugin_file_t *file; @@ -884,7 +900,7 @@ static void load_plugin_list(FILE *fp, xine_list_t *plugins) { *value = (char) 0; if( node ) { - xine_list_append_content (plugins, node); + xine_sarray_add (plugins, node); } node = xine_xmalloc(sizeof(plugin_node_t)); file = xine_xmalloc(sizeof(plugin_file_t)); @@ -1003,7 +1019,7 @@ static void load_plugin_list(FILE *fp, xine_list_t *plugins) { } if( node ) { - xine_list_append_content (plugins, node); + xine_sarray_add (plugins, node); } } @@ -1139,11 +1155,13 @@ input_plugin_t *_x_find_input_plugin (xine_stream_t *stream, const char *mrl) { plugin_catalog_t *catalog = xine->plugin_catalog; plugin_node_t *node; input_plugin_t *plugin = NULL; + int list_id, list_size; pthread_mutex_lock (&catalog->lock); - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); - while (node) { + list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_INPUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_INPUT - 1], list_id); if (node->plugin_class || _load_plugin_class(xine, node, NULL)) { if ((plugin = ((input_class_t *)node->plugin_class)->get_instance(node->plugin_class, stream, mrl))) { @@ -1151,9 +1169,7 @@ input_plugin_t *_x_find_input_plugin (xine_stream_t *stream, const char *mrl) { plugin->node = node; break; } - } - - node = xine_list_next_content (stream->xine->plugin_catalog->plugin_lists[PLUGIN_INPUT - 1]); + } } pthread_mutex_unlock (&catalog->lock); @@ -1194,16 +1210,17 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth i = 0; while (methods[i] != -1 && !plugin) { - - plugin_node_t *node; + int list_id, list_size; stream->content_detection_method = methods[i]; pthread_mutex_lock (&catalog->lock); - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); + list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]); + for(list_id = 0; list_id < list_size; list_id++) { + plugin_node_t *node; - while (node) { + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id); xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: probing demux '%s'\n", node->info->id); @@ -1214,8 +1231,6 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth break; } } - - node = xine_list_next_content (stream->xine->plugin_catalog->plugin_lists[PLUGIN_DEMUX - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1256,12 +1271,17 @@ demux_plugin_t *_x_find_demux_plugin_by_name(xine_stream_t *stream, const char * plugin_catalog_t *catalog = stream->xine->plugin_catalog; plugin_node_t *node; demux_plugin_t *plugin = NULL; + int list_id, list_size; pthread_mutex_lock(&catalog->lock); - node = xine_list_first_content(catalog->plugin_lists[PLUGIN_DEMUX - 1]); + stream->content_detection_method = METHOD_EXPLICIT; - while (node) { + list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get(catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id); + if (strcasecmp(node->info->id, name) == 0) { if (node->plugin_class || _load_plugin_class(stream->xine, node, NULL)) { if ((plugin = ((demux_class_t *)node->plugin_class)->open_plugin(node->plugin_class, stream, input))) { @@ -1271,7 +1291,6 @@ demux_plugin_t *_x_find_demux_plugin_by_name(xine_stream_t *stream, const char * } } } - node = xine_list_next_content(catalog->plugin_lists[PLUGIN_DEMUX - 1]); } pthread_mutex_unlock(&catalog->lock); @@ -1302,16 +1321,17 @@ demux_plugin_t *_x_find_demux_plugin_last_probe(xine_stream_t *stream, const cha i = 0; while (methods[i] != -1 && !plugin) { - - plugin_node_t *node; + int list_id, list_size; stream->content_detection_method = methods[i]; pthread_mutex_lock (&catalog->lock); - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); + list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + plugin_node_t *node; - while (node) { + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id); lprintf ("probing demux '%s'\n", node->info->id); @@ -1330,8 +1350,6 @@ demux_plugin_t *_x_find_demux_plugin_last_probe(xine_stream_t *stream, const cha } } } - - node = xine_list_next_content (stream->xine->plugin_catalog->plugin_lists[PLUGIN_DEMUX - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1378,16 +1396,19 @@ const char *const *xine_get_autoplay_input_plugin_ids(xine_t *this) { plugin_catalog_t *catalog; plugin_node_t *node; + int list_id, list_size; catalog = this->plugin_catalog; pthread_mutex_lock (&catalog->lock); catalog->ids[0] = NULL; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); - while (node) { + + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_INPUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { input_class_t *ic; + node = xine_sarray_get(catalog->plugin_lists[PLUGIN_INPUT - 1], list_id); if (node->plugin_class || _load_plugin_class(this, node, NULL)) { ic = (input_class_t *) node->plugin_class; @@ -1402,7 +1423,6 @@ const char *const *xine_get_autoplay_input_plugin_ids(xine_t *this) { catalog->ids[i] = node->info->id; } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1415,16 +1435,19 @@ const char *const *xine_get_browsable_input_plugin_ids(xine_t *this) { plugin_catalog_t *catalog; plugin_node_t *node; + int list_id, list_size; catalog = this->plugin_catalog; pthread_mutex_lock (&catalog->lock); catalog->ids[0] = NULL; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_INPUT - 1]); + + for (list_id = 0; list_id < list_size; list_id++) { input_class_t *ic; + node = xine_sarray_get(catalog->plugin_lists[PLUGIN_INPUT - 1], list_id); if (node->plugin_class || _load_plugin_class(this, node, NULL)) { ic = (input_class_t *) node->plugin_class; @@ -1439,7 +1462,6 @@ const char *const *xine_get_browsable_input_plugin_ids(xine_t *this) { catalog->ids[i] = node->info->id; } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1477,6 +1499,7 @@ vo_driver_t *_x_load_video_output_plugin(xine_t *this, vo_driver_t *driver; vo_info_t *vo_info; plugin_catalog_t *catalog = this->plugin_catalog; + int list_id, list_size; driver = NULL; @@ -1485,8 +1508,10 @@ vo_driver_t *_x_load_video_output_plugin(xine_t *this, pthread_mutex_lock (&catalog->lock); - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1], list_id); vo_info = node->info->special_info; if (vo_info->visual_type == visual_type) { @@ -1506,8 +1531,6 @@ vo_driver_t *_x_load_video_output_plugin(xine_t *this, } } } - - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1542,21 +1565,23 @@ xine_video_port_t *xine_new_framegrab_video_port (xine_t *this) { vo_info_t *vo_info; plugin_catalog_t *catalog = this->plugin_catalog; char *id; + int list_id, list_size; driver = NULL; id = "none"; pthread_mutex_lock (&catalog->lock); - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1], list_id); vo_info = node->info->special_info; if (!strcasecmp (node->info->id, id)) { driver = _load_video_driver (this, node, NULL); break; } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1621,6 +1646,7 @@ xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id, xine_audio_port_t *port; ao_info_t *ao_info; plugin_catalog_t *catalog = this->plugin_catalog; + int list_id, list_size; if (id && !strcasecmp(id, "auto") ) id = NULL; @@ -1629,8 +1655,10 @@ xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id, driver = NULL; - node = xine_list_first_content (this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1]); - while (node) { + list_size = xine_sarray_size (this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1], list_id); ao_info = node->info->special_info; @@ -1645,8 +1673,6 @@ xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id, break; } } - - node = xine_list_next_content (this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -1697,13 +1723,16 @@ void xine_close_video_driver (xine_t *this, xine_video_port_t *vo_port) { char **xine_get_autoplay_mrls (xine_t *this, const char *plugin_id, int *num_mrls) { - plugin_catalog_t *catalog; - plugin_node_t *node; + plugin_catalog_t *catalog; + plugin_node_t *node; + int list_id, list_size; catalog = this->plugin_catalog; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_INPUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_INPUT - 1], list_id); if (!strcasecmp (node->info->id, plugin_id)) { input_class_t *ic; @@ -1718,7 +1747,6 @@ char **xine_get_autoplay_mrls (xine_t *this, const char *plugin_id, return ic->get_autoplay_list (ic, num_mrls); } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); } return NULL; } @@ -1731,11 +1759,14 @@ xine_mrl_t **xine_get_browse_mrls (xine_t *this, const char *plugin_id, plugin_catalog_t *catalog; plugin_node_t *node; + int list_id, list_size; catalog = this->plugin_catalog; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_INPUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_INPUT - 1], list_id); if (!strcasecmp (node->info->id, plugin_id)) { input_class_t *ic; @@ -1750,7 +1781,6 @@ xine_mrl_t **xine_get_browse_mrls (xine_t *this, const char *plugin_id, return ic->get_dir (ic, start_mrl, num_mrls); } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_INPUT - 1]); } return NULL; } @@ -1911,12 +1941,16 @@ static void _display_file_plugin_list (xine_list_t *list, plugin_file_t *file) { } #endif -static void _unload_unref_plugins(xine_t *this, xine_list_t *list) { +static void _unload_unref_plugins(xine_t *this, xine_sarray_t *list) { plugin_node_t *node; + int list_id, list_size; + + list_size = xine_sarray_size (list); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (list, list_id); - node = xine_list_first_content(list); - while (node) { if (node->ref == 0) { plugin_file_t *file = node->file; @@ -1936,7 +1970,6 @@ static void _unload_unref_plugins(xine_t *this, xine_list_t *list) { file->lib_handle = NULL; } } - node = xine_list_next_content(list); } } @@ -2105,15 +2138,17 @@ const char *const *xine_list_post_plugins_typed(xine_t *xine, int type) { plugin_catalog_t *catalog = xine->plugin_catalog; plugin_node_t *node; int i; + int list_id, list_size; pthread_mutex_lock (&catalog->lock); i = 0; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_POST - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_POST - 1]); + + for (list_id = 0; list_id < list_size; list_id++) { + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_POST - 1], list_id); if (((post_info_t *)node->info->special_info)->type == type) catalog->ids[i++] = node->info->id; - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_POST - 1]); } catalog->ids[i] = NULL; @@ -2124,8 +2159,11 @@ const char *const *xine_list_post_plugins_typed(xine_t *xine, int type) { #define GET_PLUGIN_DESC(NAME,TYPE,CATITEM) \ const char *xine_get_##NAME##_plugin_description (xine_t *this, const char *plugin_id) { \ plugin_catalog_t *catalog = this->plugin_catalog; \ - plugin_node_t *node = xine_list_first_content (catalog->plugin_lists[CATITEM - 1]); \ - while (node) { \ + plugin_node_t *node; \ + int list_id, list_size; \ + list_size = xine_sarray_size (catalog->plugin_lists[CATITEM - 1]); \ + for (list_id = 0; list_id < list_size; list_id++) { \ + node = xine_sarray_get (catalog->plugin_lists[CATITEM - 1], list_id); \ if (!strcasecmp (node->info->id, plugin_id)) { \ TYPE##_class_t *ic = (TYPE##_class_t *) node->plugin_class; \ if (!ic) { \ @@ -2136,7 +2174,6 @@ const char *const *xine_list_post_plugins_typed(xine_t *xine, int type) { } \ return ic->get_description(ic); \ } \ - node = xine_list_next_content (catalog->plugin_lists[CATITEM - 1]); \ } \ return NULL; \ } @@ -2156,14 +2193,17 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, plugin_catalog_t *catalog = xine->plugin_catalog; plugin_node_t *node; post_plugin_t *post = NULL; + int list_id, list_size; if( !name ) return NULL; pthread_mutex_lock(&catalog->lock); - node = xine_list_first_content(catalog->plugin_lists[PLUGIN_POST - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_POST - 1]); + + for (list_id = 0; list_id < list_size; list_id++) { + node = xine_sarray_get (catalog->plugin_lists[PLUGIN_POST - 1], list_id); if (strcmp(node->info->id, name) == 0) { @@ -2179,6 +2219,7 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, if (post) { xine_post_in_t *input; xine_post_out_t *output; + xine_list_iterator_t ite; int i; post->running_ticket = xine->port_ticket; @@ -2188,32 +2229,36 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, /* init the lists of announced connections */ i = 0; - input = xine_list_first_content(post->input); - while (input) { + ite = xine_list_front(post->input); + while (ite) { + input = xine_list_get_value (post->input, ite); i++; - input = xine_list_next_content(post->input); + ite = xine_list_next (post->input, ite); } post->input_ids = malloc(sizeof(char *) * (i + 1)); i = 0; - input = xine_list_first_content(post->input); - while (input) { + ite = xine_list_front (post->input); + while (ite) { + input = xine_list_get_value (post->input, ite); post->input_ids[i++] = input->name; - input = xine_list_next_content(post->input); + ite = xine_list_next (post->input, ite); } post->input_ids[i] = NULL; i = 0; - output = xine_list_first_content(post->output); - while (output) { + ite = xine_list_front (post->output); + while (ite) { + output = xine_list_get_value (post->output, ite); i++; - output = xine_list_next_content(post->output); + ite = xine_list_next (post->output, ite); } post->output_ids = malloc(sizeof(char *) * (i + 1)); i = 0; - output = xine_list_first_content(post->output); - while (output) { + ite = xine_list_front (post->output); + while (ite) { + output = xine_list_get_value (post->output, ite); post->output_ids[i++] = output->name; - output = xine_list_next_content(post->output); + ite = xine_list_next (post->output, ite); } post->output_ids[i] = NULL; @@ -2227,8 +2272,6 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, break; } } - - node = xine_list_next_content(catalog->plugin_lists[PLUGIN_POST - 1]); } pthread_mutex_unlock(&catalog->lock); @@ -2258,17 +2301,19 @@ char *xine_get_file_extensions (xine_t *self) { int len, pos; plugin_node_t *node; char *str; + int list_id, list_size; pthread_mutex_lock (&catalog->lock); /* calc length of output */ len = 0; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); + for (list_id = 0; list_id < list_size; list_id++) { demux_class_t *cls; char *exts; + 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; @@ -2276,19 +2321,19 @@ char *xine_get_file_extensions (xine_t *self) { if((exts = cls->get_extensions(cls)) && strlen(exts)) len += strlen(exts) + 1; } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); } /* create output */ str = malloc (len); /* '\0' space is already counted in the previous loop */ pos = 0; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); + for (list_id = 0; list_id < list_size; list_id++) { demux_class_t *cls; char *e; int l; + 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; @@ -2306,7 +2351,6 @@ char *xine_get_file_extensions (xine_t *self) { } } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); } str[pos] = 0; @@ -2325,16 +2369,20 @@ char *xine_get_mime_types (xine_t *self) { int len, pos; plugin_node_t *node; char *str; + int list_id, list_size; pthread_mutex_lock (&catalog->lock); /* calc length of output */ - len = 0; node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); - while (node) { + len = 0; + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); + + for (list_id = 0; list_id < list_size; list_id++) { demux_class_t *cls; char *s; + 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; @@ -2343,7 +2391,6 @@ char *xine_get_mime_types (xine_t *self) { if (s) len += strlen(s); } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); } /* create output */ @@ -2351,12 +2398,14 @@ char *xine_get_mime_types (xine_t *self) { str = malloc (len+1); pos = 0; - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); - while (node) { + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); + + for (list_id = 0; list_id < list_size; list_id++) { demux_class_t *cls; char *s; int l; + 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; @@ -2369,7 +2418,6 @@ char *xine_get_mime_types (xine_t *self) { pos += l; } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); } str[pos] = 0; @@ -2391,6 +2439,7 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { char *id = NULL; char *mime_arg, *mime_demux; char *s; + int list_id, list_size; /* create a copy and convert to lower case */ mime_arg = strdup(mime_type); @@ -2399,10 +2448,12 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { pthread_mutex_lock (&catalog->lock); - node = xine_list_first_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); - while (node && !id) { + 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; @@ -2420,7 +2471,6 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { free(mime_demux); } } - node = xine_list_next_content (catalog->plugin_lists[PLUGIN_DEMUX - 1]); } pthread_mutex_unlock (&catalog->lock); @@ -2431,21 +2481,23 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { } -static void dispose_plugin_list (xine_list_t *list) { +static void dispose_plugin_list (xine_sarray_t *list) { - plugin_node_t *node; + plugin_node_t *node; decoder_info_t *decoder_info; + int list_id, list_size; - if(list) { + if (list) { - node = xine_list_first_content (list); - while (node) { + list_size = xine_sarray_size (list); + + for (list_id = 0; list_id < list_size; list_id++) { + node = xine_sarray_get (list, list_id); if (node->ref == 0) _dispose_plugin_class(node); else { lprintf("node \"%s\" still referenced %d time(s)\n", node->info->id, node->ref); - node = xine_list_next_content (list); continue; } @@ -2467,24 +2519,24 @@ static void dispose_plugin_list (xine_list_t *list) { free (node->info->id); free (node->info); free (node); - - node = xine_list_next_content (list); } - xine_list_free(list); + xine_sarray_delete(list); } } static void dispose_plugin_file_list (xine_list_t *list) { - plugin_file_t *file; + plugin_file_t *file; + xine_list_iterator_t ite; - file = xine_list_first_content (list); - while (file) { + ite = xine_list_front (list); + while (ite) { + file = xine_list_get_value (list, ite); free (file->filename); free (file); - file = xine_list_next_content (list); + ite = xine_list_next (list, ite); } - xine_list_free(list); + xine_list_delete (list); } diff --git a/src/xine-engine/plugin_catalog.h b/src/xine-engine/plugin_catalog.h index e7b212f78..027dd082a 100644 --- a/src/xine-engine/plugin_catalog.h +++ b/src/xine-engine/plugin_catalog.h @@ -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: plugin_catalog.h,v 1.19 2005/04/10 09:31:17 tmattern Exp $ + * $Id: plugin_catalog.h,v 1.20 2006/01/27 07:46:15 tmattern Exp $ * * xine-internal header: Definitions for plugin lists * @@ -58,12 +58,13 @@ typedef struct { plugin_info_t *info; void *plugin_class; int ref; /* count intances of plugins */ + int priority; } plugin_node_t ; struct plugin_catalog_s { - xine_list_t *plugin_lists[PLUGIN_TYPE_MAX]; + xine_sarray_t *plugin_lists[PLUGIN_TYPE_MAX]; - xine_list_t *cache_list; + xine_sarray_t *cache_list; xine_list_t *file_list; plugin_node_t *audio_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE]; diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c index 93737d714..6ae96e982 100644 --- a/src/xine-engine/post.c +++ b/src/xine-engine/post.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: post.c,v 1.31 2005/07/17 20:22:24 jstembridge Exp $ + * $Id: post.c,v 1.32 2006/01/27 07:46:15 tmattern Exp $ */ /* @@ -243,7 +243,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ (*input)->xine_in.type = XINE_POST_DATA_VIDEO; (*input)->xine_in.data = &port->new_port; (*input)->post = post; - xine_list_append_content(post->input, *input); + xine_list_push_back(post->input, *input); } if (output) { @@ -255,7 +255,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ (*output)->xine_out.rewire = post_video_rewire; (*output)->post = post; (*output)->user_data = port; - xine_list_append_content(post->output, *output); + xine_list_push_back(post->output, *output); } return port; @@ -725,7 +725,7 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ (*input)->xine_in.type = XINE_POST_DATA_AUDIO; (*input)->xine_in.data = &port->new_port; (*input)->post = post; - xine_list_append_content(post->input, *input); + xine_list_push_back(post->input, *input); } if (output) { @@ -737,7 +737,7 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ (*output)->xine_out.rewire = post_audio_rewire; (*output)->post = post; (*output)->user_data = port; - xine_list_append_content(post->output, *output); + xine_list_push_back(post->output, *output); } return port; @@ -790,6 +790,7 @@ int _x_post_dispose(post_plugin_t *this) { if (!in_use) { xine_post_in_t *input; xine_post_out_t *output; + xine_list_iterator_t ite; /* we can really dispose it */ @@ -799,8 +800,9 @@ int _x_post_dispose(post_plugin_t *this) { free(this->input_ids); free(this->output_ids); - for (input = xine_list_first_content(this->input); input; - input = xine_list_next_content(this->input)) { + for (ite = xine_list_front(this->input); ite; + ite = xine_list_next(this->input, ite)) { + input = xine_list_get_value(this->input, ite); switch (input->type) { case XINE_POST_DATA_VIDEO: { @@ -832,8 +834,9 @@ int _x_post_dispose(post_plugin_t *this) { break; } } - for (output = xine_list_first_content(this->output); output; - output = xine_list_next_content(this->output)) { + for (ite = xine_list_front(this->output); ite; + ite = xine_list_next(this->output, ite)) { + output = xine_list_get_value(this->output, ite); switch (output->type) { case XINE_POST_DATA_VIDEO: if (output->rewire == post_video_rewire) @@ -848,8 +851,8 @@ int _x_post_dispose(post_plugin_t *this) { } } - xine_list_free(this->input); - xine_list_free(this->output); + xine_list_delete(this->input); + xine_list_delete(this->output); /* since the plugin loader does not know, when the plugin gets disposed, * we have to handle the reference counter here */ diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 2c19daee9..603bd5b39 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.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: video_out.c,v 1.222 2005/11/14 23:48:19 miguelfreitas Exp $ + * $Id: video_out.c,v 1.223 2006/01/27 07:46:15 tmattern Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -502,6 +502,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { if (!img->bad_frame) { int img_already_locked = 0; + xine_list_iterator_t ite; /* add cropping requested by frontend */ img->crop_left += this->crop_left; @@ -543,8 +544,9 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { */ img->is_first = 0; pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams); stream; - stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM) continue; pthread_mutex_lock (&stream->first_frame_lock); if (stream->first_frame_flag == 2) { @@ -583,6 +585,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { if ((this->num_frames_delivered % 200) == 0 && this->num_frames_delivered) { int send_event; + xine_list_iterator_t ite; if( (100 * this->num_frames_skipped / this->num_frames_delivered) > this->warn_skipped_threshold || @@ -600,8 +603,9 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { this->warn_threshold_event_sent += send_event; pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams); stream; - stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM) continue; _x_stream_info_set(stream, XINE_STREAM_INFO_SKIPPED_FRAMES, 1000 * this->num_frames_skipped / this->num_frames_delivered); @@ -967,6 +971,7 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, static void overlay_and_display_frame (vos_t *this, vo_frame_t *img, int64_t vpts) { xine_stream_t *stream; + xine_list_iterator_t ite; lprintf ("displaying image with vpts = %" PRId64 "\n", img->vpts); @@ -1006,8 +1011,9 @@ static void overlay_and_display_frame (vos_t *this, */ if( this->last_frame->is_first ) { pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams); stream; - stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM) continue; pthread_mutex_lock (&stream->first_frame_lock); if (stream->first_frame_flag) { @@ -1149,11 +1155,12 @@ static void *video_out_loop (void *this_gen) { diff = vpts - this->last_delivery_pts; if (diff > 30000 && !this->display_img_buf_queue->first) { - xine_stream_t *stream; + xine_list_iterator_t ite; pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams); stream; - stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + xine_stream_t *stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM) continue; if (stream->video_decoder_plugin && stream->video_fifo) { buf_element_t *buf; @@ -1255,12 +1262,12 @@ int xine_get_next_video_frame (xine_video_port_t *this_gen, xine_stream_t *stream = NULL; while (!img || !stream) { - stream = xine_list_first_content(this->streams); + xine_list_iterator_t ite = xine_list_front(this->streams); + stream = xine_list_get_value(this->streams, ite); if (!stream) { xine_usec_sleep (5000); continue; } - /* FIXME: ugly, use conditions and locks instead? */ @@ -1327,14 +1334,14 @@ static void vo_open (xine_video_port_t *this_gen, xine_stream_t *stream) { /* enable overlays if our new stream might want to show some */ this->overlay_enabled = 1; pthread_mutex_lock(&this->streams_lock); - xine_list_append_content(this->streams, stream); + xine_list_push_back(this->streams, stream); pthread_mutex_unlock(&this->streams_lock); } static void vo_close (xine_video_port_t *this_gen, xine_stream_t *stream) { vos_t *this = (vos_t *) this_gen; - xine_stream_t *cur; + xine_list_iterator_t ite; /* this will make sure all hide events were processed */ if (this->overlay_source) @@ -1344,19 +1351,20 @@ static void vo_close (xine_video_port_t *this_gen, xine_stream_t *stream) { /* unregister stream */ pthread_mutex_lock(&this->streams_lock); - for (cur = xine_list_first_content(this->streams); cur; - cur = xine_list_next_content(this->streams)) + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + xine_stream_t *cur = xine_list_get_value(this->streams, ite); if (cur == stream) { - xine_list_delete_current(this->streams); + xine_list_remove(this->streams, ite); break; } + } pthread_mutex_unlock(&this->streams_lock); } static int vo_get_property (xine_video_port_t *this_gen, int property) { vos_t *this = (vos_t *) this_gen; - xine_stream_t *cur; int ret; switch (property) { @@ -1369,11 +1377,8 @@ static int vo_get_property (xine_video_port_t *this_gen, int property) { break; case VO_PROP_NUM_STREAMS: - ret = 0; pthread_mutex_lock(&this->streams_lock); - for (cur = xine_list_first_content(this->streams); cur; - cur = xine_list_next_content(this->streams)) - ret++; + ret = xine_list_size(this->streams); pthread_mutex_unlock(&this->streams_lock); break; @@ -1524,12 +1529,13 @@ static int vo_status (xine_video_port_t *this_gen, xine_stream_t *stream, int *width, int *height, int64_t *img_duration) { vos_t *this = (vos_t *) this_gen; - xine_stream_t *cur; + xine_list_iterator_t ite; int ret = 0; pthread_mutex_lock(&this->streams_lock); - for (cur = xine_list_first_content(this->streams); cur; - cur = xine_list_next_content(this->streams)) + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + xine_stream_t *cur = xine_list_get_value(this->streams, ite); if (cur == stream || !stream) { *width = this->current_width; *height = this->current_height; @@ -1537,6 +1543,7 @@ static int vo_status (xine_video_port_t *this_gen, xine_stream_t *stream, ret = !!stream; /* return false for a NULL stream, true otherwise */ break; } + } pthread_mutex_unlock(&this->streams_lock); return ret; @@ -1584,7 +1591,7 @@ static void vo_exit (xine_video_port_t *this_gen) { this->overlay_source->dispose (this->overlay_source); } - xine_list_free(this->streams); + xine_list_delete(this->streams); pthread_mutex_destroy(&this->streams_lock); free (this->free_img_buf_queue); @@ -1615,10 +1622,12 @@ static void vo_enable_overlay (xine_video_port_t *this_gen, int overlay_enabled) this->overlay_enabled = 1; } else { /* ... but we only actually DISable, if all associated streams have SPU off */ - xine_stream_t *stream; + xine_list_iterator_t ite; + pthread_mutex_lock(&this->streams_lock); - for (stream = xine_list_first_content(this->streams) ; stream ; - stream = xine_list_next_content(this->streams)) { + for (ite = xine_list_front(this->streams); ite; + ite = xine_list_next(this->streams, ite)) { + xine_stream_t *stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM || stream->spu_channel_user > -2) { pthread_mutex_unlock(&this->streams_lock); return; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 9bc0aa6b2..b97ae7157 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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.c,v 1.320 2006/01/26 12:13:23 miguelfreitas Exp $ + * $Id: xine.c,v 1.321 2006/01/27 07:46:16 tmattern Exp $ */ /* @@ -594,7 +594,7 @@ xine_stream_t *xine_stream_new (xine_t *this, * register stream */ - xine_list_append_content (this->streams, stream); + xine_list_push_back (this->streams, stream); pthread_mutex_unlock (&this->streams_lock); @@ -630,13 +630,14 @@ static void mrl_unescape(char *mrl) { void _x_flush_events_queues (xine_stream_t *stream) { - xine_event_queue_t *queue; + xine_list_iterator_t ite; pthread_mutex_lock (&stream->event_queues_lock); /* No events queue? */ - for (queue = xine_list_first_content (stream->event_queues); - queue; queue = xine_list_next_content (stream->event_queues)) { + for (ite = xine_list_front (stream->event_queues); + ite; ite = xine_list_next (stream->event_queues, ite)) { + xine_event_queue_t *queue = xine_list_get_value(stream->event_queues, ite); pthread_mutex_lock (&queue->lock); pthread_mutex_unlock (&stream->event_queues_lock); @@ -646,7 +647,7 @@ void _x_flush_events_queues (xine_stream_t *stream) { * currently executing their callback functions. */ if (queue->listener_thread != NULL && !queue->callback_running) { - while (!xine_list_is_empty (queue->events)) { + while (!xine_list_empty (queue->events)) { pthread_cond_wait (&queue->events_processed, &queue->lock); } } @@ -1258,7 +1259,7 @@ int xine_eject (xine_stream_t *stream) { void xine_dispose_internal (xine_stream_t *stream) { - xine_stream_t *s; + xine_list_iterator_t *ite; lprintf("stream: %p\n", stream); pthread_mutex_destroy (&stream->info_mutex); @@ -1275,12 +1276,9 @@ void xine_dispose_internal (xine_stream_t *stream) { stream->metronom->exit (stream->metronom); pthread_mutex_lock(&stream->xine->streams_lock); - for (s = xine_list_first_content(stream->xine->streams); - s; s = xine_list_next_content(stream->xine->streams)) { - if (s == stream) { - xine_list_delete_current (stream->xine->streams); - break; - } + ite = xine_list_find(stream->xine->streams, stream); + if (ite) { + xine_list_remove(stream->xine->streams, ite); } pthread_mutex_unlock(&stream->xine->streams_lock); @@ -1336,7 +1334,7 @@ void xine_exit (xine_t *this) { _x_dispose_plugins (this); if(this->streams) { - xine_list_free(this->streams); + xine_list_delete(this->streams); pthread_mutex_destroy(&this->streams_lock); } @@ -1463,13 +1461,16 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) { strcmp(entry->str_value, xine_get_homedir()) == 0 || strcmp(entry->str_value, homedir_trail_slash) == 0)) { xine_stream_t *stream; + xine_list_iterator_t ite; xine_log(this, XINE_LOG_MSG, _("xine: The specified save_dir \"%s\" might be a security risk.\n"), entry->str_value); pthread_mutex_lock(&this->streams_lock); - if ((stream = (xine_stream_t *)xine_list_first_content(this->streams))) + if ( (ite = xine_list_front(this->streams)) ) { + stream = xine_list_get_value(this->streams, ite); _x_message(stream, XINE_MSG_SECURITY, _("The specified save_dir might be a security risk."), NULL); + } pthread_mutex_unlock(&this->streams_lock); } diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 18c86349b..9a785c9b3 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.91 2005/10/30 02:18:35 miguelfreitas Exp $ + * $Id: xine_interface.c,v 1.92 2006/01/27 07:46:16 tmattern Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -813,26 +813,28 @@ const char *const *xine_post_list_outputs(xine_post_t *this_gen) { xine_post_in_t *xine_post_input(xine_post_t *this_gen, const char *name) { post_plugin_t *this = (post_plugin_t *)this_gen; - xine_post_in_t *input; + xine_list_iterator_t ite; - input = xine_list_first_content(this->input); - while (input) { + ite = xine_list_front(this->input); + while (ite) { + xine_post_in_t *input = xine_list_get_value(this->input, ite); if (strcmp(input->name, name) == 0) return input; - input = xine_list_next_content(this->input); + ite = xine_list_next(this->input, ite); } return NULL; } xine_post_out_t *xine_post_output(xine_post_t *this_gen, const char *name) { post_plugin_t *this = (post_plugin_t *)this_gen; - xine_post_out_t *output; + xine_list_iterator_t ite; - output = xine_list_first_content(this->output); - while (output) { + ite = xine_list_front(this->output); + while (ite) { + xine_post_out_t *output = xine_list_get_value(this->output, ite); if (strcmp(output->name, name) == 0) return output; - output = xine_list_next_content(this->output); + ite = xine_list_next(this->output, ite); } return NULL; } diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index b3cb7d65c..0fc083569 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -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_internal.h,v 1.170 2006/01/26 12:13:23 miguelfreitas Exp $ + * $Id: xine_internal.h,v 1.171 2006/01/27 07:46:16 tmattern Exp $ * */ @@ -264,6 +264,7 @@ struct xine_stream_s { audio_decoder_t *audio_decoder_plugin; int audio_decoder_streamtype; extra_info_t *audio_decoder_extra_info; + uint32_t audio_track_map[50]; int audio_track_map_entries; uint32_t audio_type; |