From c1d2a5017517f74c30c5f5733ab71bda3f235b41 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jan 2022 20:25:00 -0500 Subject: [PATCH 1/2] Give OpenAL the ability to be optional --- CMakeLists.txt | 1 + src/86box.c | 2 ++ src/CMakeLists.txt | 8 +++++--- src/sound/CMakeLists.txt | 7 ++++++- src/sound/midi_fluidsynth.c | 8 ++++++++ src/sound/midi_mt32.c | 8 ++++++++ src/sound/sound.c | 6 ++++++ 7 files changed, 36 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07b3d027a..941506bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,7 @@ set(CMAKE_CXX_STANDARD 11) # ------ ----------- ---- option(RELEASE "Release build" OFF) option(DYNAREC "Dynamic recompiler" ON) +option(OPENAL "OpenAL" ON) option(FLUIDSYNTH "FluidSynth" ON) option(MUNT "MUNT" ON) option(VRAMDUMP "Video RAM dumping" OFF) diff --git a/src/86box.c b/src/86box.c index 4c6e06488..bdd5f4ffa 100644 --- a/src/86box.c +++ b/src/86box.c @@ -932,7 +932,9 @@ pc_reset_hard_close(void) scsi_disk_close(); +#ifdef USE_OPENAL closeal(); +#endif video_reset_close(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c3ed435d8..8bb53a5d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,9 +87,11 @@ if(APPLE) target_link_libraries(86Box Freetype::Freetype) endif() -find_package(OpenAL REQUIRED) -include_directories(${OPENAL_INCLUDE_DIR}) -target_link_libraries(86Box ${OPENAL_LIBRARY}) +if(OPENAL) + find_package(OpenAL REQUIRED) + include_directories(${OPENAL_INCLUDE_DIR}) + target_link_libraries(86Box ${OPENAL_LIBRARY}) +endif() find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) diff --git a/src/sound/CMakeLists.txt b/src/sound/CMakeLists.txt index e3420ac01..d7da82713 100644 --- a/src/sound/CMakeLists.txt +++ b/src/sound/CMakeLists.txt @@ -13,12 +13,17 @@ # Copyright 2020,2021 David Hrdlička. # -add_library(snd OBJECT sound.c openal.c snd_opl.c snd_opl_nuked.c snd_resid.cc +add_library(snd OBJECT sound.c snd_opl.c snd_opl_nuked.c snd_resid.cc midi.c midi_rtmidi.cpp snd_speaker.c snd_pssj.c snd_lpt_dac.c snd_ac97_codec.c snd_ac97_via.c snd_lpt_dss.c snd_adlib.c snd_adlibgold.c snd_ad1848.c snd_audiopci.c snd_azt2316a.c snd_cms.c snd_cs423x.c snd_gus.c snd_sb.c snd_sb_dsp.c snd_emu8k.c snd_mpu401.c snd_sn76489.c snd_ssi2001.c snd_wss.c snd_ym7128.c) +if(OPENAL) + target_compile_definitions(snd PRIVATE USE_OPENAL) + target_sources(snd PRIVATE openal.c) +endif() + if(FLUIDSYNTH) target_compile_definitions(snd PRIVATE USE_FLUIDSYNTH) target_sources(snd PRIVATE midi_fluidsynth.c) diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index a93618cd4..1a3ae2764 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -40,8 +40,10 @@ enum fluid_interp { }; +#ifdef USE_OPENAL extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); +#endif static void *fluidsynth_handle; /* handle to FluidSynth DLL */ @@ -150,7 +152,9 @@ static void fluidsynth_thread(void *param) buf_pos += buf_size; if (buf_pos >= data->buf_size) { +#ifdef USE_OPENAL givealbuffer_midi(data->buffer, data->buf_size / sizeof(float)); +#endif buf_pos = 0; } } @@ -163,7 +167,9 @@ static void fluidsynth_thread(void *param) buf_pos += buf_size; if (buf_pos >= data->buf_size) { +#ifdef USE_OPENAL givealbuffer_midi(data->buffer_int16, data->buf_size / sizeof(int16_t)); +#endif buf_pos = 0; } } @@ -314,7 +320,9 @@ void* fluidsynth_init(const device_t *info) data->buffer_int16 = malloc(data->buf_size); } +#ifdef USE_OPENAL al_set_midi(data->samplerate, data->buf_size); +#endif dev = malloc(sizeof(midi_device_t)); memset(dev, 0, sizeof(midi_device_t)); diff --git a/src/sound/midi_mt32.c b/src/sound/midi_mt32.c index 8ade99b51..ed87411cc 100644 --- a/src/sound/midi_mt32.c +++ b/src/sound/midi_mt32.c @@ -13,8 +13,10 @@ #include <86box/midi.h> +#ifdef USE_OPENAL extern void givealbuffer_midi(void *buf, uint32_t size); extern void al_set_midi(int freq, int buf_size); +#endif static const mt32emu_report_handler_i_v0 handler_v0 = { /** Returns the actual interface version ID */ @@ -136,7 +138,9 @@ static void mt32_thread(void *param) buf_pos += bsize; if (buf_pos >= buf_size) { +#ifdef USE_OPENAL givealbuffer_midi(buffer, buf_size / sizeof(float)); +#endif buf_pos = 0; } } @@ -148,7 +152,9 @@ static void mt32_thread(void *param) buf_pos += bsize; if (buf_pos >= buf_size) { +#ifdef USE_OPENAL givealbuffer_midi(buffer_int16, buf_size / sizeof(int16_t)); +#endif buf_pos = 0; } } @@ -200,7 +206,9 @@ void* mt32emu_init(char *control_rom, char *pcm_rom) mt32emu_set_reversed_stereo_enabled(context, device_get_config_int("reversed_stereo")); mt32emu_set_nice_amp_ramp_enabled(context, device_get_config_int("nice_ramp")); +#ifdef USE_OPENAL al_set_midi(samplerate, buf_size); +#endif dev = malloc(sizeof(midi_device_t)); memset(dev, 0, sizeof(midi_device_t)); diff --git a/src/sound/sound.c b/src/sound/sound.c index 4ab9cf58e..af9a91460 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -323,10 +323,12 @@ sound_cd_thread(void *param) } } +#ifdef USE_OPENAL if (sound_is_float) givealbuffer_cd(cd_out_buffer); else givealbuffer_cd(cd_out_buffer_int16); +#endif } } @@ -430,10 +432,12 @@ sound_poll(void *priv) } } +#ifdef USE_OPENAL if (sound_is_float) givealbuffer(outbuffer_ex); else givealbuffer(outbuffer_ex_int16); +#endif if (cd_thread_enable) { cd_buf_update--; @@ -462,7 +466,9 @@ sound_reset(void) midi_device_init(); midi_in_device_init(); +#ifdef USE_OPENAL inital(); +#endif timer_add(&sound_poll_timer, sound_poll, NULL, 1); From 8aeaa6a8c4a6391aa2e3955292b9bb9b9e82b57f Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 29 Jan 2022 20:25:57 -0500 Subject: [PATCH 2/2] More consistency for Linux and macos actions builds --- .github/workflows/cmake.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index d1fdcb2e3..ea4ab4c4f 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -83,7 +83,7 @@ jobs: run: cmake --build build --target ${{ matrix.build.target }} - uses: actions/upload-artifact@v2 with: - name: '86Box-${{ matrix.build.name }}-MSYS2-${{ matrix.environment.msystem }}-gha${{ github.run_number }}' + name: '86Box${{ matrix.build.slug }}-MSYS2-${{ matrix.environment.msystem }}-gha${{ github.run_number }}' path: build/artifacts/** llvm-windows: @@ -177,18 +177,21 @@ jobs: path: build/artifacts/** linux: - name: "Linux GCC 11" + name: "Linux GCC 11 (${{ matrix.build.name }} x86_64)" runs-on: ubuntu-latest + strategy: fail-fast: false matrix: build: - name: Debug + slug: -Debug dev-build: off new-dynarec: off type: Debug - name: Dev + slug: -Dev dev-build: on new-dynarec: on type: Debug @@ -207,7 +210,13 @@ jobs: -D CMAKE_BUILD_TYPE=${{ matrix.build.type }} -D CMAKE_C_COMPILER=gcc-11 -D CMAKE_CXX_COMPILER=g++-11 - name: Build - run: cmake --build build --target install + run: cmake --build build + - name: Generate package + run: cmake --install build --prefix ./build/artifacts ${{ matrix.build.strip }} + - uses: actions/upload-artifact@v2 + with: + name: '86Box${{ matrix.build.slug }}-Linux-x86_64-gha${{ github.run_number }}' + path: build/artifacts/** macos: name: "macOS 11 (${{ matrix.build.name }} x86_64)" @@ -243,7 +252,9 @@ jobs: run: >- cmake -S . -B build --toolchain cmake/flags-gcc-x86_64.cmake + -D DEV_BRANCH=${{ matrix.build.dev-build }} -D NEW_DYNAREC=${{ matrix.build.new-dynarec }} + -D VNC=OFF -D CMAKE_BUILD_TYPE=${{ matrix.build.type }} - name: Build run: cmake --build build