Skip to content

Commit

Permalink
Fixed bug 3710 - SDL_OpenAudio(desired, obtained) doesn't update desi…
Browse files Browse the repository at this point in the history
…red's size when obtained is NULL

David Ludwig

I've created a new set of patches.  I am happy to create more, if it would help.

One version only copies 'size'.

A second version copies both 'size' and 'silence'.  When looking over the documentation for SDL_OpenAudio in SDL_audio.h, it mentioned that both 'size' and 'silence' were things that SDL_OpenAudio would calculate.

Regarding *both* patches, I did notice that SDL 1.2 appears to have always modified desired's size and silence fields.  The SDL wiki, at https://wiki.libsdl.org/SDL_OpenAudio#Remarks , does note:
  • Loading branch information
slouken committed Aug 28, 2017
1 parent 003d491 commit 8e7998e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/audio/SDL_audio.c
Expand Up @@ -1413,7 +1413,14 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
id = open_audio_device(NULL, 0, desired, obtained,
SDL_AUDIO_ALLOW_ANY_CHANGE, 1);
} else {
id = open_audio_device(NULL, 0, desired, NULL, 0, 1);
SDL_AudioSpec _obtained;
SDL_zero(_obtained);
id = open_audio_device(NULL, 0, desired, &_obtained, 0, 1);
/* On successful open, copy calculated values into 'desired'. */
if (id > 0) {
desired->size = _obtained.size;
desired->silence = _obtained.silence;
}
}

SDL_assert((id == 0) || (id == 1));
Expand Down

0 comments on commit 8e7998e

Please sign in to comment.