]> git.lizzy.rs Git - nothing.git/commitdiff
(#612) Remove SDL_mixer deps to simply initial Windows support
authorrexim <reximkut@gmail.com>
Mon, 20 May 2019 16:45:05 +0000 (23:45 +0700)
committerrexim <reximkut@gmail.com>
Mon, 20 May 2019 16:45:05 +0000 (23:45 +0700)
15 files changed:
.travis.yml
CMakeLists.txt
README.md
appveyor.yml
cmake/FindSDL2_mixer.cmake [deleted file]
default.nix
src/game.c
src/game/level.h
src/game/level/goals.c
src/game/level/player.c
src/game/sound_samples.c
src/game/sound_samples.h
src/main.c
src/system/lt/lt_adapters.c
src/system/lt/lt_adapters.h

index 4276c187926ebee6fee6e21118a2a63c02adccd9..b54e2ebb4a7b0989241994cf12f5cefa5b5c523a 100644 (file)
@@ -3,7 +3,6 @@ addons:
   homebrew:
     packages:
       - sdl2
-      - sdl2_mixer
 os:
   - osx
 compiler:
index ab9848eb59baceccef6d9b189a9e2be2f589cd7e..665d1f13e237e318771005b1cd58ee53b9096ace 100644 (file)
@@ -4,7 +4,6 @@ project(nothing)
 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
 
 find_package(SDL2 REQUIRED)
-find_package(SDL2_mixer REQUIRED)
 
 include_directories(${CMAKE_BINARY_DIR})
 include_directories(src/)
@@ -15,8 +14,6 @@ else()
   include_directories(${SDL2_INCLUDE_DIR})
 endif()
 
-include_directories(${SDL2_MIXER_INCLUDE_DIR})
-
 add_library(system STATIC
   src/system/line_stream.c
   src/system/line_stream.h
@@ -152,7 +149,7 @@ add_executable(nothing
   src/game/level/level_editor/layer.h
   src/game/level/level_editor/layer.c
 )
-target_link_libraries(nothing ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m system ebisp)
+target_link_libraries(nothing ${SDL2_LIBRARY} m system ebisp)
 
 add_custom_command(
   OUTPUT broadcast_lisp.h
@@ -163,7 +160,7 @@ add_executable(repl
   src/ebisp/repl.c
   src/ebisp/repl_runtime.c
   )
-target_link_libraries(repl ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m system ebisp)
+target_link_libraries(repl ${SDL2_LIBRARY} m system ebisp)
 
 add_executable(baker
   src/ebisp/baker.c
@@ -175,7 +172,7 @@ add_executable(nothing_test
   test/test.h
   test/tokenizer_suite.h
   )
-target_link_libraries(nothing_test ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m system ebisp)
+target_link_libraries(nothing_test ${SDL2_LIBRARY} m system ebisp)
 
 if (UNIX)
   add_subdirectory(devtools/svg2level)
index c944d8fbe43ce2fe4139b3363115936732712741..1053441ae5c46427b695b5ce0b156d627c9c1adf 100644 (file)
--- a/README.md
+++ b/README.md
 - [gcc]
 - [cmake]
 - [libsdl2-dev]
-- [libsdl2-mixer-dev]
 - [inotify-tools]
 
 ### Ubuntu
 
 ```console
-$ sudo apt-get install gcc cmake libsdl2-dev libsdl2-mixer-dev inotify-tools libxml2-dev
+$ sudo apt-get install gcc cmake libsdl2-dev inotify-tools libxml2-dev
 ```
 
 ### MacOS
 
 ```console
-$ brew install gcc cmake sdl2 sdl2_mixer
+$ brew install gcc cmake sdl2
 ```
 
 ### NixOS
@@ -39,7 +38,7 @@ $ nix-shell
 ### Arch Linux
 
 ```console
-$ sudo pacman -S gcc cmake sdl2 sdl2_mixer inotify-tools libxml2
+$ sudo pacman -S gcc cmake sdl2 inotify-tools libxml2
 ```
 
 ### Windows
@@ -162,7 +161,6 @@ You can support my work via
 [gcc]: https://gcc.gnu.org/
 [cmake]: https://cmake.org/
 [libsdl2-dev]: https://www.libsdl.org/
-[libsdl2-mixer-dev]: https://www.libsdl.org/projects/SDL_mixer/
 [NixOS]: https://nixos.org/
 [default.nix]: ./default.nix
 [build-on-windows]: #build-on-windows
index deb9c8486a119b0a4db7cd6d02c17f1ac36ec664..3deb303a89525b164ef1b8be919d065fad60bd26 100644 (file)
@@ -1,7 +1,7 @@
 image: ubuntu1804
 install:
   - sh: sudo apt-get update -qq
-  - sh: sudo apt-get install -qq cmake cmake-data libsdl2-dev libsdl2-mixer-dev libxml2-dev
+  - sh: sudo apt-get install -qq cmake cmake-data libsdl2-dev libxml2-dev
 build_script:
   - mkdir build
   - cd build
diff --git a/cmake/FindSDL2_mixer.cmake b/cmake/FindSDL2_mixer.cmake
deleted file mode 100644 (file)
index 4cb3e30..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-# - Locate SDL2_mixer library (modified from Cmake's FindSDL_mixer.cmake)
-# This module defines:
-#  SDL2_MIXER_LIBRARIES, the name of the library to link against
-#  SDL2_MIXER_INCLUDE_DIRS, where to find the headers
-#  SDL2_MIXER_FOUND, if false, do not try to link against
-#  SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL2_mixer
-#
-# For backward compatiblity the following variables are also set:
-#  SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
-#  SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
-#  SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
-#
-# $SDLDIR is an environment variable that would
-# correspond to the ./configure --prefix=$SDLDIR
-# used in building SDL.
-#
-#=============================================================================
-# Copyright 2000-2014 Kitware, Inc.
-# Copyright 2000-2011 Insight Software Consortium
-# Copyright 2014 Justin Jacobs
-# All rights reserved.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-
-if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
-  set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
-entry initialized from old variable name")
-endif()
-find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
-  HINTS
-    ENV SDLMIXERDIR
-    ENV SDLDIR
-  PATH_SUFFIXES include/SDL2 include
-)
-
-if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
-  set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
-initialized from old variable name")
-endif()
-find_library(SDL2_MIXER_LIBRARY
-  NAMES SDL2_mixer
-  HINTS
-    ENV SDLMIXERDIR
-    ENV SDLDIR
-  PATH_SUFFIXES lib
-)
-
-if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h")
-  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
-  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
-  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
-  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}")
-  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}")
-  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}")
-  set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH})
-  unset(SDL2_MIXER_VERSION_MAJOR_LINE)
-  unset(SDL2_MIXER_VERSION_MINOR_LINE)
-  unset(SDL2_MIXER_VERSION_PATCH_LINE)
-  unset(SDL2_MIXER_VERSION_MAJOR)
-  unset(SDL2_MIXER_VERSION_MINOR)
-  unset(SDL2_MIXER_VERSION_PATCH)
-endif()
-
-set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
-set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
-                                  REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
-                                  VERSION_VAR SDL2_MIXER_VERSION_STRING)
-
-# for backward compatiblity
-set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
-set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
-set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
-
-mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
index 4d4c8e074ec7c66667ecbff0349120bb18753961..508da862c91cef7e4611bbe1f6edfa56ec8d8799 100644 (file)
@@ -5,7 +5,6 @@ with import <nixpkgs> {}; {
                         gcc
                         gdb
                         SDL2
-                        SDL2_mixer
                         pkgconfig
                         cmake
                         valgrind
index 0b0e3976716e9786260da4db945641c6aca5feae..81adf948ff8f34b9f3bc48bef6457a6514292571 100644 (file)
@@ -1,5 +1,4 @@
 #include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
 #include "system/stacktrace.h"
 #include <stdio.h>
 
index 29ab9a73c214b5b9421fc5877bcb0982e25ffb6f..06a73b7917c5303b9d7fa499db68cca22142464c 100644 (file)
@@ -2,7 +2,6 @@
 #define LEVEL_H_
 
 #include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
 
 #include "game/camera.h"
 #include "game/level/platforms.h"
index 5d0a29271eda4810b65a2f02d6315764ed2c3885..bb8693bfd2b7f32e37ec090f706e1cf3883924bd 100644 (file)
@@ -257,7 +257,7 @@ int goals_sound(Goals *goals,
     for (size_t i = 0; i < goals->count; ++i) {
         switch (goals->cue_states[i]) {
         case CUE_STATE_HIT_NOTHING:
-            sound_samples_play_sound(sound_samples, 0, 0);
+            sound_samples_play_sound(sound_samples, 0);
             goals->cue_states[i] = CUE_STATE_SEEN_NOTHING;
             break;
 
index f112080a7c36037193ab4971f25b18ba0c1b713d..836315720108bbd4c31433c28ee1c9ff78306ff8 100644 (file)
@@ -298,7 +298,7 @@ int player_sound(Player *player,
     if (player->play_die_cue) {
         player->play_die_cue = 0;
 
-        if (sound_samples_play_sound(sound_samples, 0, 0) < 0) {
+        if (sound_samples_play_sound(sound_samples, 0) < 0) {
             return -1;
         }
     }
index f69c49a7d0ad883f59aae445e5ab8c7a550f4255..c3f3e153c9a66f5db79b28154f0d6be10a0aab83 100644 (file)
@@ -1,5 +1,4 @@
 #include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
 #include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include "system/lt.h"
 #include "system/nth_alloc.h"
 
+// TODO: Sound_samples is not implemented
+
 struct Sound_samples
 {
     Lt *lt;
-    Mix_Chunk **samples;
     size_t samples_count;
     int paused;
 };
 
-static int mix_get_free_channel(void)
-{
-    for (int i = 0; i < MIX_CHANNELS; ++i) {
-        if (!Mix_Playing(i)) {
-            return i;
-        }
-    }
-
-    return -1;
-}
-
 Sound_samples *create_sound_samples(const char *sample_files[],
-                                      size_t sample_files_count)
+                                    size_t sample_files_count)
 {
     trace_assert(sample_files);
     trace_assert(sample_files_count > 0);
@@ -41,31 +30,11 @@ Sound_samples *create_sound_samples(const char *sample_files[],
     if (sound_samples == NULL) {
         RETURN_LT(lt, NULL);
     }
-
-    sound_samples->samples = PUSH_LT(
-        lt,
-        nth_calloc(1, sizeof(Mix_Chunk*) * sample_files_count),
-        free);
-    if (sound_samples->samples == NULL) {
-        RETURN_LT(lt, NULL);
-    }
-
-    for (size_t i = 0; i < sample_files_count; ++i) {
-        sound_samples->samples[i] = PUSH_LT(
-            lt,
-            Mix_LoadWAV(sample_files[i]),
-            Mix_FreeChunk);
-        if (sound_samples->samples[i] == NULL) {
-            log_fail("Could not load '%s': %s\n", sample_files[i], Mix_GetError());
-            RETURN_LT(lt, NULL);
-        }
-    }
+    sound_samples->lt = lt;
 
     sound_samples->samples_count = sample_files_count;
     sound_samples->paused = 0;
 
-    sound_samples->lt = lt;
-
     return sound_samples;
 }
 
@@ -76,35 +45,16 @@ void destroy_sound_samples(Sound_samples *sound_samples)
 }
 
 int sound_samples_play_sound(Sound_samples *sound_samples,
-                            size_t sound_index,
-                            int loops)
+                             size_t sound_index)
 {
     trace_assert(sound_samples);
-
-    if (sound_index < sound_samples->samples_count) {
-        const int free_channel = mix_get_free_channel();
-
-        log_info("Found free channel: %d\n", free_channel);
-
-        if (free_channel >= 0) {
-            return Mix_PlayChannel(free_channel, sound_samples->samples[sound_index], loops);
-        }
-    }
-
+    (void) sound_index;
     return 0;
 }
 
 int sound_samples_toggle_pause(Sound_samples *sound_samples)
 {
     trace_assert(sound_samples);
-
-    if (sound_samples->paused) {
-        Mix_Resume(-1);
-    } else {
-        Mix_Pause(-1);
-    }
-
     sound_samples->paused = !sound_samples->paused;
-
     return 0;
 }
index 05b1c9bd6d8b21a79c533fbbfdb9c2c813da3785..b035b9647101767ae5f870cdb668184cbc078408 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef SOUND_SAMPLES_H_
 #define SOUND_SAMPLES_H_
 
-#include <SDL2/SDL_mixer.h>
-
 #include "math/point.h"
 
 typedef struct Sound_samples Sound_samples;
@@ -12,8 +10,7 @@ Sound_samples *create_sound_samples(const char *sample_files[],
 void destroy_sound_samples(Sound_samples *sound_samples);
 
 int sound_samples_play_sound(Sound_samples *sound_samples,
-                            size_t sound_index,
-                            int loops);
+                             size_t sound_index);
 
 int sound_samples_toggle_pause(Sound_samples *sound_samples);
 
index 777b088f0cb86a5e61320daf431a881dbe0a635e..84eab090b3a3866dbdca7890f924fccab765ba06 100644 (file)
@@ -1,5 +1,4 @@
 #include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
 
 #include <stdint.h>
 #include <stdio.h>
@@ -117,16 +116,6 @@ int main(int argc, char *argv[])
         log_warn("Could not find any Sticks of the Joy\n");
     }
 
-    if (Mix_OpenAudio(
-            MIX_DEFAULT_FREQUENCY,
-            MIX_DEFAULT_FORMAT,
-            2,
-            1024) < 0) {
-        log_fail("Could not initialize the audio: %s\n", Mix_GetError());
-        RETURN_LT(lt, -1);
-    }
-    PUSH_LT(lt, 42, Mix_CloseAudio_lt);
-
     // ------------------------------
 
     const char * sound_sample_files[] = {
index 4917555733fff9606781afb4b42044560c60208e..cc353df108a29ec418d6a21e612cbf13511c5522 100644 (file)
@@ -1,15 +1,8 @@
 #include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
 #include <stdio.h>
 
 #include "lt_adapters.h"
 
-void Mix_CloseAudio_lt(void* ignored)
-{
-    (void) ignored;
-    Mix_CloseAudio();
-}
-
 void SDL_Quit_lt(void* ignored)
 {
     (void) ignored;
index 6afe5d27ca72e8ca0bda7008532d5469bf8f8568..43a53b01a11280261b06804c7dbcb3f8502c3d37 100644 (file)
@@ -1,10 +1,9 @@
 #ifndef LT_ADAPTERS_H_
 #define LT_ADAPTERS_H_
 
+// TODO: lt_adapters could be removed
+
 // SDL
 void SDL_Quit_lt(void* ignored);
 
-// SDL_mixer
-void Mix_CloseAudio_lt(void* ignored);
-
 #endif  // LT_ADAPTERS_H_