From 2434f2932bd02b627f4498534531c218ead1d102 Mon Sep 17 00:00:00 2001 From: Andoni Morales Alastruey Date: Tue, 15 May 2012 19:21:15 +0200 Subject: [PATCH] alsasink: check for spdif support only in the current device --- ext/alsa/gstalsa.c | 11 ++++++----- ext/alsa/gstalsa.h | 3 ++- ext/alsa/gstalsasink.c | 8 ++++---- ext/alsa/gstalsasrc.c | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index c1529af9e8..e1aed95f77 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -398,7 +398,7 @@ max_chan_error: } snd_pcm_t * -gst_alsa_open_iec958_pcm (GstObject * obj) +gst_alsa_open_iec958_pcm (GstObject * obj, gchar * device) { char *iec958_pcm_name = NULL; snd_pcm_t *pcm = NULL; @@ -417,7 +417,8 @@ gst_alsa_open_iec958_pcm (GstObject * obj) * spdif:{AES0 0x2 AES1 0x82 AES2 0x0 AES3 0x2} */ sprintf (devstr, - "iec958:{AES0 0x%02x AES1 0x%02x AES2 0x%02x AES3 0x%02x}", + "%s:{AES0 0x%02x AES1 0x%02x AES2 0x%02x AES3 0x%02x}", + device, IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO, IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER, 0, IEC958_AES3_CON_FS_48000); @@ -445,8 +446,8 @@ gst_alsa_open_iec958_pcm (GstObject * obj) */ GstCaps * -gst_alsa_probe_supported_formats (GstObject * obj, snd_pcm_t * handle, - const GstCaps * template_caps) +gst_alsa_probe_supported_formats (GstObject * obj, gchar * device, + snd_pcm_t * handle, const GstCaps * template_caps) { snd_pcm_hw_params_t *hw_params; snd_pcm_stream_t stream_type; @@ -473,7 +474,7 @@ gst_alsa_probe_supported_formats (GstObject * obj, snd_pcm_t * handle, /* Try opening IEC958 device to see if we can support that format (playback * only for now but we could add SPDIF capture later) */ if (stream_type == SND_PCM_STREAM_PLAYBACK) { - snd_pcm_t *pcm = gst_alsa_open_iec958_pcm (obj); + snd_pcm_t *pcm = gst_alsa_open_iec958_pcm (obj, device); if (G_LIKELY (pcm)) { gst_caps_append (caps, gst_caps_from_string (PASSTHROUGH_CAPS)); diff --git a/ext/alsa/gstalsa.h b/ext/alsa/gstalsa.h index 3f4aa87929..ff8791bca7 100644 --- a/ext/alsa/gstalsa.h +++ b/ext/alsa/gstalsa.h @@ -51,9 +51,10 @@ GST_DEBUG_CATEGORY_EXTERN (alsa_debug); #define GST_CAT_DEFAULT alsa_debug -snd_pcm_t * gst_alsa_open_iec958_pcm (GstObject * obj); +snd_pcm_t * gst_alsa_open_iec958_pcm (GstObject * obj, gchar *device); GstCaps * gst_alsa_probe_supported_formats (GstObject * obj, + gchar * device, snd_pcm_t * handle, const GstCaps * template_caps); diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index 97fd6b5031..8fb78913ea 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -300,8 +300,8 @@ gst_alsasink_getcaps (GstBaseSink * bsink, GstCaps * filter) g_return_val_if_fail (pad_template != NULL, NULL); templ_caps = gst_pad_template_get_caps (pad_template); - caps = gst_alsa_probe_supported_formats (GST_OBJECT (sink), sink->handle, - templ_caps); + caps = gst_alsa_probe_supported_formats (GST_OBJECT (sink), sink->device, + sink->handle, templ_caps); gst_caps_unref (templ_caps); if (caps) { @@ -852,9 +852,9 @@ gst_alsasink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec) alsa = GST_ALSA_SINK (asink); - if (spec->type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IEC958) { + if (alsa->iec958) { snd_pcm_close (alsa->handle); - alsa->handle = gst_alsa_open_iec958_pcm (GST_OBJECT (alsa)); + alsa->handle = gst_alsa_open_iec958_pcm (GST_OBJECT (alsa), alsa->device); if (G_UNLIKELY (!alsa->handle)) { goto no_iec958; } diff --git a/ext/alsa/gstalsasrc.c b/ext/alsa/gstalsasrc.c index 20e6e15e81..55eaedca98 100644 --- a/ext/alsa/gstalsasrc.c +++ b/ext/alsa/gstalsasrc.c @@ -267,8 +267,8 @@ gst_alsasrc_getcaps (GstBaseSrc * bsrc, GstCaps * filter) templ_caps = gst_pad_template_get_caps (pad_template); GST_INFO_OBJECT (src, "template caps %" GST_PTR_FORMAT, templ_caps); - caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), src->handle, - templ_caps); + caps = gst_alsa_probe_supported_formats (GST_OBJECT (src), + src->device, src->handle, templ_caps); gst_caps_unref (templ_caps); if (caps) {