gst/synaesthesia/gstsynaesthesia.c: Some timestamp fixes.

Original commit message from CVS:
* gst/synaesthesia/gstsynaesthesia.c: (gst_synaesthesia_init),
(gst_synaesthesia_sink_setcaps), (gst_synaesthesia_src_setcaps),
(gst_synaesthesia_chain), (gst_synaesthesia_change_state):
Some timestamp fixes.
* gst/synaesthesia/synaescope.c: (synaescope_coreGo):
Fix for 64-bit machines.
This commit is contained in:
Wim Taymans 2007-04-12 10:19:18 +00:00
parent 47e79a2050
commit 96d8fd786b
3 changed files with 55 additions and 38 deletions

View file

@ -1,3 +1,13 @@
2007-04-12 Wim Taymans <wim@fluendo.com>
* gst/synaesthesia/gstsynaesthesia.c: (gst_synaesthesia_init),
(gst_synaesthesia_sink_setcaps), (gst_synaesthesia_src_setcaps),
(gst_synaesthesia_chain), (gst_synaesthesia_change_state):
Some timestamp fixes.
* gst/synaesthesia/synaescope.c: (synaescope_coreGo):
Fix for 64-bit machines.
2007-04-12 Wim Taymans <wim@fluendo.com> 2007-04-12 Wim Taymans <wim@fluendo.com>
Patch by: René Stadler <mail at renestadler dot de> Patch by: René Stadler <mail at renestadler dot de>

View file

@ -69,12 +69,11 @@ struct _GstSynaesthesia
GstPad *sinkpad, *srcpad; GstPad *sinkpad, *srcpad;
GstAdapter *adapter; GstAdapter *adapter;
guint64 audio_basetime; /* the timestamp of the next frame */ guint64 next_ts; /* the timestamp of the next frame */
guint64 frame_duration; guint64 frame_duration;
guint bps; /* bytes per sample */ guint bps; /* bytes per sample */
guint spf; /* samples per video frame */ guint spf; /* samples per video frame */
guint64 samples_consumed;
gint16 datain[2][SYNAES_SAMPLES]; gint16 datain[2][SYNAES_SAMPLES];
/* video state */ /* video state */
@ -236,8 +235,7 @@ gst_synaesthesia_init (GstSynaesthesia * synaesthesia)
synaesthesia->rate = GST_AUDIO_DEF_RATE; synaesthesia->rate = GST_AUDIO_DEF_RATE;
synaesthesia->channels = 2; synaesthesia->channels = 2;
synaesthesia->audio_basetime = GST_CLOCK_TIME_NONE; synaesthesia->next_ts = GST_CLOCK_TIME_NONE;
synaesthesia->samples_consumed = 0;
/* FIXME: the size is currently ignored by the engine. It should /* FIXME: the size is currently ignored by the engine. It should
* not be, and also there should be a way to change the size later. * not be, and also there should be a way to change the size later.
@ -296,7 +294,6 @@ gst_synaesthesia_sink_setcaps (GstPad * pad, GstCaps * caps)
if (rate <= 0) if (rate <= 0)
goto wrong_rate; goto wrong_rate;
synaesthesia->channels = channels; synaesthesia->channels = channels;
synaesthesia->rate = rate; synaesthesia->rate = rate;
@ -306,18 +303,26 @@ done:
/* Errors */ /* Errors */
missing_caps_details: missing_caps_details:
GST_WARNING ("missing channels or rate in the caps"); {
GST_WARNING_OBJECT (synaesthesia, "missing channels or rate in the caps");
res = FALSE; res = FALSE;
goto done; goto done;
}
wrong_channels: wrong_channels:
GST_WARNING ("number of channels must be 2, but is %d", channels); {
GST_WARNING_OBJECT (synaesthesia, "number of channels must be 2, but is %d",
channels);
res = FALSE; res = FALSE;
goto done; goto done;
}
wrong_rate: wrong_rate:
GST_WARNING ("sample rate must be >0, but is %d", rate); {
GST_WARNING_OBJECT (synaesthesia, "sample rate must be >0, but is %d",
rate);
res = FALSE; res = FALSE;
goto done; goto done;
} }
}
static GstCaps * static GstCaps *
gst_synaesthesia_src_getcaps (GstPad * pad) gst_synaesthesia_src_getcaps (GstPad * pad)
@ -387,15 +392,20 @@ done:
/* Errors */ /* Errors */
missing_caps_details: missing_caps_details:
GST_WARNING ("missing channels or rate in the caps"); {
GST_WARNING_OBJECT (synaesthesia, "missing channels or rate in the caps");
res = FALSE; res = FALSE;
goto done; goto done;
}
wrong_resolution: wrong_resolution:
GST_WARNING ("unsupported resolution: %d x %d (wanted %d x %d)", {
w, h, SYNAES_WIDTH, SYNAES_HEIGHT); GST_WARNING_OBJECT (synaesthesia,
"unsupported resolution: %d x %d (wanted %d x %d)", w, h, SYNAES_WIDTH,
SYNAES_HEIGHT);
res = FALSE; res = FALSE;
goto done; goto done;
} }
}
static GstFlowReturn static GstFlowReturn
gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer) gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
@ -410,8 +420,7 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
/* resync on DISCONT */ /* resync on DISCONT */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) { if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
synaesthesia->audio_basetime = GST_CLOCK_TIME_NONE; synaesthesia->next_ts = GST_CLOCK_TIME_NONE;
synaesthesia->samples_consumed = 0;
gst_adapter_clear (synaesthesia->adapter); gst_adapter_clear (synaesthesia->adapter);
} }
@ -428,11 +437,9 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
} }
} }
if (synaesthesia->audio_basetime == GST_CLOCK_TIME_NONE) /* Match timestamps from the incoming audio */
synaesthesia->audio_basetime = GST_BUFFER_TIMESTAMP (buffer); if (GST_BUFFER_TIMESTAMP (buffer) != GST_CLOCK_TIME_NONE)
synaesthesia->next_ts = GST_BUFFER_TIMESTAMP (buffer);
if (synaesthesia->audio_basetime == GST_CLOCK_TIME_NONE)
synaesthesia->audio_basetime = 0;
gst_adapter_push (synaesthesia->adapter, buffer); gst_adapter_push (synaesthesia->adapter, buffer);
@ -469,9 +476,7 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
if (ret != GST_FLOW_OK) if (ret != GST_FLOW_OK)
break; break;
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (outbuf) = synaesthesia->next_ts;
synaesthesia->audio_basetime +
(GST_SECOND * synaesthesia->samples_consumed / synaesthesia->rate);
GST_BUFFER_DURATION (outbuf) = synaesthesia->frame_duration; GST_BUFFER_DURATION (outbuf) = synaesthesia->frame_duration;
out_frame = (guchar *) out_frame = (guchar *)
@ -484,8 +489,10 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
if (ret != GST_FLOW_OK) if (ret != GST_FLOW_OK)
break; break;
/* FIXME: flush what we actually read */ if (synaesthesia->next_ts != GST_CLOCK_TIME_NONE)
synaesthesia->samples_consumed += synaesthesia->spf; synaesthesia->next_ts += synaesthesia->frame_duration;
/* flush sampled for one frame */
gst_adapter_flush (synaesthesia->adapter, synaesthesia->spf * gst_adapter_flush (synaesthesia->adapter, synaesthesia->spf *
synaesthesia->channels * sizeof (gint16)); synaesthesia->channels * sizeof (gint16));
@ -506,7 +513,7 @@ gst_synaesthesia_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
synaesthesia->audio_basetime = GST_CLOCK_TIME_NONE; synaesthesia->next_ts = GST_CLOCK_TIME_NONE;
gst_adapter_clear (synaesthesia->adapter); gst_adapter_clear (synaesthesia->adapter);
break; break;
default: default:

View file

@ -127,8 +127,8 @@ static void
synaescope_coreGo (syn_instance * si) synaescope_coreGo (syn_instance * si)
{ {
int i, j; int i, j;
register unsigned long *ptr; register guint32 *ptr;
register unsigned long *end; register guint32 *end;
int heightFactor; int heightFactor;
int actualHeight; int actualHeight;
int heightAdd; int heightAdd;
@ -160,8 +160,8 @@ synaescope_coreGo (syn_instance * si)
/* Asger Alstrupt's optimized 32 bit fade */ /* Asger Alstrupt's optimized 32 bit fade */
/* (alstrup@diku.dk) */ /* (alstrup@diku.dk) */
ptr = (unsigned long *) si->output; ptr = (guint32 *) si->output;
end = (unsigned long *) (si->output + syn_width * syn_height * 2); end = (guint32 *) (si->output + syn_width * syn_height * 2);
do { do {
/*Bytewize version was: *(ptr++) -= *ptr+(*ptr>>1)>>4; */ /*Bytewize version was: *(ptr++) -= *ptr+(*ptr>>1)>>4; */
if (*ptr) { if (*ptr) {