Fixed crash and garbled output when converting from F32 to S16 audio.
This commit is contained in:
parent
e2a14cf5dd
commit
5623b2c61d
1 changed files with 12 additions and 10 deletions
|
@ -360,9 +360,7 @@ SDL_RunAudio(void *devicep)
|
|||
device->convert.len_mult;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* stream_len = device->convert.len; */
|
||||
stream_len = device->spec.size;
|
||||
stream_len = device->convert.len;
|
||||
} else {
|
||||
stream_len = device->spec.size;
|
||||
}
|
||||
|
@ -958,12 +956,6 @@ open_audio_device(const char *devname, int iscapture,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* If the audio driver changes the buffer size, accept it */
|
||||
if (device->spec.samples != obtained->samples) {
|
||||
obtained->samples = device->spec.samples;
|
||||
SDL_CalculateAudioSpec(obtained);
|
||||
}
|
||||
|
||||
/* See if we need to do any conversion */
|
||||
build_cvt = SDL_FALSE;
|
||||
if (obtained->freq != device->spec.freq) {
|
||||
|
@ -987,6 +979,16 @@ open_audio_device(const char *devname, int iscapture,
|
|||
build_cvt = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the audio driver changes the buffer size, accept it.
|
||||
This needs to be done after the format is modified above,
|
||||
otherwise it might not have the correct buffer size.
|
||||
*/
|
||||
if (device->spec.samples != obtained->samples) {
|
||||
obtained->samples = device->spec.samples;
|
||||
SDL_CalculateAudioSpec(obtained);
|
||||
}
|
||||
|
||||
if (build_cvt) {
|
||||
/* Build an audio conversion block */
|
||||
if (SDL_BuildAudioCVT(&device->convert,
|
||||
|
@ -998,7 +1000,7 @@ open_audio_device(const char *devname, int iscapture,
|
|||
return 0;
|
||||
}
|
||||
if (device->convert.needed) {
|
||||
device->convert.len = (int) (((double) obtained->size) /
|
||||
device->convert.len = (int) (((double) device->spec.size) /
|
||||
device->convert.len_ratio);
|
||||
|
||||
device->convert.buf =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue