src/audio/SDL_audiocvt.c
changeset 7037 3fedf1f25b94
parent 6885 700f1b25f77f
child 7191 75360622e65f
equal deleted inserted replaced
7036:8c891504e325 7037:3fedf1f25b94
   968      * !!! FIXME: good in practice as it sounds in theory, though.
   968      * !!! FIXME: good in practice as it sounds in theory, though.
   969      */
   969      */
   970 
   970 
   971     /* Sanity check target pointer */
   971     /* Sanity check target pointer */
   972     if (cvt == NULL) {
   972     if (cvt == NULL) {
   973         SDL_InvalidParamError("cvt");
   973         return SDL_InvalidParamError("cvt");
   974         return -1;
       
   975     }
   974     }
   976     
   975     
   977     /* there are no unsigned types over 16 bits, so catch this up front. */
   976     /* there are no unsigned types over 16 bits, so catch this up front. */
   978     if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
   977     if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
   979         SDL_SetError("Invalid source format");
   978         return SDL_SetError("Invalid source format");
   980         return -1;
       
   981     }
   979     }
   982     if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
   980     if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
   983         SDL_SetError("Invalid destination format");
   981         return SDL_SetError("Invalid destination format");
   984         return -1;
       
   985     }
   982     }
   986 
   983 
   987     /* prevent possible divisions by zero, etc. */
   984     /* prevent possible divisions by zero, etc. */
   988     if ((src_channels == 0) || (dst_channels == 0)) {
   985     if ((src_channels == 0) || (dst_channels == 0)) {
   989         SDL_SetError("Source or destination channels is zero");
   986         return SDL_SetError("Source or destination channels is zero");
   990         return -1;
       
   991     }
   987     }
   992     if ((src_rate == 0) || (dst_rate == 0)) {
   988     if ((src_rate == 0) || (dst_rate == 0)) {
   993         SDL_SetError("Source or destination rate is zero");
   989         return SDL_SetError("Source or destination rate is zero");
   994         return -1;
       
   995     }
   990     }
   996 #ifdef DEBUG_CONVERT
   991 #ifdef DEBUG_CONVERT
   997     printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
   992     printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
   998            src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
   993            src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
   999 #endif
   994 #endif