From 1a69ec3fd31dfeb4ba0abd52557c15eaa3fd19b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 18 Oct 2012 00:39:42 +0100 Subject: [PATCH] alsa: if no formats in native endianness could be detected, try non-native endianness as well This can happen, e.g. when using an USB sound card on a big-endian device https://bugzilla.gnome.org/show_bug.cgi?id=680904 --- ext/alsa/gstalsa.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index a6fc0c8bc5..13b0fae6ae 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -497,10 +497,20 @@ gst_alsa_probe_supported_formats (GstObject * obj, gchar * device, stream_type = snd_pcm_stream (handle); - caps = gst_caps_copy (template_caps); + caps = gst_alsa_detect_formats (obj, hw_params, + gst_caps_copy (template_caps), G_BYTE_ORDER); - if (!(caps = gst_alsa_detect_formats (obj, hw_params, caps, G_BYTE_ORDER))) - goto subroutine_error; + /* if there are no formats in native endianness, try non-native as well */ + if (caps == NULL) { + GST_INFO_OBJECT (obj, "no formats in native endianness detected"); + + caps = gst_alsa_detect_formats (obj, hw_params, + gst_caps_copy (template_caps), + (G_BYTE_ORDER == G_LITTLE_ENDIAN) ? G_BIG_ENDIAN : G_LITTLE_ENDIAN); + + if (caps == NULL) + goto subroutine_error; + } if (!(caps = gst_alsa_detect_rates (obj, hw_params, caps))) goto subroutine_error; @@ -533,7 +543,7 @@ subroutine_error: { GST_ERROR_OBJECT (obj, "failed to query formats"); snd_pcm_hw_params_free (hw_params); - gst_caps_unref (caps); + gst_caps_replace (&caps, NULL); return NULL; } }