summaryrefslogtreecommitdiff
path: root/src/post/visualizations/fftgraph.c
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2003-11-16 12:18:59 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2003-11-16 12:18:59 +0000
commite4f25307b11599e0495aa4743123984287be3650 (patch)
tree13f7bda0cb63ba4bde5e349aa3d1266bf0381aad /src/post/visualizations/fftgraph.c
parent8cc82907bd8a41336a93b92b989295af8fdfe231 (diff)
downloadxine-lib-e4f25307b11599e0495aa4743123984287be3650.tar.gz
xine-lib-e4f25307b11599e0495aa4743123984287be3650.tar.bz2
audio visualization post plugins now use a private metronom to sync their video
CVS patchset: 5743 CVS date: 2003/11/16 12:18:59
Diffstat (limited to 'src/post/visualizations/fftgraph.c')
-rw-r--r--src/post/visualizations/fftgraph.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/post/visualizations/fftgraph.c b/src/post/visualizations/fftgraph.c
index 3d3089642..11cd0c180 100644
--- a/src/post/visualizations/fftgraph.c
+++ b/src/post/visualizations/fftgraph.c
@@ -20,7 +20,7 @@
* FftGraph Visualization Post Plugin For xine
* by Thibaut Mattern (tmattern@noos.fr)
*
- * $Id: fftgraph.c,v 1.4 2003/11/11 18:44:59 f1rmb Exp $
+ * $Id: fftgraph.c,v 1.5 2003/11/16 12:18:59 mroi Exp $
*
*/
@@ -48,6 +48,14 @@
typedef struct post_plugin_fftgraph_s post_plugin_fftgraph_t;
+typedef struct post_class_fftgraph_s post_class_fftgraph_t;
+
+struct post_class_fftgraph_s {
+ post_class_t post_class;
+
+ xine_t *xine;
+};
+
struct post_plugin_fftgraph_s {
post_plugin_t post;
@@ -55,6 +63,9 @@ struct post_plugin_fftgraph_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;
@@ -262,6 +273,8 @@ static int fftgraph_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream
this->stream = stream;
this->data_idx = 0;
+ this->metronom->set_master(this->metronom, stream->metronom);
+
this->fft = fft_new(FFT_BITS);
this->cur_line = 0;
@@ -323,6 +336,8 @@ static void fftgraph_port_close(xine_audio_port_t *port_gen, xine_stream_t *stre
fft_dispose(this->fft);
this->fft = NULL;
+ this->metronom->set_master(this->metronom, NULL);
+
port->original_port->close(port->original_port, stream );
}
@@ -336,7 +351,6 @@ static void fftgraph_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 */
@@ -397,17 +411,9 @@ static void fftgraph_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_fftgraph(this, frame);
@@ -424,6 +430,8 @@ static void fftgraph_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);
@@ -443,6 +451,7 @@ static post_plugin_t *fftgraph_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
+ post_class_fftgraph_t *class = (post_class_fftgraph_t *)class_gen;
post_plugin_fftgraph_t *this = (post_plugin_fftgraph_t *)malloc(sizeof(post_plugin_fftgraph_t));
xine_post_in_t *input = (xine_post_in_t *)malloc(sizeof(xine_post_in_t));
post_fftgraph_out_t *output = (post_fftgraph_out_t *)malloc(sizeof(post_fftgraph_out_t));
@@ -458,6 +467,8 @@ static post_plugin_t *fftgraph_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];
@@ -521,15 +532,17 @@ static void fftgraph_class_dispose(post_class_t *class_gen)
/* plugin class initialization function */
void *fftgraph_init_plugin(xine_t *xine, void *data)
{
- post_class_t *class = (post_class_t *)malloc(sizeof(post_class_t));
+ post_class_fftgraph_t *class = (post_class_fftgraph_t *)malloc(sizeof(post_class_fftgraph_t));
if (!class)
return NULL;
- class->open_plugin = fftgraph_open_plugin;
- class->get_identifier = fftgraph_get_identifier;
- class->get_description = fftgraph_get_description;
- class->dispose = fftgraph_class_dispose;
+ class->post_class.open_plugin = fftgraph_open_plugin;
+ class->post_class.get_identifier = fftgraph_get_identifier;
+ class->post_class.get_description = fftgraph_get_description;
+ class->post_class.dispose = fftgraph_class_dispose;
+
+ class->xine = xine;
return class;
}