mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
wavparse fixups
Original commit message from CVS: wavparse fixups
This commit is contained in:
parent
b1bb03e1a8
commit
22c7be80df
2 changed files with 18 additions and 1 deletions
|
@ -192,6 +192,10 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf)
|
|||
/* I suppose we could signal an EOF at this point, but that may be
|
||||
premature. We've stopped data flow, that's the main thing. */
|
||||
}
|
||||
|
||||
GST_BUFFER_TIMESTAMP (buf) = wavparse->offset * GST_SECOND / wavparse->rate;
|
||||
wavparse->offset += GST_BUFFER_SIZE (buf) * 8 / wavparse->width / wavparse->channels;
|
||||
|
||||
gst_pad_push (wavparse->srcpad, buf);
|
||||
return;
|
||||
}
|
||||
|
@ -271,9 +275,16 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf)
|
|||
"channels", GST_PROPS_INT (format->wChannels)
|
||||
);
|
||||
|
||||
gst_pad_try_set_caps (wavparse->srcpad, caps);
|
||||
if (!gst_pad_try_set_caps (wavparse->srcpad, caps)) {
|
||||
gst_element_error (GST_ELEMENT (wavparse), "Could not set caps");
|
||||
return;
|
||||
}
|
||||
|
||||
wavparse->bps = format->wBlockAlign;
|
||||
wavparse->rate = format->dwSamplesPerSec;
|
||||
wavparse->channels = format->wChannels;
|
||||
wavparse->width = format->wBitsPerSample;
|
||||
|
||||
GST_DEBUG (0, "frequency %d, channels %d",
|
||||
format->dwSamplesPerSec, format->wChannels);
|
||||
|
||||
|
@ -316,6 +327,8 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf)
|
|||
newbuf = gst_buffer_new ();
|
||||
GST_BUFFER_DATA (newbuf) = g_malloc (subsize);
|
||||
GST_BUFFER_SIZE (newbuf) = subsize;
|
||||
GST_BUFFER_TIMESTAMP (newbuf) = wavparse->offset * GST_SECOND / wavparse->rate;
|
||||
wavparse->offset += subsize * 8 / wavparse->width / wavparse->channels;
|
||||
|
||||
memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (buf) + datachunk->offset, subsize);
|
||||
|
||||
|
|
|
@ -71,7 +71,11 @@ struct _GstWavParse {
|
|||
|
||||
/* useful audio data */
|
||||
gint bps;
|
||||
gint rate;
|
||||
gint channels;
|
||||
gint width;
|
||||
|
||||
gint64 offset;
|
||||
};
|
||||
|
||||
struct _GstWavParseClass {
|
||||
|
|
Loading…
Reference in a new issue