Project

General

Profile

Actions

Emulator Issues #5971

closed

SDL2 dependency API change

Added by matthewharveys over 11 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 #1

Updated by delroth over 11 years ago

  • Status changed from New to Accepted
  • Issue type set to Bug
  • Priority set to High
  • Relates to usability set to Yes
  • Operating system N/A added
Actions #2

Updated by Billiard26 over 11 years ago

Does r708fed92c851ada9dbe191b20eafa14c378ca664 fix or help the problem?

Actions #3

Updated by matthewharveys over 11 years ago

With a change to this one as well. With only the changes made in 708fed92c851ada9dbe191b20eafa14c378ca664, the program doesn't compile on my machine (which is a step in the right direction :D). With the change in the attached patch made (It's just what you did in the first commit, but again), this issue can be resolved.
I didn't know that the SDL_VERSION_ATLEAST() macro existed, which would have made this issue kind of messy to solve. Thanks for your help.

Actions #4

Updated by Billiard26 over 11 years ago

  • Status changed from Accepted to Fixed

This issue was closed by revision ef9d7fb789ec.

Actions #5

Updated by Sonicadvance1 over 11 years ago

This issue was closed by revision 46f94203b735.

Actions

Also available in: Atom PDF