summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2010-03-30 11:43:04 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-05-11 19:02:55 +0100
commit59120a02224c92fdab7ff187793841a2e9d90019 (patch)
tree8b7ea2ad6a8653ebf01519ab00c861f5f7960781 /sys
parent3b1347260f58590caf5713a57a65e2db977aee17 (diff)
oss4: also accept formats not natively supported
Also accept formats that are not natively supported by the hardware, OSS4 can convert them internally. List the native formats first in the caps though, to express our preference for the native formats. We need this in order to support the case properly where the audio hardware supports only e.g. little endian PCM, but the host is big endian, since many audio elements only support native endianness and make the reasonable assumption that any audiosink will be able to handle audio in native endianness. Based on patch by Jerry Tan <jerry.tan@sun.com> Fixes #614317.
Diffstat (limited to 'sys')
-rw-r--r--sys/oss4/oss4-audio.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/oss4/oss4-audio.c b/sys/oss4/oss4-audio.c
index 297ea7ff3..45a1ecc62 100644
--- a/sys/oss4/oss4-audio.c
+++ b/sys/oss4/oss4-audio.c
@@ -73,6 +73,16 @@ static const struct
GST_U8, AFMT_U8, "audio/x-raw-int", 8, 8, 0, FALSE}
};
+/* formats we assume the OSS4 layer can always handle and convert internally */
+#define CONVERTIBLE_FORMATS ( \
+ AFMT_MU_LAW | AFMT_A_LAW | \
+ AFMT_S32_LE | AFMT_S32_BE | \
+ AFMT_S24_LE | AFMT_S24_BE | \
+ AFMT_S24_PACKED | \
+ AFMT_S16_LE | AFMT_S16_BE | \
+ AFMT_U16_LE | AFMT_U16_BE | \
+ AFMT_S8 | AFMT_U8 )
+
static gboolean
gst_oss4_append_format_to_caps (gint fmt, GstCaps * caps)
{
@@ -411,6 +421,7 @@ gst_oss4_audio_probe_caps (GstObject * obj, int fd)
oss_audioinfo ai = { 0, };
gboolean output;
GstCaps *caps;
+ int nonnative_formats = 0;
int formats, i;
output = GST_IS_OSS4_SINK (obj);
@@ -427,9 +438,22 @@ gst_oss4_audio_probe_caps (GstObject * obj, int fd)
caps = gst_caps_new_empty ();
+ /* first list all the formats natively supported */
for (i = 0; i < G_N_ELEMENTS (fmt_map); ++i) {
if ((formats & fmt_map[i].oss_fmt)) {
gst_oss4_append_format_to_caps (fmt_map[i].oss_fmt, caps);
+ } else if ((fmt_map[i].oss_fmt & CONVERTIBLE_FORMATS)) {
+ nonnative_formats |= fmt_map[i].oss_fmt;
+ }
+ }
+
+ GST_LOG_OBJECT (obj, "adding non-native %s formats : 0x%08x",
+ (output) ? "out" : "in", nonnative_formats);
+
+ /* now append non-native formats for which conversion would be needed */
+ for (i = 0; i < G_N_ELEMENTS (fmt_map); ++i) {
+ if ((nonnative_formats & fmt_map[i].oss_fmt)) {
+ gst_oss4_append_format_to_caps (fmt_map[i].oss_fmt, caps);
}
}