[vlc-devel] [PATCH] amem: Added FL32 support to amem

Matthias Schaff mschaff at inovex.de
Fri Jun 10 14:39:50 CEST 2016


From: Matthias Schaff <matthias.schaff at inovex.de>

---
 modules/audio_output/amem.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/modules/audio_output/amem.c b/modules/audio_output/amem.c
index 9e9ece6..fff761e 100644
--- a/modules/audio_output/amem.c
+++ b/modules/audio_output/amem.c
@@ -160,39 +160,56 @@ static void Stop (audio_output_t *aout)
 static int Start (audio_output_t *aout, audio_sample_format_t *fmt)
 {
     aout_sys_t *sys = aout->sys;
-    char format[5] = "S16N";
     unsigned channels;
-
+    char * format;
+    format = var_InheritString(aout, "amem-format");
+    int i_format = 0;
+    if(!strcmp(format, "S16N"))
+    {
+        i_format = VLC_CODEC_S16N;
+    }
+    else if (!strcmp(format, "FL32"))
+    {
+        i_format = VLC_CODEC_FL32;
+    } else
+    {
+        msg_Warn(aout, "Audio format invalid: %s, amem only supports FL32 and S16N, using default: S16N", format);
+        i_format = VLC_CODEC_S16N;
+        strcpy(format, "S16N");
+    }
     if (sys->setup != NULL)
     {
         channels = aout_FormatNbChannels(fmt);
-
         sys->opaque = sys->setup_opaque;
-        if (sys->setup (&sys->opaque, format, &fmt->i_rate, &channels))
+        if (sys->setup (&sys->opaque, format, &fmt->i_rate, &channels) != 0)
+        {
+            msg_Err(aout, "Audio format setup failure (audio playback skipped)");
             return VLC_EGENERIC;
+        }
     }
     else
     {
         fmt->i_rate = sys->rate;
         channels = sys->channels;
     }
+    fmt->i_format = i_format;
 
     /* Initialize volume (in case the UI changed volume before setup) */
     sys->ready = true;
     if (sys->set_volume != NULL)
         sys->set_volume(sys->opaque, sys->volume, sys->mute);
 
-    /* Ensure that format is supported */
-    if (fmt->i_rate == 0 || fmt->i_rate > 192000
-     || channels == 0 || channels > AOUT_CHAN_MAX
-     || strcmp(format, "S16N") /* TODO: amem-format */)
+    /* Ensure that format is supported, regarding rate and channels */
+    if (fmt->i_rate == 0 || fmt->i_rate > 192000 
+     || channels == 0 || channels > AOUT_CHAN_MAX)
     {
         msg_Err (aout, "format not supported: %s, %u channel(s), %u Hz",
                  format, channels, fmt->i_rate);
         Stop (aout);
+        free(format);
         return VLC_EGENERIC;
     }
-
+    free(format);
     /* channel mapping */
     switch (channels)
     {
@@ -227,7 +244,6 @@ static int Start (audio_output_t *aout, audio_sample_format_t *fmt)
             vlc_assert_unreachable();
     }
 
-    fmt->i_format = VLC_CODEC_S16N;
     fmt->i_original_channels = fmt->i_physical_channels;
     return VLC_SUCCESS;
 }
-- 
1.9.1



More information about the vlc-devel mailing list