smpeg icon indicating copy to clipboard operation
smpeg copied to clipboard

SDL2.0 MPEGaudio::MPEGaudio()

Open pch666777 opened this issue 3 years ago • 0 comments

There is a small problem with the constructor of MPEGaudio at MPEGaudio:: MPEGaudio(MPEGstream *stream, bool initSDL). In SDL2.0 environment, this line: audio_ active = (SDL_OpenAudio(&wanted, &actual) == 0); Always return to the first available device mode. In the internal implementation of SDL_OpenAudio(), open_ audio_ device(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE, 1),SDL_ AUDIO_ ALLOW_ ANY_ CHANGE caused the problem, which led to the existing more powerful devices always returning to F32 mode audio support, so that the audio could not be played. To solve this problem, this sentence can be changed to:

#if SDL_ VERSION_ ATLEAST(2, 0, 0) actual = wanted; audio_ active = (SDL_OpenAudio(&wanted, NULL) == 0); #else audio_ active = (SDL_OpenAudio(&wanted, &actual) == 0); #endif

Passed the test in Windows x64 mode and fixed the problem.

pch666777 avatar Feb 08 '23 23:02 pch666777