Skip to content
  • Devarsh Thakkar's avatar
    ext: alsa: Fix fallback paths for setting buffer and period times · 297b1e68
    Devarsh Thakkar authored and GStreamer Marge Bot's avatar GStreamer Marge Bot committed
    Below fallback paths were introduced in
    https://github.com/GStreamer/gst-plugins-base/commit/9759810d8206b5f1aa199f98599caec3630a1813
    if setting period time after buffer time failed :
    1) Set period time and then buffer time if it doesn't work
    2) Set only buffer time
    3) Set only period time
    
    These all were not functioning properly since they were using old
    copy of snd_pcm_hw_params_t which already had some fields set
    as per previous try and this was causing issues as driver was
    referring to that old value while trying to set them again in
    fallback paths.
    
    So now we always use the initial copy of snd_pcm_hw_params_t
    for every fallback  and same is also being done at
    pulseaudio/pulseaudio@557c4295
    
    Also we change the sequence to set period time earlier than
    buffer time since period bytes being the smaller unit, most of the times
    if underlying alsa device has a dependency then it is of period bytes
    to be a multiple of some value (as per underlying DMA constraint)
    and rest of the parameters like buffer bytes need to be adjusted
    as per period bytes.
    
    The same sequence is also followed in alsa-utils at
    https://github.com/alsa-project/alsa-utils/commit/9b621eeac4d55c4e881f093be5b163ca07d01b63
    
    Fix 2) and 3) scenarios by returning success if the exclusive setting is passed
    and not doing any further setting for buffer time or period time.
    
    Add new fallback path of not setting any buffer time and period time
    if all above fallback paths fail. The same is also being
    followed at aforementioned pulseaudio commit.
    
    In case of alsasink, remove the retry goto label, since it is not
    required anymore as fallback paths take care of setting default
    values if driver is not accepting any of the fallback paths.
    
    Use separate label for exit to free params structs and return err
    code. This also fixes leak in no_rate goto path in alsasink
    
    Part-of: <gstreamer/gst-plugins-base!1212>
    297b1e68