Explorar el Código

audio: more AudioStream allocation work.

This was only including the resampling buffer needs if it was larger
the other allocation needs, but it needs to be included unconditionally.

For safety's sake, we also make sure the pre-resample buffer doesn't risk
overflow, too, but this might not be necessary in practice.
Ryan C. Gordon hace 2 años
padre
commit
9facc86b6a
Se han modificado 1 ficheros con 2 adiciones y 5 borrados
  1. 2 5
      src/audio/SDL_audiocvt.c

+ 2 - 5
src/audio/SDL_audiocvt.c

@@ -801,7 +801,7 @@ static int CalculateAudioStreamWorkBufSize(const SDL_AudioStream *stream, int le
     if (stream->dst_rate != stream->src_rate) {
     if (stream->dst_rate != stream->src_rate) {
         /* calculate requested sample frames needed before resampling. Use a Uint64 so the multiplication doesn't overflow. */
         /* calculate requested sample frames needed before resampling. Use a Uint64 so the multiplication doesn't overflow. */
         const int input_frames = ((int) ((((Uint64) workbuf_frames) * stream->src_rate) / stream->dst_rate));
         const int input_frames = ((int) ((((Uint64) workbuf_frames) * stream->src_rate) / stream->dst_rate));
-        inputlen = input_frames * stream->src_sample_frame_size;
+        inputlen = input_frames * stream->max_sample_frame_size;
         if (inputlen > workbuflen) {
         if (inputlen > workbuflen) {
             workbuflen = inputlen;
             workbuflen = inputlen;
         }
         }
@@ -811,10 +811,7 @@ static int CalculateAudioStreamWorkBufSize(const SDL_AudioStream *stream, int le
             workbuflen = inputlen;
             workbuflen = inputlen;
         }
         }
         /* Calculate space needed after resample (which lives in a second copy in the same buffer). */
         /* Calculate space needed after resample (which lives in a second copy in the same buffer). */
-        inputlen += workbuf_frames * stream->pre_resample_channels * sizeof (float);
-        if (inputlen > workbuflen) {
-            workbuflen = inputlen;
-        }
+        workbuflen += workbuf_frames * stream->pre_resample_channels * sizeof (float);
     }
     }
 
 
     return workbuflen;
     return workbuflen;