diff options
Diffstat (limited to 'src/xine-engine/post.c')
-rw-r--r-- | src/xine-engine/post.c | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c index 6ae96e982..651bb10f3 100644 --- a/src/xine-engine/post.c +++ b/src/xine-engine/post.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: post.c,v 1.32 2006/01/27 07:46:15 tmattern Exp $ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ /* @@ -27,7 +25,7 @@ #define POST_INTERNAL #define XINE_ENGINE_INTERNAL -#include "post.h" +#include <xine/post.h> #include <stdarg.h> @@ -59,7 +57,7 @@ static void post_video_open(xine_video_port_t *port_gen, xine_stream_t *stream) _x_post_rewire(port->post); _x_post_inc_usage(port); if (port->port_lock) pthread_mutex_lock(port->port_lock); - port->original_port->open(port->original_port, stream); + (port->original_port->open) (port->original_port, stream); if (port->port_lock) pthread_mutex_unlock(port->port_lock); port->stream = stream; } @@ -149,6 +147,14 @@ static void post_video_flush(xine_video_port_t *port_gen) { if (port->port_lock) pthread_mutex_unlock(port->port_lock); } +static void post_video_trigger_drawing(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + + if (port->port_lock) pthread_mutex_lock(port->port_lock); + port->original_port->trigger_drawing(port->original_port); + if (port->port_lock) pthread_mutex_unlock(port->port_lock); +} + static int post_video_status(xine_video_port_t *port_gen, xine_stream_t *stream, int *width, int *height, int64_t *img_duration) { post_video_port_t *port = (post_video_port_t *)port_gen; @@ -192,16 +198,18 @@ static int post_video_rewire(xine_post_out_t *output_gen, void *data) { if (!new_port) return 0; + this->running_ticket->lock_port_rewiring(this->running_ticket, -1); this->running_ticket->revoke(this->running_ticket, 1); if (input_port->original_port->status(input_port->original_port, input_port->stream, &width, &height, &img_duration)) { - new_port->open(new_port, input_port->stream); + (new_port->open) (new_port, input_port->stream); input_port->original_port->close(input_port->original_port, input_port->stream); } input_port->original_port = new_port; this->running_ticket->issue(this->running_ticket, 1); + this->running_ticket->unlock_port_rewiring(this->running_ticket); return 1; } @@ -223,6 +231,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ port->new_port.exit = post_video_exit; port->new_port.get_overlay_manager = post_video_get_overlay_manager; port->new_port.flush = post_video_flush; + port->new_port.trigger_drawing = post_video_trigger_drawing; port->new_port.status = post_video_status; port->new_port.get_property = post_video_get_property; port->new_port.set_property = post_video_set_property; @@ -362,6 +371,9 @@ vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t * /* make a copy and attach the original */ xine_fast_memcpy(new_frame, frame, sizeof(vo_frame_t)); new_frame->next = frame; + + if (new_frame->stream) + _x_refcounter_inc(new_frame->stream->refcounter); /* modify the frame with the intercept functions */ new_frame->port = &port->new_port; @@ -379,10 +391,11 @@ vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t * port->new_frame->free ? port->new_frame->free : post_frame_free; new_frame->dispose = port->new_frame->dispose ? port->new_frame->dispose : post_frame_dispose; - - if (!port->new_frame->draw) { + + if (!port->new_frame->draw || (port->route_preprocessing_procs && port->route_preprocessing_procs(port, frame))) { /* draw will most likely modify the frame, so the decoder - * should only request preprocessing when there is no new draw */ + * should only request preprocessing when there is no new draw + * but route_preprocessing_procs() can override this decision */ if (frame->proc_frame && !new_frame->proc_frame) new_frame->proc_frame = post_frame_proc_frame; if (frame->proc_slice && !new_frame->proc_slice) @@ -399,6 +412,9 @@ vo_frame_t *_x_post_restore_video_frame(vo_frame_t *frame, post_video_port_t *po /* propagate any changes */ _x_post_frame_copy_down(frame, original); + if (frame->stream) + _x_refcounter_dec(frame->stream->refcounter); + /* put the now free slot into the free frames list */ pthread_mutex_lock(&port->free_frames_lock); frame->next = port->free_frame_slots; @@ -410,6 +426,11 @@ vo_frame_t *_x_post_restore_video_frame(vo_frame_t *frame, post_video_port_t *po void _x_post_frame_copy_down(vo_frame_t *from, vo_frame_t *to) { /* propagate changes downwards (from decoders to video out) */ + if (from->stream) + _x_refcounter_inc(from->stream->refcounter); + if (to->stream) + _x_refcounter_dec(to->stream->refcounter); + to->pts = from->pts; to->bad_frame = from->bad_frame; to->duration = from->duration; @@ -432,8 +453,14 @@ void _x_post_frame_copy_down(vo_frame_t *from, vo_frame_t *to) { void _x_post_frame_copy_up(vo_frame_t *to, vo_frame_t *from) { /* propagate changes upwards (from video out to decoders) */ + if (from->stream) + _x_refcounter_inc(from->stream->refcounter); + if (to->stream) + _x_refcounter_dec(to->stream->refcounter); + to->vpts = from->vpts; to->duration = from->duration; + to->stream = from->stream; if (to->extra_info != from->extra_info) _x_extra_info_merge(to->extra_info, from->extra_info); @@ -441,6 +468,11 @@ void _x_post_frame_copy_up(vo_frame_t *to, vo_frame_t *from) { void _x_post_frame_u_turn(vo_frame_t *frame, xine_stream_t *stream) { /* frame's travel will end here => do the housekeeping */ + if (stream) + _x_refcounter_inc(stream->refcounter); + if (frame->stream) + _x_refcounter_dec(frame->stream->refcounter); + frame->stream = stream; if (stream) { _x_extra_info_merge(frame->extra_info, stream->video_decoder_extra_info); @@ -583,7 +615,7 @@ static int post_audio_open(xine_audio_port_t *port_gen, xine_stream_t *stream, _x_post_rewire(port->post); _x_post_inc_usage(port); if (port->port_lock) pthread_mutex_lock(port->port_lock); - result = port->original_port->open(port->original_port, stream, bits, rate, mode); + result = (port->original_port->open) (port->original_port, stream, bits, rate, mode); if (port->port_lock) pthread_mutex_unlock(port->port_lock); port->stream = stream; port->bits = bits; @@ -680,16 +712,18 @@ static int post_audio_rewire(xine_post_out_t *output_gen, void *data) { if (!new_port) return 0; + this->running_ticket->lock_port_rewiring(this->running_ticket, -1); this->running_ticket->revoke(this->running_ticket, 1); if (input_port->original_port->status(input_port->original_port, input_port->stream, &bits, &rate, &mode)) { - new_port->open(new_port, input_port->stream, bits, rate, mode); + (new_port->open) (new_port, input_port->stream, bits, rate, mode); input_port->original_port->close(input_port->original_port, input_port->stream); } input_port->original_port = new_port; this->running_ticket->issue(this->running_ticket, 1); + this->running_ticket->unlock_port_rewiring(this->running_ticket); return 1; } @@ -857,7 +891,7 @@ int _x_post_dispose(post_plugin_t *this) { /* since the plugin loader does not know, when the plugin gets disposed, * we have to handle the reference counter here */ pthread_mutex_lock(&this->xine->plugin_catalog->lock); - ((plugin_node_t *)this->node)->ref--; + this->node->ref--; pthread_mutex_unlock(&this->xine->plugin_catalog->lock); return 1; |