summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2005-10-24 15:57:17 +0000
committerTim-Philipp Müller <tim@centricular.net>2005-10-24 15:57:17 +0000
commit0e01f91dc1e12f54c5e273d78a51eaf19b5234d2 (patch)
tree2f777cdd6b74cbaf5e7f76ec3bb88ec9fe7a2dca
parent2042e06dd4a55d941b6dcbdb0a4f2927f87475bb (diff)
sys/oss/gstosssrc.c: Set bytes_per_sample correctly (is not always 4, but depends on width and number of channels).
Original commit message from CVS: * sys/oss/gstosssrc.c: (gst_oss_src_prepare): Set bytes_per_sample correctly (is not always 4, but depends on width and number of channels).
-rw-r--r--ChangeLog6
-rw-r--r--sys/oss/gstosssrc.c14
2 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f35c016..0d60da63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2005-10-24 Tim-Philipp Müller <tim at centricular dot net>
+ * sys/oss/gstosssrc.c: (gst_oss_src_prepare):
+ Set bytes_per_sample correctly (is not always 4, but
+ depends on width and number of channels).
+
+2005-10-24 Tim-Philipp Müller <tim at centricular dot net>
+
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
diff --git a/sys/oss/gstosssrc.c b/sys/oss/gstosssrc.c
index 6c2f7008..bb5d7caa 100644
--- a/sys/oss/gstosssrc.c
+++ b/sys/oss/gstosssrc.c
@@ -389,8 +389,12 @@ gst_oss_src_prepare (GstAudioSrc * asrc, GstRingBufferSpec * spec)
spec->segsize = info.fragsize;
spec->segtotal = info.fragstotal;
- spec->bytes_per_sample = 4;
- oss->bytes_per_sample = 4;
+
+ if (spec->width != 16 && spec->width != 8)
+ goto dodgy_width;
+
+ spec->bytes_per_sample = (spec->width / 8) * spec->channels;
+ oss->bytes_per_sample = (spec->width / 8) * spec->channels;
memset (spec->silence_sample, 0, spec->bytes_per_sample);
GST_DEBUG ("got segsize: %d, segtotal: %d, value: %08x", spec->segsize,
@@ -411,6 +415,12 @@ wrong_format:
("Unable to get format %d", spec->format), (NULL));
return FALSE;
}
+dodgy_width:
+ {
+ GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ,
+ ("Unexpected width %d", spec->width), (NULL));
+ return FALSE;
+ }
}
static gboolean