Project

General

Profile

Actions

Emulator Issues #5971

closed

SDL2 dependency API change

Added by matthewharveys almost 12 years ago.

Status:
Fixed
Priority:
High
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
Yes
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

I'm on the development version of Dolphin, and of the SDL2 library, and I started getting a C++ library Null string exception a little while ago. After doing some investigating, I figured out that the fault was happening in a call to SDL_JoystickName() at line 38 of SDL.cpp. After bisecting the SDL2 library (which was where the fault was coming from), I found that the SDL2 API for that function had changed recently. That function name has now been re-purposed for something else, and it's functionality has been moved to another name. I posted on the SDL2 mailing list, and they said that the changes were on purpose (as the API is not set in stone) to facilitate better hot-plugging of devices.
For us, the Cmake build system is designed to pull in the SDL2 library (as opposed to SDL1.2, which is the older API) if it is installed on the system (as it was on mine). It looks like the dolphin code is the same for both SDL1.2 and SDL2, which probably shouldn't be the case going forward. This is as far as my investigation took me, so the decision of what to do is left up to the developers.
To Summarize: We have the problems that:

  1. The function call to SDL_JoystickName() should be replaced with SDL_JoystickNameForIndex() for SDL2 libraries (I guess only ones that have been built after November 2012 when the commit was made).
  2. The code, instead of failing to compile when the function definition changes, still compiles, and then crashes on joystick initialization (the issue doesn't show up if there's no joystick attached to the system). This is because the SDL.h file pulls in SDL/SDL.h as opposed to SDL2/SDL.h, which is what should be used when using the SDL2 library.

I trivially fixed the issue on my build by changing these two things.

This was all on my Ubuntu 64bit box, but I don't think the issue was too dependant on my setup. The issue arrived when they changed the API in SDL2, and was OK before it.

I figure this won't be a problem for many people right now, but in the future it probably will be, so I thought the dolphin devs might want to start thinking about how to solve it. The simplest way would be to declare SDL1.2 as the dependency, and simply stop supporting SDL2. Then, in the future, when SDL2 is finished, SDL2 could be declared the soul dependency, and the program could be ported all at once.

Actions

Also available in: Atom PDF