[vlc-commits] coreaudio: fix fmt in au_Initialize

Thomas Guillem git at videolan.org
Fri Mar 3 18:47:42 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar  3 18:44:38 2017 +0100| [a457d7b20d1bfc43d310d652225aa66218461e8d] | committer: Thomas Guillem

coreaudio: fix fmt in au_Initialize

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a457d7b20d1bfc43d310d652225aa66218461e8d
---

 modules/audio_output/audiounit_ios.m    |  8 --------
 modules/audio_output/auhal.c            |  1 -
 modules/audio_output/coreaudio_common.c | 13 ++++++++++---
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index 5884e1a..1c5725d 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -402,15 +402,7 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
         if (p_sys->au_dev != AU_DEV_ENCODED
          || (port_type != PORT_TYPE_USB && port_type != PORT_TYPE_HDMI))
             goto error;
-
-        fmt->i_format = VLC_CODEC_SPDIFL;
-        fmt->i_bytes_per_frame = 4;
-        fmt->i_frame_length = 1;
-        free(layout);
-        layout = NULL;
     }
-    else
-        fmt->i_format = VLC_CODEC_FL32;
 
     p_sys->au_unit = au_NewOutputInstance(p_aout, kAudioUnitSubType_RemoteIO);
     if (p_sys->au_unit == NULL)
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 7451e6e..3adfdce 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -999,7 +999,6 @@ StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt,
                    "kAudioDevicePropertyPreferredChannelLayout - using stereo");
 
     /* Do the last VLC aout setups */
-    fmt->i_format = VLC_CODEC_FL32;
     int ret = au_Initialize(p_aout, p_sys->au_unit, fmt, layout, i_latency_us);
     if (ret != VLC_SUCCESS)
         goto error;
diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index e3e205a..406c30d 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -631,8 +631,10 @@ au_Initialize(audio_output_t *p_aout, AudioUnit au, audio_sample_format_t *fmt,
 
     /* Set the desired format */
     AudioStreamBasicDescription desc;
-    if (fmt->i_format == VLC_CODEC_FL32)
+    if (aout_BitsPerSample(fmt->i_format) != 0)
     {
+        /* PCM */
+        fmt->i_format = VLC_CODEC_FL32;
         ret = MapOutputLayout(p_aout, fmt, outlayout);
         if (ret != VLC_SUCCESS)
             return ret;
@@ -645,10 +647,12 @@ au_Initialize(audio_output_t *p_aout, AudioUnit au, audio_sample_format_t *fmt,
         desc.mChannelsPerFrame = aout_FormatNbChannels(fmt);
         desc.mBitsPerChannel = 32;
     }
-    else
+    else if (AOUT_FMT_SPDIF(fmt))
     {
         /* Passthrough */
-        assert(fmt->i_format == VLC_CODEC_SPDIFL);
+        fmt->i_format = VLC_CODEC_SPDIFL;
+        fmt->i_bytes_per_frame = 4;
+        fmt->i_frame_length = 1;
 
         inlayout_tag = kAudioChannelLayoutTag_Stereo;
 
@@ -657,6 +661,9 @@ au_Initialize(audio_output_t *p_aout, AudioUnit au, audio_sample_format_t *fmt,
         desc.mChannelsPerFrame = 2;
         desc.mBitsPerChannel = 16;
     }
+    else
+        return VLC_EGENERIC;
+
     desc.mSampleRate = fmt->i_rate;
     desc.mFormatID = kAudioFormatLinearPCM;
     desc.mFramesPerPacket = 1;



More information about the vlc-commits mailing list