diff options
Diffstat (limited to 'src/post/visualizations/oscope.c')
-rw-r--r-- | src/post/visualizations/oscope.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/post/visualizations/oscope.c b/src/post/visualizations/oscope.c index 71fe3933a..553ea5519 100644 --- a/src/post/visualizations/oscope.c +++ b/src/post/visualizations/oscope.c @@ -20,7 +20,7 @@ * Basic Oscilloscope Visualization Post Plugin For xine * by Mike Melanson (melanson@pcisys.net) * - * $Id: oscope.c,v 1.11 2003/11/11 18:45:00 f1rmb Exp $ + * $Id: oscope.c,v 1.12 2003/11/16 12:18:59 mroi Exp $ * */ @@ -41,6 +41,14 @@ typedef struct post_plugin_oscope_s post_plugin_oscope_t; +typedef struct post_class_oscope_s post_class_oscope_t; + +struct post_class_oscope_s { + post_class_t post_class; + + xine_t *xine; +}; + struct post_plugin_oscope_s { post_plugin_t post; @@ -48,6 +56,9 @@ struct post_plugin_oscope_s { xine_video_port_t *vo_port; xine_stream_t *stream; + /* private metronom for syncing the video */ + metronom_t *metronom; + double ratio; int data_idx; @@ -223,6 +234,8 @@ static int oscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream, this->data_idx = 0; init_yuv_planes(&this->yuv, OSCOPE_WIDTH, OSCOPE_HEIGHT); + this->metronom->set_master(this->metronom, stream->metronom); + return port->original_port->open(port->original_port, stream, bits, rate, mode ); } @@ -233,6 +246,8 @@ static void oscope_port_close(xine_audio_port_t *port_gen, xine_stream_t *stream this->stream = NULL; + this->metronom->set_master(this->metronom, NULL); + port->original_port->close(port->original_port, stream ); } @@ -246,7 +261,6 @@ static void oscope_port_put_buffer (xine_audio_port_t *port_gen, int8_t *data8; int samples_used = 0; int64_t pts = buf->vpts; - int64_t vpts = 0; int i, c; /* make a copy of buf data for private use */ @@ -301,17 +315,9 @@ static void oscope_port_put_buffer (xine_audio_port_t *port_gen, frame->extra_info->invalid = 1; frame->bad_frame = 0; frame->duration = 90000 * this->samples_per_frame / this->sample_rate; - if (!vpts) { - vpts = this->stream->metronom->audio_vpts; - frame->pts = pts; - frame->vpts = vpts; - pts = 0; - vpts += frame->duration; - } else { - frame->pts = 0; - frame->vpts = vpts; - vpts += frame->duration; - } + frame->pts = pts; + this->metronom->got_video_frame(this->metronom, frame); + this->sample_counter -= this->samples_per_frame; draw_oscope_dots(this); @@ -330,6 +336,8 @@ static void oscope_dispose(post_plugin_t *this_gen) xine_post_out_t *output = (xine_post_out_t *)xine_list_last_content(this_gen->output); xine_video_port_t *port = *(xine_video_port_t **)output->data; + this->metronom->exit(this->metronom); + if (this->stream) port->close(port, this->stream); @@ -349,6 +357,7 @@ static post_plugin_t *oscope_open_plugin(post_class_t *class_gen, int inputs, xine_audio_port_t **audio_target, xine_video_port_t **video_target) { + post_class_oscope_t *class = (post_class_oscope_t *)class_gen; post_plugin_oscope_t *this = (post_plugin_oscope_t *)malloc(sizeof(post_plugin_oscope_t)); xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t)); post_oscope_out_t *output = (post_oscope_out_t *)malloc(sizeof(post_oscope_out_t)); @@ -364,6 +373,8 @@ static post_plugin_t *oscope_open_plugin(post_class_t *class_gen, int inputs, return NULL; } + this->metronom = _x_metronom_init(0, class->xine); + this->sample_counter = 0; this->stream = NULL; this->vo_port = video_target[0]; @@ -427,15 +438,17 @@ static void oscope_class_dispose(post_class_t *class_gen) /* plugin class initialization function */ void *oscope_init_plugin(xine_t *xine, void *data) { - post_class_t *class = (post_class_t *)malloc(sizeof(post_class_t)); + post_class_oscope_t *class = (post_class_oscope_t *)malloc(sizeof(post_class_oscope_t)); if (!class) return NULL; - class->open_plugin = oscope_open_plugin; - class->get_identifier = oscope_get_identifier; - class->get_description = oscope_get_description; - class->dispose = oscope_class_dispose; + class->post_class.open_plugin = oscope_open_plugin; + class->post_class.get_identifier = oscope_get_identifier; + class->post_class.get_description = oscope_get_description; + class->post_class.dispose = oscope_class_dispose; + + class->xine = xine; - return class; + return &class->post_class; } |