diff --git a/docs/README-migration.md b/docs/README-migration.md index f073d94b0..6fea417ac 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -56,6 +56,30 @@ SDL_FreeWAV has been removed and calls can be replaced with SDL_free. SDL_AudioCVT interface is removed, SDL_AudioStream can be used instead. +Code that used to look like this: +```c + SDL_AudioCVT cvt; + SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq, spec.format, cvtchans, cvtfreq); + cvt.len = len; + cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult); + SDL_memcpy(cvt.buf, data, len); + SDL_ConvertAudio(&cvt); + do_something(cvt.buf, cvt.len_cvt); +``` +should be changed to: +```c + SDL_AudioStream *stream = SDL_CreateAudioStream(spec.format, spec.channels, spec.freq, spec.format, cvtchans, cvtfreq); + int src_samplesize = (SDL_AUDIO_BITSIZE(spec.format) / 8) * spec.channels; + int src_len = len & ~(src_samplesize - 1); // need to be rounded to samplesize + SDL_PutAudioStreamData(stream, data, src_len); + SDL_FlushAudioStream(stream); + int dst_len = expected_dst_len & ~(dst_samplesize - 1); // need to be rounded to samplesize + Uint8 *dst_buf = (Uint8 *)SDL_malloc(dst_len); + int real_dst_len = SDL_GetAudioStreamData(stream, dst_buf, dst_len); + do_something(dst_buf, real_dst_len); +``` + + The following functions have been renamed: * SDL_AudioStreamAvailable() => SDL_GetAudioStreamAvailable() * SDL_AudioStreamClear() => SDL_ClearAudioStream()