New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL2: fix mixer errors, mixer.init(..., allowchanges=0) #861
Conversation
Ah. SDL 2 is required for the allowchanges stuff to work.
With SDL1 (and pygame), I think it defaulted to 0 behaviour. |
src_c/mixer.c
Outdated
} | ||
channels = (channels >= 2) ? 2 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should let channels
to go through as a number more than 2? I guess none of the code is prepared for this really (sound array etc), and it would require testing. But SDL2 accepts more than 2.
https://wiki.libsdl.org/SDL_AudioSpec#Remarks
channels specifies the number of output channels. As of SDL 2.0, supported values are 1 (mono), 2 (stereo), 4 (quad), and 6 (5.1).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I guess this channels >= 2
test should only be for SDL1.
For SDL2 it should check for 1, 2, 4, and 6.
Edit: Just saw the edit
allowedchanges=0 doesn't cause it to fail. SDL converts the audio to and
from the requested format instead of using a similar one (in the
callbacks). Seems to be the default behavior in SDL 1
Den fre 1 mars 2019 06:14René Dudfield <notifications@github.com> skrev:
… Ah. SDL 2 is required for the allowchanges stuff to work.
https://wiki.libsdl.org/SDL_OpenAudioDevice#allowed
- SDL_AUDIO_ALLOW_FREQUENCY_CHANGE
- SDL_AUDIO_ALLOW_FORMAT_CHANGE
- SDL_AUDIO_ALLOW_CHANNELS_CHANGE
- SDL_AUDIO_ALLOW_ANY_CHANGE
With SDL1 (and pygame), I think it defaulted to SDL_AUDIO_ALLOW_ANY_CHANGE
behaviour.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#861 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACh9LW3aAVga3h3H3y_ExH4cgYiwbz6Cks5vSLctgaJpZM4bXsSK>
.
|
This also solved the issues in #850. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good changes and good idea providing the allowedchanges
argument.
From the SDL 1.2.15 docs:
From SDL_mixer (1.*): /* Open the mixer with a certain desired audio format */
int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
{
int i;
SDL_AudioSpec desired;
...
/* Set the desired format and frequency */
desired.freq = frequency;
desired.format = format;
desired.channels = nchannels;
desired.samples = chunksize;
desired.callback = mix_channels;
desired.userdata = NULL;
/* Accept nearly any audio format */
if ( SDL_OpenAudio(&desired, &mixer) < 0 ) {
return(-1);
}
...
} obtained is not NULL (it's &mixer), so I guess allowedchanges=0 is the wrong default. But changing it causes a bunch of test failures, so I guess we update the tests instead. I set the default to |
case 6: | ||
break; | ||
default: | ||
PyErr_SetString(PyExc_ValueError, "'channels' must be 1, 2, 4, or 6"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#113 can be closed since channels > 2 are supported in SDL2.
Close #860