gst/audioscale/gstaudioscale.c: %#^@^#@^@#^#@^#@^@#^@#^@#^@#^#@^#@^#@^@#^#@ fix seeking when resampling - how the ^@$...

Original commit message from CVS:
* gst/audioscale/gstaudioscale.c: (gst_audioscale_init),
(gst_audioscale_chain):
%#^@^#@^@#^#@^#@^@#^@#^@#^@#^#@^#@^#@^@#^#@ fix seeking
when resampling - how the ^@$^!@^! is this possible?!?
This commit is contained in:
Ronald S. Bultje 2005-01-09 12:22:56 +00:00
parent 71c41d27f8
commit a356581006
2 changed files with 48 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2005-01-09 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* gst/audioscale/gstaudioscale.c: (gst_audioscale_init),
(gst_audioscale_chain):
%#^@^#@^@#^#@^#@^@#^@#^@#^@#^#@^#@^#@^@#^#@ fix seeking
when resampling - how the ^@$^!@^! is this possible?!?
2005-01-09 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/alsa/gstalsa.c: (gst_alsa_change_state):

View file

@ -523,6 +523,8 @@ gst_audioscale_init (Audioscale * audioscale)
audioscale->offsets = NULL;
audioscale->gst_resample_offset = 0;
audioscale->increase = FALSE;
GST_FLAG_SET (audioscale, GST_ELEMENT_EVENT_AWARE);
}
static void
@ -564,6 +566,45 @@ gst_audioscale_chain (GstPad * pad, GstData * _data)
return;
}
if (GST_IS_EVENT (_data)) {
GstEvent *e = GST_EVENT (_data);
switch (GST_EVENT_TYPE (e)) {
case GST_EVENT_DISCONTINUOUS:{
gint64 new_off;
if (gst_event_discont_get_value (e, GST_FORMAT_TIME, &new_off)) {
/* time -> out-sample */
new_off = new_off * audioscale->gst_resample->o_rate / GST_SECOND;
} else if (gst_event_discont_get_value (e,
GST_FORMAT_DEFAULT, &new_off)) {
/* in-sample -> out-sample */
new_off *= audioscale->gst_resample->o_rate;
new_off /= audioscale->gst_resample->i_rate;
} else if (gst_event_discont_get_value (e, GST_FORMAT_BYTES, &new_off)) {
new_off /= audioscale->gst_resample->channels;
new_off /=
(audioscale->gst_resample->format == GST_RESAMPLE_S16) ? 2 : 4;
new_off *= audioscale->gst_resample->o_rate;
new_off /= audioscale->gst_resample->i_rate;
} else {
/* *sigh* */
new_off = 0;
}
audioscale->gst_resample_offset = new_off;
/* fall-through */
}
default:
gst_pad_event_default (pad, e);
break;
}
return;
} else if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
/* update time for out-sample */
audioscale->gst_resample_offset = GST_BUFFER_TIMESTAMP (buf) *
audioscale->gst_resample->o_rate / GST_SECOND;
}
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);