Skip to content
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

Fix to play SDL_audio on current device by default #23

Merged
merged 2 commits into from
Sep 2, 2024

Conversation

dartfnm
Copy link
Contributor

@dartfnm dartfnm commented Aug 31, 2024

  • There was no sound in quaesar because it uses the sound SDL_Audio device at index 0, not the current audio device in the OS. So now it will choose the current OS audio device unless the user has explicitly specified a different device in the config.

- There was no sound in quaesar because it uses the sound SDL_Audio device at index 0, not the current audio device in the OS.
So now it will choose the current OS audio device unless the user has explicitly specified a different device in the config.
@emoon
Copy link
Member

emoon commented Aug 31, 2024

Thanks for the PR.

It seems that the function is missing in some version (?) of SDL2

/usr/bin/clang++-9 -DFSUAE -I/home/runner/work/quaesar/quaesar/uae_src/include -I/home/runner/work/quaesar/quaesar/uae_src -I/home/runner/work/quaesar/quaesar/src -I/home/runner/work/quaesar/quaesar/. -I/usr/include/SDL2 -I/home/runner/work/quaesar/quaesar/external/ADFlib/src -I/home/runner/work/quaesar/quaesar/temp/external/zlib -I/home/runner/work/quaesar/quaesar/external/zlib -std=gnu++17 -DUAE=1 -D_cdecl= -DFILEFLAG_WRITE=1 -DOS_NAME=\"linux\" -DUSHORT=uint16_t -DHWND=uint32_t -DHRESULT=uint32_t -DWPARAM=uint16_t -DLPARAM=uint32_t -DFILEFLAG_DIR=1 -D_ftelli64=ftello64 -D_fseeki64=fseeko64 -MD -MT CMakeFiles/quaesar.dir/src/sounddep/sound.cpp.o -MF CMakeFiles/quaesar.dir/src/sounddep/sound.cpp.o.d -o CMakeFiles/quaesar.dir/src/sounddep/sound.cpp.o -c /home/runner/work/quaesar/quaesar/src/sounddep/sound.cpp
/home/runner/work/quaesar/quaesar/src/sounddep/sound.cpp:370:9: error: use of undeclared identifier 'SDL_GetDefaultAudioInfo'
    if (SDL_GetDefaultAudioInfo(&cur_driver, &spec, 0) == 0) {

Any idea here?

@dartfnm
Copy link
Contributor Author

dartfnm commented Sep 1, 2024

Yes, it is strange according to the documentation this function was added in 2022 in SDL version 2.24.0.
It looks like the problem is in CMake, since the quaesar\external\sdl2\include\SDL_audio.h folder contains the new version of SDL.
It seems that for UNIX you need to update the SDL version or give it the correct path, like here:

target_include_directories(quaesar PRIVATE "${CMAKE_SOURCE_DIR}/external/sdl2/include")

But I don't know how to do it correctly on Linux.

@emoon
Copy link
Member

emoon commented Sep 1, 2024

The way it works is that the system version of SDL is used on Linux and for Windows an included version is used. As listed above

-I/usr/include/SDL2 for the commandline

It seems to only happen on Ubuntu 20.04 which is an older version. I try to allow coming the code for older systems. My guess is that the older of Ubuntu has an older version of SDL2 installed, but maybe it's possible to to update the installed SDL2 version. Otherwise it might be possible with an #ifdef that checks the SDL version if the function is included or not.

It seems that libsdl2-2.0-0 gets installed.

@emoon
Copy link
Member

emoon commented Sep 1, 2024

What I think the best approach here is to use

#if SDL_VERSION_ATLEAST(2, 24, 0)
  ... code that uses SDL_GetDefaultAudioInfo(...)
#endif

So older SDL2 versions will still work, but just not get the default audio device selected.

- There was no sound in quaesar because it uses the sound SDL_Audio device at index 0, not the current audio device in the OS.
So now it will choose the current OS audio device unless the user has explicitly specified a different device in the config.
@dartfnm
Copy link
Contributor Author

dartfnm commented Sep 1, 2024

What I think the best approach here is to use

#if SDL_VERSION_ATLEAST(2, 24, 0)
  ... code that uses SDL_GetDefaultAudioInfo(...)
#endif

All right, done.

@dartfnm
Copy link
Contributor Author

dartfnm commented Sep 1, 2024

Fixed it in 2nd commit, but I don't know how to run the CI check again. It didn't start automatically.

@emoon
Copy link
Member

emoon commented Sep 2, 2024

Yeah, the maintainer has to trigger the CI manually for new user PRs (it's because in the past bots open up tons of PR on many repos and because CI started the injected crypto mining and what not)

@emoon emoon merged commit c0f2882 into theblacklotus:main Sep 2, 2024
15 checks passed
@emoon
Copy link
Member

emoon commented Sep 2, 2024

Seems to pass now. Thanks for the fix!

dartfnm added a commit to dartfnm/quaesar that referenced this pull request Oct 9, 2024
* Fix to play SDL_audio on current device by default

- There was no sound in quaesar because it uses the sound SDL_Audio device at index 0, not the current audio device in the OS.
So now it will choose the current OS audio device unless the user has explicitly specified a different device in the config.

* Fix to play SDL_audio on current device by default

- There was no sound in quaesar because it uses the sound SDL_Audio device at index 0, not the current audio device in the OS.
So now it will choose the current OS audio device unless the user has explicitly specified a different device in the config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants