Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slouken committed Oct 1, 2018
1 parent 0a7faa4 commit b251876
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 2 additions & 1 deletion include/SDL_audio.h
Expand Up @@ -140,7 +140,8 @@ typedef Uint16 SDL_AudioFormat;
#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001
#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002
#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004
#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0x00000008
#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)
/* @} */

/* @} *//* Audio flags */
Expand Down
13 changes: 5 additions & 8 deletions src/audio/SDL_audio.c
Expand Up @@ -1324,15 +1324,12 @@ open_audio_device(const char *devname, int iscapture,
build_stream = SDL_TRUE;
}
}

/* !!! FIXME in 2.1: add SDL_AUDIO_ALLOW_SAMPLES_CHANGE flag?
As of 2.0.6, we will build a stream to buffer the difference between
what the app wants to feed and the device wants to eat, so everyone
gets their way. In prior releases, SDL would force the callback to
feed at the rate the device requested, adjusted for resampling.
*/
if (device->spec.samples != obtained->samples) {
build_stream = SDL_TRUE;
if (allowed_changes & SDL_AUDIO_ALLOW_SAMPLES_CHANGE) {
obtained->samples = device->spec.samples;
} else {
build_stream = SDL_TRUE;
}
}

SDL_CalculateAudioSpec(obtained); /* recalc after possible changes. */
Expand Down

0 comments on commit b251876

Please sign in to comment.