diff --git a/ChangeLog b/ChangeLog index 17bbeae02f..1241c74ae0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,22 @@ +2007-08-24 Jan Schmidt + + * ext/alsa/Makefile.am: + There is no GST_PLUGINS_BASE_LIBS defined. + + * ext/alsa/gstalsa.c: + * ext/alsa/gstalsasink.c: (gst_alsasink_delay): + * ext/alsa/gstalsasrc.c: (gst_alsasrc_delay): + Add support for ALSA 24-bit formats. + snd_pcm_delay can return an error code, especially + during XRUNS. In that case, the best we can do is assume + delay = 0. + + * gst/audioconvert/Makefile.am: + Add flags from -base before any more-remote dependencies. + 2007-08-23 Sebastian Dröge - Based on a patch by: Davyd + Based on a patch by: Davyd Madeley * gst/volume/gstvolume.c: (volume_choose_func), (volume_update_real_volume), (gst_volume_set_volume), diff --git a/ext/alsa/Makefile.am b/ext/alsa/Makefile.am index db633f7f63..1b87fe930b 100644 --- a/ext/alsa/Makefile.am +++ b/ext/alsa/Makefile.am @@ -17,7 +17,6 @@ libgstalsa_la_CFLAGS = \ $(GST_CFLAGS) \ $(ALSA_CFLAGS) libgstalsa_la_LIBADD = \ - $(GST_PLUGINS_BASE_LIBS) \ $(top_builddir)/gst-libs/gst/interfaces/libgstinterfaces-$(GST_MAJORMINOR).la \ $(top_builddir)/gst-libs/gst/audio/libgstaudio-$(GST_MAJORMINOR).la \ $(GST_BASE_LIBS) \ diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index 5d7f1ef831..d33fd8d9e5 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -84,14 +84,21 @@ max_rate_err: static const struct { + const int width; + const int depth; const int sformat; const int uformat; -} pcmformats[4] = { +} pcmformats[] = { { - SND_PCM_FORMAT_S8, SND_PCM_FORMAT_U8}, { - SND_PCM_FORMAT_S16, SND_PCM_FORMAT_U16}, { - SND_PCM_FORMAT_UNKNOWN, SND_PCM_FORMAT_UNKNOWN}, { - SND_PCM_FORMAT_S32, SND_PCM_FORMAT_U32} + 8, 8, SND_PCM_FORMAT_S8, SND_PCM_FORMAT_U8}, { + 16, 16, SND_PCM_FORMAT_S16, SND_PCM_FORMAT_U16}, { + 32, 24, SND_PCM_FORMAT_S24, SND_PCM_FORMAT_U24}, { +#if (G_BYTE_ORDER == G_LITTLE_ENDIAN) /* no endian-unspecific enum available */ + 24, 24, SND_PCM_FORMAT_S24_3LE, SND_PCM_FORMAT_U24_3LE}, { +#else +24, 24, SND_PCM_FORMAT_S24_3BE, SND_PCM_FORMAT_U24_3BE},} +#endif +32, 32, SND_PCM_FORMAT_S32, SND_PCM_FORMAT_U32} }; static GstCaps * @@ -110,16 +117,24 @@ gst_alsa_detect_formats (GstObject * obj, snd_pcm_hw_params_t * hw_params, for (i = 0; i < gst_caps_get_size (in_caps); ++i) { GstStructure *scopy; - gint w, width = 0; + gint w, width = 0, depth = 0; s = gst_caps_get_structure (in_caps, i); if (!gst_structure_has_name (s, "audio/x-raw-int")) { GST_WARNING_OBJECT (obj, "skipping non-int format"); continue; } - gst_structure_get_int (s, "width", &width); - g_assert (width != 0 && (width % 8) == 0); - w = (width / 8) - 1; + if (!gst_structure_get_int (s, "width", &width) || + !gst_structure_get_int (s, "depth", &depth)) + continue; + if (width == 0 || (width % 8) != 0) + continue; /* Only full byte widths are valid */ + for (w = 0; w < G_N_ELEMENTS (pcmformats); w++) + if (pcmformats[w].width == width && pcmformats[w].depth == depth) + break; + if (w == G_N_ELEMENTS (pcmformats)) + continue; /* Unknown format */ + if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat) && snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) { /* template contains { true, false } or just one, leave it as it is */ diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c index 0329d4f115..42537342d6 100644 --- a/ext/alsa/gstalsasink.c +++ b/ext/alsa/gstalsasink.c @@ -122,6 +122,18 @@ static GstStaticPadTemplate alsasink_sink_factory = "audio/x-raw-int, " "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, " "signed = (boolean) { TRUE, FALSE }, " + "width = (int) 24, " + "depth = (int) 24, " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " + "audio/x-raw-int, " + "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, " + "signed = (boolean) { TRUE, FALSE }, " + "width = (int) 32, " + "depth = (int) 24, " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " + "audio/x-raw-int, " + "endianness = (int) { " ALSA_SINK_FACTORY_ENDIANNESS " }, " + "signed = (boolean) { TRUE, FALSE }, " "width = (int) 16, " "depth = (int) 16, " "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " @@ -815,10 +827,15 @@ gst_alsasink_delay (GstAudioSink * asink) { GstAlsaSink *alsa; snd_pcm_sframes_t delay; + int res; alsa = GST_ALSA_SINK (asink); - snd_pcm_delay (alsa->handle, &delay); + res = snd_pcm_delay (alsa->handle, &delay); + if (G_UNLIKELY (res < 0)) { + GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res); + delay = 0; + } return delay; } diff --git a/ext/alsa/gstalsasrc.c b/ext/alsa/gstalsasrc.c index 7c197b3de4..23204161a6 100644 --- a/ext/alsa/gstalsasrc.c +++ b/ext/alsa/gstalsasrc.c @@ -122,6 +122,18 @@ static GstStaticPadTemplate alsasrc_src_factory = "audio/x-raw-int, " "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, " "signed = (boolean) { TRUE, FALSE }, " + "width = (int) 32, " + "depth = (int) 24, " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " + "audio/x-raw-int, " + "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, " + "signed = (boolean) { TRUE, FALSE }, " + "width = (int) 24, " + "depth = (int) 24, " + "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " + "audio/x-raw-int, " + "endianness = (int) { " ALSA_SRC_FACTORY_ENDIANNESS " }, " + "signed = (boolean) { TRUE, FALSE }, " "width = (int) 16, " "depth = (int) 16, " "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, MAX ]; " @@ -792,10 +804,15 @@ gst_alsasrc_delay (GstAudioSrc * asrc) { GstAlsaSrc *alsa; snd_pcm_sframes_t delay; + int res; alsa = GST_ALSA_SRC (asrc); - snd_pcm_delay (alsa->handle, &delay); + res = snd_pcm_delay (alsa->handle, &delay); + if (G_UNLIKELY (res < 0)) { + GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res); + delay = 0; + } return CLAMP (delay, 0, alsa->buffer_size); } diff --git a/gst/audioconvert/Makefile.am b/gst/audioconvert/Makefile.am index 7410a808bb..d4107171b5 100644 --- a/gst/audioconvert/Makefile.am +++ b/gst/audioconvert/Makefile.am @@ -11,7 +11,7 @@ libgstaudioconvert_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(G libgstaudioconvert_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstaudioconvert_la_LIBADD = \ $(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \ - $(GST_LIBS) $(GST_BASE_LIBS) + $(GST_BASE_LIBS) $(GST_LIBS) noinst_HEADERS = \ gstaudioconvert.h \