[vlc-devel] [PATCH] auhal: add the "auhal-buffer-frame-size" option

Thomas Guillem thomas at gllm.fr
Wed Jul 22 09:40:51 CEST 2020


Hello,

Indeed, you are right.

I would love to add a delay enum when the decoder is configuring the aout.

3 enums values:

 AOUT_DELAY_LOW: ambisonics, "--low-delay" input options (< 50ms)
 AOUT_DELAY_MEDIUM: when an interactive filter (equalizer, volume > 100) is inserted (around 200ms)
 AOUT_DELAY_HIGH: current behavior (maximum delay to save CPU cycles)

It can be also a bool low_delay, but I think it's interesting to have an intermediate setting. I'm thinking about restarting the aout stream with medium delay when an interactive audio filter is inserted. That way, the user can hear the difference when he is changing filters from the UI. (I'm thinking about a 200ms delay).


On Tue, Jul 21, 2020, at 17:53, Rémi Denis-Courmont wrote:
> Hi,
> 
> As far as I understand the link, it is the application's responsibility, not the user's, to set that value optimally.
> 
> Le 21 juillet 2020 17:01:25 GMT+03:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>> This option can be used to change the I/O buffer size.
>> 
>> cf. https://developer.apple.com/library/archive/technotes/tn2321/_index.html modules/audio_output/audiounit_ios.m    |  2 +-
>>  modules/audio_output/auhal.c            |  8 ++++++++
>>  modules/audio_output/coreaudio_common.c | 16 +++++++++++++++-
>>  modules/audio_output/coreaudio_common.h |  2 +-
>>  4 files changed, 25 insertions(+), 3 deletions(-)
>> 
>> diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
>> index e0547b514f0..6de6af0aec7 100644
>> --- a/modules/audio_output/audiounit_ios.m
>> +++ b/modules/audio_output/audiounit_ios.m
>> @@ -536,7 +536,7 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
>>          vlc_tick_from_sec([p_sys->avInstance outputLatency]);
>>      msg_Dbg(p_aout, "Current device has a latency of %lld us", latency_us);
>>  
>> -    ret = au_Initialize(p_aout, p_sys->au_unit, fmt, layout, latency_us, NULL);
>> +    ret = au_Initialize(p_aout, p_sys->au_unit, fmt, layout, latency_us, 0, NULL);
>>      if (ret != VLC_SUCCESS)
>>          goto error;
>>  
>> diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
>> index ab614c92a00..0bf3b2b809a 100644
>> --- a/modules/audio_output/auhal.c
>> +++ b/modules/audio_output/auhal.c
>> @@ -46,6 +46,10 @@
>>  #define DEVICE_TEXT N_("Last audio device")
>>  #define DEVICE_LONGTEXT DEVICE_TEXT
>>  
>> +#define BUFFER_FRAME_SIZE_TEXT "Auhal I/O buffer size in frames"
>> +#define BUFFER_FRAME_SIZE_LONGTEXT "A low value (16-32) reduces audio latency," \
>> +    "a higher value (> 1024) improves power consumption"
>> +
>>  static int      Open                    (vlc_object_t *);
>>  static void     Close                   (vlc_object_t *);
>>  
>> @@ -59,6 +63,8 @@ vlc_module_begin ()
>>      add_integer("auhal-volume", AOUT_VOLUME_DEFAULT,
>>                  VOLUME_TEXT, VOLUME_LONGTEXT, true)
>>      change_integer_range(0, AOUT_VOLUME_MAX)
>> +    add_integer("auhal-buffer-frame-size", 0 /* system default */,
>> +                BUFFER_FRAME_SIZE_TEXT, BUFFER_FRAME_SIZE_LONGTEXT, true)
>>      add_string("auhal-audio-device", "", DEVICE_TEXT, DEVICE_LONGTEXT, true)
>>      add_string("auhal-warned-devices", "", NULL, NULL, true)
>>      change_private()
>> @@ -1112,7 +1118,9 @@ StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt)
>>  
>>      /* Do the last VLC aout setups */
>>      bool warn_configuration;
>> +
>>      int ret = au_Initialize(p_aout, p_sys->au_unit, fmt, layout, 0,
>> +                            var_InheritInteger(p_aout, "auhal-buffer-frame-size"),
>>                              &warn_configuration);
>>      if (ret != VLC_SUCCESS)
>>          goto error;
>> diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
>> index 797c3e623d3..8d8be946edf 100644
>> --- a/modules/audio_output/coreaudio_common.c
>> +++ b/modules/audio_output/coreaudio_common.c
>> @@ -840,7 +840,7 @@ SetupInputLayout(audio_output_t *p_aout, const audio_sample_format_t *fmt,
>>  int
>>  au_Initialize(audio_output_t *p_aout, AudioUnit au, audio_sample_format_t *fmt,
>>                const AudioChannelLayout *outlayout, vlc_tick_t i_dev_latency_us,
>> -              bool *warn_configuration)
>> +              unsigned buffer_frame_size, bool *warn_configuration)
>>  {
>>      int ret;
>>      AudioChannelLayoutTag inlayout_tag;
>> @@ -938,6 +938,20 @@ au_Initialize(audio_output_t *p_aout, AudioUnit au, audio_sample_format_t *fmt,
>>          return VLC_EGENERIC;
>>      }
>>  
>> +    if (buffer_frame_size > 0)
>> +    {
>> +        UInt32 buffer_size = buffer_frame_size;
>> +        err = AudioUnitSetProperty(au, kAudioDevicePropertyBufferFrameSize,
>> +                                   kAudioUnitScope_Output, 0, &buffer_size,
>> +                                   sizeof(buffer_size));
>> +        if (err != noErr)
>> +        {
>> +            ca_LogErr("failed to setup buffer frame size");
>> +            return VLC_EGENERIC;
>> +        }
>> +    }
>> +
>> +
>>      /* AU init */
>>      err = AudioUnitInitialize(au);
>>  
>> diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
>> index 4bd61394937..272399689f8 100644
>> --- a/modules/audio_output/coreaudio_common.h
>> +++ b/modules/audio_output/coreaudio_common.h
>> @@ -111,6 +111,6 @@ AudioUnit au_NewOutputInstance(audio_output_t *p_aout, OSType comp_sub_type);
>>  int  au_Initialize(audio_output_t *p_aout, AudioUnit au,
>>                     audio_sample_format_t *fmt,
>>                     const AudioChannelLayout *outlayout, vlc_tick_t i_dev_latency_us,
>> -                   bool *warn_configuration);
>> +                   unsigned buffer_frame_size, bool *warn_configuration);
>>  
>>  void au_Uninitialize(audio_output_t *p_aout, AudioUnit au);
> 
> -- 
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté. 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200722/12773061/attachment.html>


More information about the vlc-devel mailing list