commit c6b28f46b8116552ec2b38d1d3c8535df28ba7a1
authorSam Lantinga <slouken@libsdl.org>
Mon, 01 Oct 2018 09:47:10 -0700
changeset 12272c68b05ca0761
parent 12271 44a639b5f1af
child 12273 c522b61334f1
commit c6b28f46b8116552ec2b38d1d3c8535df28ba7a1
Author: Anthony Pesch <inolen@gmail.com>
Date: Fri May 4 20:21:21 2018 -0400

Added SDL_AUDIO_ALLOW_SAMPLES_CHANGE flag enabling users of SDL_OpenAudioDevice to get
the sample size of the actual hardware buffer vs having a stream created to handle the
delta
include/SDL_audio.h
src/audio/SDL_audio.c
     1.1 --- a/include/SDL_audio.h	Fri May 04 21:58:39 2018 -0400
     1.2 +++ b/include/SDL_audio.h	Mon Oct 01 09:47:10 2018 -0700
     1.3 @@ -140,7 +140,8 @@
     1.4  #define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE    0x00000001
     1.5  #define SDL_AUDIO_ALLOW_FORMAT_CHANGE       0x00000002
     1.6  #define SDL_AUDIO_ALLOW_CHANNELS_CHANGE     0x00000004
     1.7 -#define SDL_AUDIO_ALLOW_ANY_CHANGE          (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
     1.8 +#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE      0x00000008
     1.9 +#define SDL_AUDIO_ALLOW_ANY_CHANGE          (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE)
    1.10  /* @} */
    1.11  
    1.12  /* @} *//* Audio flags */
     2.1 --- a/src/audio/SDL_audio.c	Fri May 04 21:58:39 2018 -0400
     2.2 +++ b/src/audio/SDL_audio.c	Mon Oct 01 09:47:10 2018 -0700
     2.3 @@ -1324,15 +1324,12 @@
     2.4              build_stream = SDL_TRUE;
     2.5          }
     2.6      }
     2.7 -
     2.8 -    /* !!! FIXME in 2.1: add SDL_AUDIO_ALLOW_SAMPLES_CHANGE flag?
     2.9 -       As of 2.0.6, we will build a stream to buffer the difference between
    2.10 -       what the app wants to feed and the device wants to eat, so everyone
    2.11 -       gets their way. In prior releases, SDL would force the callback to
    2.12 -       feed at the rate the device requested, adjusted for resampling.
    2.13 -     */
    2.14      if (device->spec.samples != obtained->samples) {
    2.15 -        build_stream = SDL_TRUE;
    2.16 +        if (allowed_changes & SDL_AUDIO_ALLOW_SAMPLES_CHANGE) {
    2.17 +            obtained->samples = device->spec.samples;
    2.18 +        } else {
    2.19 +            build_stream = SDL_TRUE;
    2.20 +        }
    2.21      }
    2.22  
    2.23      SDL_CalculateAudioSpec(obtained);  /* recalc after possible changes. */