| Summary: | SDL_OpenAudio(desired, obtained) doesn't update desired's size when obtained is NULL | ||
|---|---|---|---|
| Product: | SDL | Reporter: | David Ludwig <dll> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | dll, ny00 |
| Version: | HG 2.0 | Keywords: | target-2.0.6 |
| Hardware: | All | ||
| OS: | Other | ||
| Attachments: |
fix #1 (rejected) for SDL Bug 3710
fix #2,A, adjust both 'size' and 'silence' fix #2,B, adjust only 'size' |
||
|
Description
David Ludwig
2017-07-23 19:01:48 UTC
Created attachment 2807 [details] fix #1 (rejected) for SDL Bug 3710 This change modifies SDL_OpenAudio(desired, obtained), if and when called with 'obtained == NULL', to record the SDL_AudioSpec changes to a temporary buffer, then, on successful creation of an audio device, copy those values back into 'desired'. (Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.) Tagging a bunch of bugs as target-2.0.6. This means we're in the final stretch for an official SDL 2.0.6 release! These are the bugs we really want to fix before shipping if humanly possible. That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.6 release, and generally be organized about what we're aiming to ship. After some debate, we might just remove this tag again and deal with it for a later release. Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment. Thanks! --ryan. This is the wrong fix. The actual behavior should be that the application should get called back with exactly what it requested and SDL should convert it to the correct format for output. If and when 'obtained' is NULL, should SDL modify the 'desired' field's 'size' parameter? For example:
SDL_AudioSpec want;
SDL_memset(&want, 0, sizeof(want));
want.freq = 48000;
want.format = AUDIO_F32;
want.channels = 2;
want.samples = 4096;
want.callback = MyAudioCallback;
if (SDL_OpenAudio(&want, NULL) != 0) {
exit(1);
}
//
// Assuming we get to this point in the code, should 'want.size' be zero, or non-zero?
// Currently, it'll be zero.
//
size is the only field that should be written, and it should be calculated from the other fields in the desired audio spec. 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: "This function remains for compatibility with SDL 1.2, but also because it's slightly easier to use than the new functions in SDL 2.0." Should SDL_OpenAudio, in SDL 2.x, always write size and/or silence field(s) in 'desired', regardless of whether 'obtained' is passed in? Created attachment 2874 [details]
fix #2,A, adjust both 'size' and 'silence'
Created attachment 2875 [details]
fix #2,B, adjust only 'size'
For reference, here is a link to SDL_audio.c on SDL 1.2.x, which contains its implementation of SDL_OpenAudio: https://hg.libsdl.org/SDL/file/SDL-1.2/src/audio/SDL_audio.c Fix #2,A is in, thanks! https://hg.libsdl.org/SDL/rev/ec27c4fd6880 |