- // Decompress in the resampling_buffer to get STREAM_BUFFER_SIZE samples after resampling
-#if BYTE_ORDER == LITTLE_ENDIAN
- bigendian = 0;
-#else
+ // We add exactly 1 sec of sound to the buffer:
+ // 1- to ensure we won't lose any sample during the resampling process
+ // 2- to force one call to OGG_FetchSound per second to regulate the workload
+ if ((sfx->format.speed + sb->length) * factor > buff_len)
+ {
+ Con_Printf ("OGG_FetchSound: stream buffer overflow (%u bytes / %u)\n",
+ (sfx->format.speed + sb->length) * factor, buff_len);
+ return NULL;
+ }
+ newlength = per_sfx->format.speed * factor; // -> 1 sec of sound before resampling
+
+ // Decompress in the resampling_buffer
+#if BYTE_ORDER == BIG_ENDIAN