-
Notifications
You must be signed in to change notification settings - Fork 252
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
Use SDL2 on Windows #457
Use SDL2 on Windows #457
Conversation
You probably know, but in windows x64 there is no audio in the main menu. I didn't test further into levels. Mve audio played fine. |
yep, I did not look into it yet |
rebased on master, nothing obvious comes up to fix the sound, any help welcome, I'll try again later |
I tested it on Windows and had no audio at all, except for movies. I tracked it down to a change in how the SDL audio device is getting created for movies and the rest of the game. The callstack for movies is:
going through While the callstack for the menu and other things looks like this:
going through If I change the Line 102 in 95f3efe
it works for me. This change seems to boil down to SDL_audio.c Line 1478 where I have no clue about any consequences this might have for other platforms or in general... |
@pzychotic you rock, thanks for investigating! you've saved me at least a couple hours of sleep tonight :) I'll give your fix a try later and report back |
This should, in theory, work on all platforms, but definitely test it and verify. According to documentation for I'm not at all certain what this change would mean for embedded systems like android that don't have similar audio hardware and drivers like the three core platforms. Maybe add a fallback to where if SDL fails to init audio, go back to the |
So at sdlsound.cpp do this, maybe. sound_device = SDL_OpenAudioDevice(nullptr, 0, &spec, nullptr, 0);
if (sound_device == 0) {
strcpy(m_error_text, SDL_GetError());
// Retry
sound_device = SDL_OpenAudioDevice(nullptr, 0, &spec, nullptr, SDL_AUDIO_ALLOW_ANY_CHANGE);
if (sound_device == 0) {
strcpy(m_error_text, SDL_GetError());
}
return false;
}
|
Sound fix tested and approved on Windows! This PR is now open for review (@winterheart @Arcnor ?)
Let's not preemptively fix a bug we don't have yet and we can't test. First, find a case where this is proven to be problematic |
I just noticed something. This PR’s description says:
At the same time, this PR’s README says:
I think that the “x86 Native Tools Command Prompt” and the |
Readme updated |
huh is updated builtin-baseline too recent for Github-actions? |
{ | ||
"name": "sdl2", | ||
"version>=": "2.30.3" | ||
} | ||
] |
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.
an override
section is needed to specify an exact version, otherwise the builtin-baseline
and version>=
(note >=
) fields together just designate a minimum version
] | |
], | |
"overrides": [ | |
{ | |
"name": "sdl2", | |
"version": "2.30.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.
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.
thanks for the tip, I added the override
d2ca9f9
to
e94a13d
Compare
rebased (correctly) on master |
Project compiles, but cannot start due failing to find required OpenGL symbols on dlopen. See Lgt2x#7 for proposed fix. Didn't test deeper, but after applying fix critical parts of game runs fine. Tested video playback, main screen UI, starting training mission and Retribution. There only one non-critical regression found: all sound and briefings goes in German language. I don't know why, seems that happens because I'm using non-English locale on Windows and game incorrectly detects it as German. |
…bility. Per the SDL2 doc, the 0 flag means that SDL will handle any difference between the hardware audio data format and the game's
Du sprichst nicht Deutsch? :D More seriously locale detection looks broken, I suspect this is also the case on Linux. I want to tackle this in a future PR. I created #477 to report it. Your fix looks correct, I tested & cherry-picked it. It makes more sense to use the SDL loading functions for OpenGL just like Linux does. I don't know why it worked for me and others, maybe system version differences. |
babc895
to
7b7ffde
Compare
Well, that was worked earlier for me too, I don't know why is was broken for this time... |
On loading GL symbols we are using SDL_GL_GetProcAddress(), which only valid if we previously loaded OpenGL library with SDL_GL_LoadLibrary(). We cannot use mod_LoadModule() here, otherwise finding symbols will fail.
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.
Tested on Windows and Linux, both runs fine. Ready to merge.
This PR makes Windows use SDL2 instead of DirectX, to be on par with the other supported platforms. As a consequence, now the Windows executable:
Windows 32bit has been dropped because of compatibility issues. Note that Linux and OSX 32bit are not built either.
The internal editor gave me a some trouble: this MFC app relies a lot on DirectX tools and interacts with the game through it, and is not a solved problem as of this PR. Making it use the SDL2 game properly is going to require additional work.
One solution I tried was to keep using directX for the game on the editor. This way, we would build both DirectInput and SDL2 Input for the ddio module in the form of 2 separate static libraries, but as many modules links to it, that would mean many modules have both a SDL2 and a DirectX version, which would be cumbersome. The solution to get a successful build here is a hybrid one, building the game used in the editor with SDL2, and the rest is still using DirectX. It compiles, but has runtime problems (the editor was broken before this PR anyway)
Future work:
Depends on #453 and #456 / #449