src/audio/SDL_audiocvt.c
changeset 11319 86b1fde471c6
parent 11128 9dda3f3e9794
child 11405 4e12f78c2b0e
     1.1 --- a/src/audio/SDL_audiocvt.c	Fri Aug 18 16:35:55 2017 -0400
     1.2 +++ b/src/audio/SDL_audiocvt.c	Fri Aug 18 16:52:19 2017 -0400
     1.3 @@ -22,6 +22,7 @@
     1.4  
     1.5  /* Functions for audio drivers to perform runtime conversion of audio format */
     1.6  
     1.7 +#include "SDL.h"
     1.8  #include "SDL_audio.h"
     1.9  #include "SDL_audio_c.h"
    1.10  
    1.11 @@ -555,7 +556,7 @@
    1.12          }
    1.13  
    1.14          if (!filter) {
    1.15 -            return SDL_SetError("No conversion available for these formats");
    1.16 +            return SDL_SetError("No conversion from source format to float available");
    1.17          }
    1.18  
    1.19          if (SDL_AddAudioCVTFilter(cvt, filter) < 0) {
    1.20 @@ -594,7 +595,7 @@
    1.21          }
    1.22  
    1.23          if (!filter) {
    1.24 -            return SDL_SetError("No conversion available for these formats");
    1.25 +            return SDL_SetError("No conversion from float to destination format available");
    1.26          }
    1.27  
    1.28          if (SDL_AddAudioCVTFilter(cvt, filter) < 0) {
    1.29 @@ -743,8 +744,8 @@
    1.30  
    1.31  
    1.32  /* Creates a set of audio filters to convert from one format to another.
    1.33 -   Returns -1 if the format conversion is not supported, 0 if there's
    1.34 -   no conversion needed, or 1 if the audio filter is set up.
    1.35 +   Returns 0 if no conversion is needed, 1 if the audio filter is set up,
    1.36 +   or -1 if an error like invalid parameter, unsupported format, etc. occurred.
    1.37  */
    1.38  
    1.39  int
    1.40 @@ -757,6 +758,11 @@
    1.41          return SDL_InvalidParamError("cvt");
    1.42      }
    1.43  
    1.44 +    /* Conversions from and to float require the audio subsystem to be initialized */
    1.45 +    if (!SDL_WasInit(SDL_INIT_AUDIO)) {
    1.46 +        return SDL_SetError("Audio subsystem has not been initialized");
    1.47 +    }
    1.48 +
    1.49      /* Make sure we zero out the audio conversion before error checking */
    1.50      SDL_zerop(cvt);
    1.51