diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/post/goom/xine_goom.c | 76 | ||||
-rw-r--r-- | src/post/planar/invert.c | 57 |
2 files changed, 108 insertions, 25 deletions
diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c index da3e35761..098ec7cf1 100644 --- a/src/post/goom/xine_goom.c +++ b/src/post/goom/xine_goom.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_goom.c,v 1.1 2002/12/25 04:59:14 miguelfreitas Exp $ + * $Id: xine_goom.c,v 1.2 2002/12/25 15:05:06 mroi Exp $ * * GOOM post plugin. * @@ -46,16 +46,24 @@ struct post_plugin_goom_s { /* private data */ xine_video_port_t *vo_port; + xine_stream_t *stream; gint16 data [2][512]; int bits; + int mode; int channels; int sample_rate; int sample_counter; int samples_per_frame; }; +typedef struct post_goom_out_s post_goom_out_t; +struct post_goom_out_s { + xine_post_out_t out; + post_plugin_goom_t *post; +}; + /* plugin class initialization function */ static void *goom_init_plugin(xine_t *xine, void *); @@ -80,7 +88,8 @@ static void goom_class_dispose(post_class_t *class_gen); static void goom_dispose(post_plugin_t *this_gen); /* rewire function */ -static int goom_rewire(xine_post_out_t *output, void *data); +static int goom_rewire_audio(xine_post_out_t *output, void *data); +static int goom_rewire_video(xine_post_out_t *output, void *data); static int goom_port_open(xine_audio_port_t *this, xine_stream_t *stream, uint32_t bits, uint32_t rate, int mode); @@ -111,8 +120,8 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs, { post_plugin_goom_t *this = (post_plugin_goom_t *)malloc(sizeof(post_plugin_goom_t)); xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t)); - xine_post_out_t *output = (xine_post_out_t *)malloc(sizeof(xine_post_out_t)); - xine_post_out_t *outputv = (xine_post_out_t *)malloc(sizeof(xine_post_out_t)); + post_goom_out_t *output = (post_goom_out_t *)malloc(sizeof(post_goom_out_t)); + post_goom_out_t *outputv = (post_goom_out_t *)malloc(sizeof(post_goom_out_t)); post_audio_port_t *port; if (!this || !input || !output || !outputv || !video_target || !video_target[0] || @@ -126,10 +135,10 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs, goom_init (GOOM_WIDTH, GOOM_HEIGHT, 0); this->sample_counter = 0; + this->stream = NULL; this->vo_port = video_target[0]; - port = post_intercept_audio_port(audio_target[0]); - port->post = &this->post.xine_post; + port = post_intercept_audio_port(&this->post, audio_target[0]); port->port.open = goom_port_open; port->port.close = goom_port_close; port->port.put_buffer = goom_port_put_buffer; @@ -138,15 +147,15 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs, input->type = XINE_POST_DATA_AUDIO; input->data = (xine_audio_port_t *)&port->port; - output->name = "audio out"; - output->type = XINE_POST_DATA_AUDIO; - output->data = (xine_audio_port_t **)&port->original_port; - output->rewire = goom_rewire; + output->out.name = "audio out"; + output->out.type = XINE_POST_DATA_AUDIO; + output->out.data = (xine_audio_port_t **)&port->original_port; + output->out.rewire = goom_rewire_audio; - outputv->name = "generated video"; - outputv->type = XINE_POST_DATA_VIDEO; - outputv->data = (xine_video_port_t **)&this->vo_port; - outputv->rewire = NULL; + outputv->out.name = "generated video"; + outputv->out.type = XINE_POST_DATA_VIDEO; + outputv->out.data = (xine_video_port_t **)&this->vo_port; + outputv->out.rewire = goom_rewire_video; this->post.xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *) * 2); this->post.xine_post.audio_input[0] = &port->port; @@ -196,11 +205,41 @@ static void goom_dispose(post_plugin_t *this) } -static int goom_rewire(xine_post_out_t *output, void *data) +static int goom_rewire_audio(xine_post_out_t *output_gen, void *data) +{ + post_goom_out_t *output = (post_goom_out_t *)output_gen; + xine_audio_port_t *old_port = *(xine_audio_port_t **)output_gen->data; + xine_audio_port_t *new_port = (xine_audio_port_t *)data; + post_plugin_goom_t *this = (post_plugin_goom_t *)output->post; + + if (!data) + return 0; + if (this->stream) { + /* register our stream at the new output port */ + old_port->close(old_port, this->stream); + new_port->open(new_port, this->stream, this->bits, this->sample_rate, this->mode); + } + /* reconnect ourselves */ + *(xine_audio_port_t **)output_gen->data = new_port; + return 1; +} + +static int goom_rewire_video(xine_post_out_t *output_gen, void *data) { + post_goom_out_t *output = (post_goom_out_t *)output_gen; + xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data; + xine_video_port_t *new_port = (xine_video_port_t *)data; + post_plugin_goom_t *this = (post_plugin_goom_t *)output->post; + if (!data) return 0; - *(xine_audio_port_t **)output->data = (xine_audio_port_t *)data; + if (this->stream) { + /* register our stream at the new output port */ + old_port->close(old_port, this->stream); + new_port->open(new_port, this->stream); + } + /* reconnect ourselves */ + *(xine_video_port_t **)output_gen->data = new_port; return 1; } @@ -229,9 +268,12 @@ static int goom_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, this->vo_port->open( this->vo_port, stream ); this->bits = bits; + this->mode = mode; this->channels = mode_channels(mode); this->samples_per_frame = rate / FPS; this->sample_rate = rate; + this->stream = stream; + return port->original_port->open(port->original_port, stream, bits, rate, mode ); } @@ -241,6 +283,8 @@ static void goom_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream ) post_plugin_goom_t *this = (post_plugin_goom_t *)port->post; this->vo_port->close( this->vo_port, stream ); + + this->stream = NULL; port->original_port->close(port->original_port, stream ); } diff --git a/src/post/planar/invert.c b/src/post/planar/invert.c index 27494d1b9..8d24a6389 100644 --- a/src/post/planar/invert.c +++ b/src/post/planar/invert.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: invert.c,v 1.4 2002/12/06 14:53:18 mroi Exp $ + * $Id: invert.c,v 1.5 2002/12/25 15:05:06 mroi Exp $ */ /* @@ -40,6 +40,14 @@ plugin_info_t xine_plugin_info[] = { }; +/* plugin structure */ +typedef struct post_invert_out_s post_invert_out_t; +struct post_invert_out_s { + xine_post_out_t xine_out; + /* keep the stream for open/close when rewiring */ + xine_stream_t *stream; +}; + /* plugin class functions */ static post_plugin_t *invert_open_plugin(post_class_t *class_gen, int inputs, xine_audio_port_t **audio_target, @@ -55,9 +63,11 @@ static void invert_dispose(post_plugin_t *this_gen); static int invert_rewire(xine_post_out_t *output, void *data); /* replaced video_port functions */ +static void invert_open(xine_video_port_t *port_gen, xine_stream_t *stream); static vo_frame_t *invert_get_frame(xine_video_port_t *port_gen, uint32_t width, uint32_t height, int ratio_code, int format, int flags); +static void invert_close(xine_video_port_t *port_gen, xine_stream_t *stream); /* replaced vo_frame functions */ static int invert_draw(vo_frame_t *frame, xine_stream_t *stream); @@ -85,7 +95,7 @@ static post_plugin_t *invert_open_plugin(post_class_t *class_gen, int inputs, { post_plugin_t *this = (post_plugin_t *)malloc(sizeof(post_plugin_t)); xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t)); - xine_post_out_t *output = (xine_post_out_t *)malloc(sizeof(xine_post_out_t)); + post_invert_out_t *output = (post_invert_out_t *)malloc(sizeof(post_invert_out_t)); post_video_port_t *port; if (!this || !input || !output || !video_target || !video_target[0]) { @@ -95,18 +105,21 @@ static post_plugin_t *invert_open_plugin(post_class_t *class_gen, int inputs, return NULL; } - port = post_intercept_video_port(video_target[0]); + port = post_intercept_video_port(this, video_target[0]); /* replace with our own get_frame function */ + port->port.open = invert_open; port->port.get_frame = invert_get_frame; + port->port.close = invert_close; input->name = "video"; input->type = XINE_POST_DATA_VIDEO; input->data = (xine_video_port_t *)&port->port; - output->name = "inverted video"; - output->type = XINE_POST_DATA_VIDEO; - output->data = (xine_video_port_t **)&port->original_port; - output->rewire = invert_rewire; + output->xine_out.name = "inverted video"; + output->xine_out.type = XINE_POST_DATA_VIDEO; + output->xine_out.data = (xine_video_port_t **)&port->original_port; + output->xine_out.rewire = invert_rewire; + output->stream = NULL; this->xine_post.audio_input = (xine_audio_port_t **)malloc(sizeof(xine_audio_port_t *)); this->xine_post.audio_input[0] = NULL; @@ -153,15 +166,33 @@ static void invert_dispose(post_plugin_t *this) } -static int invert_rewire(xine_post_out_t *output, void *data) +static int invert_rewire(xine_post_out_t *output_gen, void *data) { + post_invert_out_t *output = (post_invert_out_t *)output_gen; + xine_video_port_t *old_port = *(xine_video_port_t **)output_gen->data; + xine_video_port_t *new_port = (xine_video_port_t *)data; + if (!data) return 0; - *(xine_video_port_t **)output->data = (xine_video_port_t *)data; + if (output->stream) { + /* register our stream at the new output port */ + old_port->close(old_port, output->stream); + new_port->open(new_port, output->stream); + } + /* reconnect ourselves */ + *(xine_video_port_t **)output_gen->data = new_port; return 1; } +static void invert_open(xine_video_port_t *port_gen, xine_stream_t *stream) +{ + post_video_port_t *port = (post_video_port_t *)port_gen; + post_invert_out_t *output = (post_invert_out_t *)xine_list_first_content(port->post->output); + output->stream = stream; + port->original_port->open(port->original_port, stream); +} + static vo_frame_t *invert_get_frame(xine_video_port_t *port_gen, uint32_t width, uint32_t height, int ratio_code, int format, int flags) @@ -179,6 +210,14 @@ static vo_frame_t *invert_get_frame(xine_video_port_t *port_gen, uint32_t width, return frame; } +static void invert_close(xine_video_port_t *port_gen, xine_stream_t *stream) +{ + post_video_port_t *port = (post_video_port_t *)port_gen; + post_invert_out_t *output = (post_invert_out_t *)xine_list_first_content(port->post->output); + output->stream = NULL; + port->original_port->close(port->original_port, stream); +} + static int invert_draw(vo_frame_t *frame, xine_stream_t *stream) { |