homebrew:
packages:
- sdl2
- - sdl2_mixer
os:
- osx
compiler:
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/)
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
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
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
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)
- [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
### Arch Linux
```console
-$ sudo pacman -S gcc cmake sdl2 sdl2_mixer inotify-tools libxml2
+$ sudo pacman -S gcc cmake sdl2 inotify-tools libxml2
```
### Windows
[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
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
+++ /dev/null
-# - 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)
gcc
gdb
SDL2
- SDL2_mixer
pkgconfig
cmake
valgrind
#include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
#include "system/stacktrace.h"
#include <stdio.h>
#define LEVEL_H_
#include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
#include "game/camera.h"
#include "game/level/platforms.h"
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;
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;
}
}
#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);
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;
}
}
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;
}
#ifndef SOUND_SAMPLES_H_
#define SOUND_SAMPLES_H_
-#include <SDL2/SDL_mixer.h>
-
#include "math/point.h"
typedef struct Sound_samples Sound_samples;
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);
#include <SDL2/SDL.h>
-#include <SDL2/SDL_mixer.h>
#include <stdint.h>
#include <stdio.h>
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[] = {
#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;
#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_