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

Make "Experimental" PulseAudio Backend A Viable Option #104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ else()
endif()

if(TARGET SDL3::SDL3)
target_sources(mcpelauncher-client PRIVATE src/jni/sdl3audio.cpp src/jni/sdl3audio.h)
message(VERBOSE "USING SDL3")
target_link_libraries(mcpelauncher-client SDL3::SDL3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link lib is only for audio, e.g. sdl3_audio has it's own SDL_init call for the audio subsystem and is independent from game window.

So it doesn't make sense for me to be enabled if USE_SDL3_AUDIO is off, please join USE_SDL3_AUDIO and TARGET SDL3::SDL3 via and, make if (NOT USE_SDL3_AUDIO) an else() again. Repeating conditions seems unnecessary to me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I see, I thought that TARGET SDL3::SDL3 entailed the whole SDL3 system, not just audio. My mistake. Will improve this!

target_compile_definitions(mcpelauncher-client PRIVATE HAVE_SDL3AUDIO)
else()
find_package(PulseAudio)
if (USE_SDL3_AUDIO)
message(VERBOSE "USING SDL3AUDIO")
target_sources(mcpelauncher-client PRIVATE src/jni/sdl3audio.cpp src/jni/sdl3audio.h)
target_compile_definitions(mcpelauncher-client PRIVATE HAVE_SDL3AUDIO)
endif()
endif()

if (NOT USE_SDL3_AUDIO)
find_package(PulseAudio)
message(STATUS "USING EXPERIMENTAL PULSEAUDIO BACKEND")
if (PULSEAUDIO_FOUND AND PULSEAUDIOSIMPLE_FOUND)
target_sources(mcpelauncher-client PRIVATE src/jni/pulseaudio.cpp src/jni/pulseaudio.h)
target_link_libraries(mcpelauncher-client ${PULSEAUDIO_LIBRARIES} ${PULSEAUDIOSIMPLE_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion src/jni/pulseaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void AudioDevice::write(std::shared_ptr<FakeJni::JByteArray> data, FakeJni::JInt

void AudioDevice::write2(std::shared_ptr<FakeJni::JShortArray> data, FakeJni::JInt length) {
int error = 0;
if(s && pa_simple_write(s, data->getArray(), length, &error)) {
if(s && pa_simple_write(s, data->getArray(), length * 2, &error)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, you might noticed this is no longer used legacy code as of release 1.0.0.

pa_simple_free(s);
s = nullptr;
auto errormsg = pa_strerror(error);
Expand Down
Loading