summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2005-08-10 12:12:31 +0000
committerTim-Philipp Müller <tim@centricular.net>2005-08-10 12:12:31 +0000
commita0074faed3276544260eaa9c9428d02c6384080d (patch)
tree524803b73b383829d7e151cff534f3691fd2451a
parentbd57e8657c7c5c1bd7e0e61cd22d4237ca4a4c45 (diff)
gst/wavparse/gstwavparse.c: Add some fixes from 0.8 branch: allow 24/32bps songs and blockalign samples to the header...
Original commit message from CVS: * gst/wavparse/gstwavparse.c: (gst_wavparse_stream_headers), (gst_wavparse_stream_data): Add some fixes from 0.8 branch: allow 24/32bps songs and blockalign samples to the header-specified size, if any (#311070); error out on channels==0 or bitrate==0 (#309043, #304588).
-rw-r--r--ChangeLog9
-rw-r--r--gst/wavparse/gstwavparse.c24
2 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 874cf995..89725a1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-08-10 Tim-Philipp Müller <tim at centricular dot net>
+
+ * gst/wavparse/gstwavparse.c: (gst_wavparse_stream_headers),
+ (gst_wavparse_stream_data):
+ Add some fixes from 0.8 branch: allow 24/32bps songs and
+ blockalign samples to the header-specified size, if any
+ (#311070); error out on channels==0 or bitrate==0
+ (#309043, #304588).
+
2005-08-10 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/level/gstlevel.c: (gst_level_init), (gst_level_set_caps),
diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c
index 18012c4a..9763c076 100644
--- a/gst/wavparse/gstwavparse.c
+++ b/gst/wavparse/gstwavparse.c
@@ -69,8 +69,8 @@ static GstStaticPadTemplate src_template_factory =
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) little_endian, "
"signed = (boolean) { true, false }, "
- "width = (int) { 8, 16 }, "
- "depth = (int) { 8, 16 }, "
+ "width = (int) { 8, 16, 24, 32 }, "
+ "depth = (int) { 8, 16, 24, 32 }, "
"rate = (int) [ 8000, 48000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/mpeg, "
@@ -750,6 +750,8 @@ gst_wavparse_stream_headers (GstWavParse * wav)
return GST_FLOW_ERROR;
}
+ /* Note: gst_riff_create_audio_caps might nedd to fix values in
+ * the header header depending on the format, so call it first */
caps =
gst_riff_create_audio_caps (header->format, NULL, header, NULL,
NULL, NULL);
@@ -757,10 +759,22 @@ gst_wavparse_stream_headers (GstWavParse * wav)
wav->format = header->format;
wav->rate = header->rate;
wav->channels = header->channels;
+ if (wav->channels == 0) {
+ GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
+ ("Stream claims to contain no channels - invalid data"));
+ g_free (header);
+ return GST_FLOW_ERROR;
+ }
wav->blockalign = header->blockalign;
wav->width = (header->blockalign * 8) / header->channels;
wav->depth = header->size;
wav->bps = header->av_bps;
+ if (wav->bps <= 0) {
+ GST_ELEMENT_ERROR (wav, STREAM, FAILED, (NULL),
+ ("Stream claims to have a bitrate of <= zero - invalid data"));
+ g_free (header);
+ return GST_FLOW_ERROR;
+ }
g_free (header);
@@ -774,7 +788,9 @@ gst_wavparse_stream_headers (GstWavParse * wav)
gst_element_no_more_pads (GST_ELEMENT (wav));
GST_DEBUG ("frequency %d, channels %d", wav->rate, wav->channels);
} else {
- GST_ELEMENT_ERROR (wav, STREAM, TYPE_NOT_FOUND, (NULL), (NULL));
+ GST_ELEMENT_ERROR (wav, STREAM, TYPE_NOT_FOUND, (NULL),
+ ("No caps found for format 0x%x, %d channels, %d Hz",
+ wav->format, wav->channels, wav->rate));
return GST_FLOW_ERROR;
}
@@ -843,6 +859,8 @@ gst_wavparse_stream_data (GstWavParse * wav)
GST_DEBUG ("offset : %lld , dataleft : %lld", wav->offset, wav->dataleft);
desired = MIN (wav->dataleft, MAX_BUFFER_SIZE);
+ if (desired >= wav->blockalign && wav->blockalign > 0)
+ desired -= (desired % wav->blockalign);
GST_DEBUG ("Fetching %lld bytes of data from the sinkpad.", desired);
if ((res = gst_pad_pull_range (wav->sinkpad, wav->offset,
desired, &buf)) != GST_FLOW_OK) {