mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-04 16:28:00 +01:00
full emscripten support, plus flac->ogg encoding for emscripten and android
This commit is contained in:
parent
a955820e8f
commit
3581c6060c
20 changed files with 494 additions and 37 deletions
|
@ -4,8 +4,8 @@
|
|||
# ALLEGRO5_ACODEC_INCLUDE_DIR - the allrgo5 include directory
|
||||
# ALLEGRO5_ACODEC_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_ACODEC_INCLUDE_DIR allegro5/allegro_acodec.h)
|
||||
message(${ALLEGRO5_INCLUDE_DIR})
|
||||
FIND_PATH(ALLEGRO5_ACODEC_INCLUDE_DIR allegro5/allegro_acodec.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_ACODEC_NAMES ${ALLEGRO5_ACODEC_NAMES} allegro_acodec allegro_acodec_static liballegro_acodec liballegro_acodec_static AllegroAcodec-5.2 allegro_acodec-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_ACODEC_LIBRARY NAMES ${ALLEGRO5_ACODEC_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_AUDIO_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_AUDIO_INCLUDE_DIR allegro5/allegro_audio.h)
|
||||
FIND_PATH(ALLEGRO5_AUDIO_INCLUDE_DIR allegro5/allegro_audio.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_AUDIO_NAMES ${ALLEGRO5_AUDIO_NAMES} allegro_audio allegro_audio_static liballegro_audio liballegro_audio_static AllegroAudio-5.2 allegro_audio-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_AUDIO_LIBRARY NAMES ${ALLEGRO5_AUDIO_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_COLOR_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_COLOR_INCLUDE_DIR allegro5/allegro_color.h)
|
||||
FIND_PATH(ALLEGRO5_COLOR_INCLUDE_DIR allegro5/allegro_color.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_COLOR_NAMES ${ALLEGRO5_COLOR_NAMES} allegro_color allegro_color_static liballegro_color liballegro_color_static AllegroColor-5.2 allegro_color-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_COLOR_LIBRARY NAMES ${ALLEGRO5_COLOR_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_FONT_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_FONT_INCLUDE_DIR allegro5/allegro_font.h)
|
||||
FIND_PATH(ALLEGRO5_FONT_INCLUDE_DIR allegro5/allegro_font.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_FONT_NAMES ${ALLEGRO5_FONT_NAMES} allegro_font allegro_font_static liballegro_font liballegro_font_static AllegroFont-5.2 allegro_font-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_FONT_LIBRARY NAMES ${ALLEGRO5_FONT_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_IMAGE_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_IMAGE_INCLUDE_DIR allegro5/allegro_image.h)
|
||||
FIND_PATH(ALLEGRO5_IMAGE_INCLUDE_DIR allegro5/allegro_image.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_IMAGE_NAMES ${ALLEGRO5_IMAGE_NAMES} allegro_image allegro_image_static liballegro_image liballegro_image_static AllegroImage-5.2 allegro_image-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_IMAGE_LIBRARY NAMES ${ALLEGRO5_IMAGE_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_PRIMITIVES_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_PRIMITIVES_INCLUDE_DIR allegro5/allegro_primitives.h)
|
||||
FIND_PATH(ALLEGRO5_PRIMITIVES_INCLUDE_DIR allegro5/allegro_primitives.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_PRIMITIVES_NAMES ${ALLEGRO5_PRIMITIVES_NAMES} allegro_primitives allegro_primitives_static liballegro_primitives liballegro_primitives_static AllegroPrimitives-5.2 allegro_primitives-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_PRIMITIVES_LIBRARY NAMES ${ALLEGRO5_PRIMITIVES_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_TTF_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_TTF_INCLUDE_DIR allegro5/allegro_ttf.h)
|
||||
FIND_PATH(ALLEGRO5_TTF_INCLUDE_DIR allegro5/allegro_ttf.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_TTF_NAMES ${ALLEGRO5_TTF_NAMES} allegro_ttf allegro_ttf_static liballegro_ttf liballegro_ttf_static AllegroTTF-5.2 allegro_ttf-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_TTF_LIBRARY NAMES ${ALLEGRO5_TTF_NAMES} )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# ALLEGRO5_VIDEO_LIBRARIES - Link these to use allegro5
|
||||
#
|
||||
|
||||
FIND_PATH(ALLEGRO5_VIDEO_INCLUDE_DIR allegro5/allegro_video.h)
|
||||
FIND_PATH(ALLEGRO5_VIDEO_INCLUDE_DIR allegro5/allegro_video.h HINTS ${ALLEGRO5_INCLUDE_DIR})
|
||||
|
||||
SET(ALLEGRO5_VIDEO_NAMES ${ALLEGRO5_VIDEO_NAMES} allegro_video allegro_video_static liballegro_video liballegro_video_static AllegroVideo-5.2 allegro_video-debug)
|
||||
FIND_LIBRARY(ALLEGRO5_VIDEO_LIBRARY NAMES ${ALLEGRO5_VIDEO_NAMES} )
|
||||
|
|
7
cmake/FlacToOgg.cmake
Normal file
7
cmake/FlacToOgg.cmake
Normal file
|
@ -0,0 +1,7 @@
|
|||
file(GLOB_RECURSE FLAC_FILES RELATIVE ${DATADIR} ${DATADIR}/*.flac)
|
||||
|
||||
foreach(file IN LISTS FLAC_FILES)
|
||||
message(${file})
|
||||
execute_process(COMMAND oggenc -b 192 --resample 44100 ${file} WORKING_DIRECTORY ${DATADIR})
|
||||
file(REMOVE ${DATADIR}/${file})
|
||||
endforeach(file)
|
|
@ -166,3 +166,7 @@ endif()
|
|||
#set these global flags for cmake client scripts to change behavior
|
||||
set(ANDROID True)
|
||||
set(BUILD_ANDROID True)
|
||||
|
||||
# Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not issue a warning on it being unused.
|
||||
if (CMAKE_TOOLCHAIN_FILE)
|
||||
endif()
|
||||
|
|
|
@ -10,3 +10,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(MINGDIR /usr/i686-w64-mingw32)
|
||||
|
||||
# Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not issue a warning on it being unused.
|
||||
if (CMAKE_TOOLCHAIN_FILE)
|
||||
endif()
|
||||
|
|
|
@ -4,6 +4,8 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
|
||||
add_definitions(-DLIBSUPERDERPY_ORIENTATION_${LIBSUPERDERPY_ORIENTATION}=true)
|
||||
|
||||
set(EMSCRIPTEN_TOTAL_MEMORY "32" CACHE STRING "Amount of memory allocated by Emscripten (MB, must be multiple of 16)" )
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c11")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1 -fno-optimize-sibling-calls -fno-omit-frame-pointer -fsanitize=leak -DLEAK_SANITIZER=1 -fno-common -fsanitize-recover=all")
|
||||
if(APPLE)
|
||||
|
@ -45,7 +47,31 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
|
||||
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib/${LIBSUPERDERPY_GAMENAME}:\$ORIGIN/gamestates:\$ORIGIN:\$ORIGIN/../lib:\$ORIGIN/lib:\$ORIGIN/bin")
|
||||
|
||||
find_package(Allegro5 REQUIRED)
|
||||
if(EMSCRIPTEN)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".bc")
|
||||
set(EMSCRIPTEN_USE_FLAGS -s USE_SDL=2 -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1 -s USE_OGG=1 -s USE_VORBIS=1 -s FULL_ES2=1)
|
||||
# FIXME
|
||||
set(ALLEGRO5_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_ACODEC_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_FONT_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_TTF_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_PRIMITIVES_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_AUDIO_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_ACODEC_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_IMAGE_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_COLOR_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
set(ALLEGRO5_VIDEO_INCLUDE_DIR ${ALLEGRO_INCLUDE_PATH})
|
||||
|
||||
if(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/output")
|
||||
endif(CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
|
||||
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
set(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
endif()
|
||||
|
||||
find_package(Allegro5 REQUIRED)
|
||||
find_package(Allegro5Font REQUIRED)
|
||||
find_package(Allegro5TTF REQUIRED)
|
||||
find_package(Allegro5Primitives REQUIRED)
|
||||
|
@ -78,6 +104,19 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
add_dependencies(${LIBSUPERDERPY_GAMENAME}_apk "libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}")
|
||||
endif()
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
string(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" CFLAGS)
|
||||
string(REPLACE " " ";" CFLAGS_L ${CMAKE_C_FLAGS})
|
||||
set(CFLAGS_LIST ${CFLAGS_L} ${${CFLAGS}})
|
||||
|
||||
add_custom_command(TARGET "libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}" POST_BUILD
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/gamestates"
|
||||
COMMAND "${CMAKE_C_COMPILER}" ${CFLAGS_LIST} libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}.so -s SIDE_MODULE=1 -o libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}.js
|
||||
VERBATIM
|
||||
)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/src/gamestates/libsuperderpy-${LIBSUPERDERPY_GAMENAME}-${name}.js" DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}/gamestates)
|
||||
endif()
|
||||
|
||||
ENDMACRO()
|
||||
|
||||
MACRO(libsuperderpy_copy EXECUTABLE)
|
||||
|
@ -103,6 +142,21 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
set(LIBSUPERDERPY_RELEASE "1")
|
||||
endif(NOT DEFINED LIBSUPERDERPY_RELEASE)
|
||||
|
||||
if (ANDROID OR EMSCRIPTEN)
|
||||
if (ANDROID)
|
||||
set(FLACTOOGG_DATADIR "${CMAKE_BINARY_DIR}/android/assets")
|
||||
set(FLACTOOGG_DEPEND "")
|
||||
else (EMSCRIPTEN)
|
||||
set(FLACTOOGG_DATADIR "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}/data")
|
||||
set(FLACTOOGG_DEPEND ${LIBSUPERDERPY_GAMENAME}_install)
|
||||
endif()
|
||||
|
||||
add_custom_target(${LIBSUPERDERPY_GAMENAME}_flac_to_ogg
|
||||
DEPENDS ${FLACTOOGG_DEPEND}
|
||||
COMMAND ${CMAKE_COMMAND} -DDATADIR=${FLACTOOGG_DATADIR} -P ${CMAKE_SOURCE_DIR}/libsuperderpy/cmake/FlacToOgg.cmake)
|
||||
|
||||
endif(ANDROID OR EMSCRIPTEN)
|
||||
|
||||
MACRO(add_libsuperderpy_target EXECUTABLE_SRC_LIST)
|
||||
if(ANDROID)
|
||||
set(EXECUTABLE game)
|
||||
|
@ -111,19 +165,20 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
set(APK_PATH ${CMAKE_BINARY_DIR}/android/bin/${LIBSUPERDERPY_GAMENAME}-debug.apk)
|
||||
|
||||
add_custom_target(${LIBSUPERDERPY_GAMENAME}_apk ALL
|
||||
DEPENDS ${EXECUTABLE}
|
||||
DEPENDS ${EXECUTABLE} ${LIBSUPERDERPY_GAMENAME}_flac_to_ogg
|
||||
BYPRODUCTS ${APK_PATH}
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/android"
|
||||
COMMAND ${ANT_COMMAND} debug
|
||||
)
|
||||
|
||||
add_custom_target(install_apk
|
||||
add_custom_target(${LIBSUPERDERPY_GAMENAME}_install_apk
|
||||
DEPENDS ${LIBSUPERDERPY_GAMENAME}_apk
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/android"
|
||||
COMMAND adb -d install -r ${APK_PATH}
|
||||
)
|
||||
|
||||
add_custom_target(run_apk
|
||||
DEPENDS install_apk
|
||||
add_custom_target(${LIBSUPERDERPY_GAMENAME}_run_apk
|
||||
DEPENDS ${LIBSUPERDERPY_GAMENAME}_install_apk
|
||||
COMMAND adb -d shell
|
||||
'am start -a android.intent.action.MAIN -n net.dosowisko.${LIBSUPERDERPY_GAMENAME}/.SuperDerpyActivity'
|
||||
)
|
||||
|
@ -131,6 +186,28 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
else(ANDROID)
|
||||
add_executable(${EXECUTABLE} WIN32 MACOSX_BUNDLE ${EXECUTABLE_SRC_LIST})
|
||||
endif(ANDROID)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
|
||||
add_custom_target(${LIBSUPERDERPY_GAMENAME}_install
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
COMMAND "${CMAKE_COMMAND}" --build . --target install
|
||||
)
|
||||
string(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" CFLAGS)
|
||||
string(REPLACE " " ";" CFLAGS_L ${CMAKE_C_FLAGS})
|
||||
set(CFLAGS_LIST ${CFLAGS_L} ${${CFLAGS}})
|
||||
|
||||
math(EXPR EMSCRIPTEN_TOTAL_MEMORY_BYTES "${EMSCRIPTEN_TOTAL_MEMORY} * 1024 * 1024")
|
||||
|
||||
|
||||
add_custom_target(${LIBSUPERDERPY_GAMENAME}_js
|
||||
DEPENDS ${LIBSUPERDERPY_GAMENAME}_install ${LIBSUPERDERPY_GAMENAME}_flac_to_ogg
|
||||
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}/${LIBSUPERDERPY_GAMENAME}"
|
||||
COMMAND "${CMAKE_C_COMPILER}" ${CFLAGS_LIST} ../${LIBSUPERDERPY_GAMENAME}.bc ../libsuperderpy.so ../libsuperderpy-${LIBSUPERDERPY_GAMENAME}.so ${ALLEGRO_LIBRARY_PATH} ${EMSCRIPTEN_USE_FLAGS} -s MAIN_MODULE=1 -s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY_BYTES} -o ${LIBSUPERDERPY_GAMENAME}.html --preload-file data --preload-file gamestates@/
|
||||
COMMAND rm -rf data gamestates
|
||||
VERBATIM
|
||||
)
|
||||
endif(EMSCRIPTEN)
|
||||
ENDMACRO()
|
||||
|
||||
if(ANDROID)
|
||||
|
|
|
@ -25,3 +25,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|||
set(CMAKE_PREFIX_PATH ${OSXCROSS_PATH}/SDK/MacOSX${OSXCROSS_SDK_VERSION}.sdk/usr)
|
||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${OSXCROSS_PATH}/macports/pkgs/opt/local/lib)
|
||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${OSXCROSS_PATH}/macports/pkgs/opt/local/include)
|
||||
|
||||
# Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not issue a warning on it being unused.
|
||||
if (CMAKE_TOOLCHAIN_FILE)
|
||||
endif()
|
||||
|
|
|
@ -10,3 +10,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(MINGDIR /usr/x86_64-w64-mingw32)
|
||||
|
||||
# Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not issue a warning on it being unused.
|
||||
if (CMAKE_TOOLCHAIN_FILE)
|
||||
endif()
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
SET(SRC_LIST
|
||||
utils.c
|
||||
config.c
|
||||
timeline.c
|
||||
gamestate.c
|
||||
libsuperderpy.c
|
||||
character.c
|
||||
internal.c
|
||||
)
|
||||
utils.c
|
||||
config.c
|
||||
timeline.c
|
||||
gamestate.c
|
||||
libsuperderpy.c
|
||||
character.c
|
||||
internal.c
|
||||
)
|
||||
if (EMSCRIPTEN)
|
||||
list(APPEND SRC_LIST emscripten-audio-stream.c)
|
||||
endif()
|
||||
|
||||
add_library("libsuperderpy" SHARED ${SRC_LIST})
|
||||
|
||||
|
|
238
src/emscripten-audio-stream.c
Normal file
238
src/emscripten-audio-stream.c
Normal file
|
@ -0,0 +1,238 @@
|
|||
/*! \file emscripten.c
|
||||
* \brief Emscripten stub implementations.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "emscripten.h"
|
||||
|
||||
#undef al_create_audio_stream
|
||||
#undef al_load_audio_stream
|
||||
#undef al_load_audio_stream_f
|
||||
#undef al_destroy_audio_stream
|
||||
#undef al_rewind_audio_stream
|
||||
#undef al_drain_audio_stream
|
||||
#undef al_attach_audio_stream_to_mixer
|
||||
#undef al_attach_audio_stream_to_voice
|
||||
#undef al_detach_audio_stream
|
||||
#undef al_seek_audio_stream_secs
|
||||
#undef al_get_audio_stream_frequency
|
||||
#undef al_get_audio_stream_channels
|
||||
#undef al_get_audio_stream_depth
|
||||
#undef al_get_audio_stream_length
|
||||
#undef al_get_audio_stream_speed
|
||||
#undef al_get_audio_stream_gain
|
||||
#undef al_get_audio_stream_pan
|
||||
#undef al_get_audio_stream_playing
|
||||
#undef al_get_audio_stream_playmode
|
||||
#undef al_get_audio_stream_attached
|
||||
#undef al_get_audio_stream_length_sec
|
||||
#undef al_get_audio_stream_position_secs
|
||||
#undef al_get_audio_stream_played_samples
|
||||
#undef al_get_audio_stream_fragment
|
||||
#undef al_get_audio_stream_fragments
|
||||
#undef al_get_available_audio_stream_fragments
|
||||
#undef al_get_audio_stream_event_source
|
||||
#undef al_set_audio_stream_fragment
|
||||
#undef al_set_audio_stream_loop_secs
|
||||
#undef al_set_audio_stream_gain
|
||||
#undef al_set_audio_stream_playing
|
||||
#undef al_set_audio_stream_playmode
|
||||
#undef al_set_audio_stream_speed
|
||||
#undef al_set_audio_stream_pan
|
||||
#ifdef ALLEGRO_UNSTABLE
|
||||
#undef al_set_audio_stream_channel_matrix
|
||||
#endif
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_AUDIO_STREAM *emscripten_load_audio_stream(const char* filename, size_t buffer_count, unsigned int samples) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *stream = calloc(1, sizeof(EMSCRIPTEN_AUDIO_STREAM));
|
||||
stream->sample = al_load_sample(filename);
|
||||
stream->instance = al_create_sample_instance(stream->sample);
|
||||
al_set_sample_instance_playing(stream->instance, true);
|
||||
return (ALLEGRO_AUDIO_STREAM*)stream;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_AUDIO_STREAM *emscripten_load_audio_stream_f(ALLEGRO_FILE *file, const char *ident, size_t buffer_count, unsigned int samples) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *stream = calloc(1, sizeof(EMSCRIPTEN_AUDIO_STREAM));
|
||||
stream->sample = al_load_sample_f(file, ident);
|
||||
stream->instance = al_create_sample_instance(stream->sample);
|
||||
al_set_sample_instance_playing(stream->instance, true);
|
||||
return (ALLEGRO_AUDIO_STREAM*)stream;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_gain(ALLEGRO_AUDIO_STREAM *stream, float val) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_gain(s->instance, val);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_playing(ALLEGRO_AUDIO_STREAM *stream, bool val) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_playing(s->instance, val);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_playmode(ALLEGRO_AUDIO_STREAM *stream, ALLEGRO_PLAYMODE mode) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_playmode(s->instance, mode);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_PLAYMODE emscripten_get_audio_stream_playmode(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_playmode(s->instance);
|
||||
}
|
||||
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_get_audio_stream_playing(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_playing(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_rewind_audio_stream(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_position(s->instance, 0);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_attach_audio_stream_to_mixer(ALLEGRO_AUDIO_STREAM *stream, ALLEGRO_MIXER *mixer) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_attach_sample_instance_to_mixer(s->instance, mixer);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_attach_audio_stream_to_voice(ALLEGRO_AUDIO_STREAM *stream, ALLEGRO_VOICE *voice) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_attach_sample_instance_to_voice(s->instance, voice);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_detach_audio_stream(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_detach_sample_instance(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_EVENT_SOURCE *emscripten_get_audio_stream_event_source(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void emscripten_drain_audio_stream(ALLEGRO_AUDIO_STREAM *stream) {}
|
||||
|
||||
SYMBOL_EXPORT unsigned int emscripten_get_audio_stream_frequency(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_frequency(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_CHANNEL_CONF emscripten_get_audio_stream_channels(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_channels(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT ALLEGRO_AUDIO_DEPTH emscripten_get_audio_stream_depth(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_depth(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT unsigned int emscripten_get_audio_stream_length(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_length(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT float emscripten_get_audio_stream_speed(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_speed(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT float emscripten_get_audio_stream_gain(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_gain(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT float emscripten_get_audio_stream_pan(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_pan(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_get_audio_stream_attached(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_attached(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_speed(ALLEGRO_AUDIO_STREAM *stream, float val) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_speed(s->instance, val);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_pan(ALLEGRO_AUDIO_STREAM *stream, float val) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_pan(s->instance, val);
|
||||
}
|
||||
|
||||
#ifdef ALLEGRO_UNSTABLE
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_channel_matrix(ALLEGRO_AUDIO_STREAM *stream, const float *val) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_channel_matrix(s->instance, val);
|
||||
}
|
||||
#endif
|
||||
|
||||
SYMBOL_EXPORT uint64_t emscripten_get_audio_stream_played_samples(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void *emscripten_get_audio_stream_fragment(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_fragment(ALLEGRO_AUDIO_STREAM *stream, void *val) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_set_audio_stream_loop_secs(ALLEGRO_AUDIO_STREAM *stream, double start, double end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SYMBOL_EXPORT unsigned int emscripten_get_audio_stream_fragments(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT unsigned int emscripten_get_available_audio_stream_fragments(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT double emscripten_get_audio_stream_length_sec(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
// FIXME
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_length(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT bool emscripten_seek_audio_stream_secs(ALLEGRO_AUDIO_STREAM *stream, double val) {
|
||||
// FIXME
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_set_sample_instance_position(s->instance, val);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT double emscripten_get_audio_stream_position_secs(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
// FIXME
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
return al_get_sample_instance_position(s->instance);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void emscripten_destroy_audio_stream(ALLEGRO_AUDIO_STREAM *stream) {
|
||||
EMSCRIPTEN_AUDIO_STREAM *s = (EMSCRIPTEN_AUDIO_STREAM*)stream;
|
||||
al_destroy_sample_instance(s->instance);
|
||||
al_destroy_sample(s->sample);
|
||||
}
|
||||
|
||||
ALLEGRO_AUDIO_STREAM* emscripten_create_audio_stream(size_t fragment_count, unsigned int frag_samples, unsigned int freq, ALLEGRO_AUDIO_DEPTH depth, ALLEGRO_CHANNEL_CONF chan_conf) {
|
||||
return NULL;
|
||||
}
|
110
src/emscripten-audio-stream.h
Normal file
110
src/emscripten-audio-stream.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*! \file emscripten.h
|
||||
* \brief Headers of main file of SuperDerpy engine.
|
||||
*
|
||||
* Contains basic functions shared by all views.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LIBSUPERDERPY_EMSCRIPTEN_H
|
||||
#define LIBSUPERDERPY_EMSCRIPTEN_H
|
||||
|
||||
typedef struct {
|
||||
ALLEGRO_SAMPLE *sample;
|
||||
ALLEGRO_SAMPLE_INSTANCE *instance;
|
||||
} EMSCRIPTEN_AUDIO_STREAM;
|
||||
|
||||
ALLEGRO_AUDIO_STREAM *emscripten_load_audio_stream(const char* filename, size_t buffer_count, unsigned int samples);
|
||||
ALLEGRO_AUDIO_STREAM *emscripten_load_audio_stream_f(ALLEGRO_FILE *file, const char *ident, size_t buffer_count, unsigned int samples);
|
||||
bool emscripten_set_audio_stream_gain(ALLEGRO_AUDIO_STREAM *stream, float val);
|
||||
bool emscripten_set_audio_stream_playing(ALLEGRO_AUDIO_STREAM *stream, bool val);
|
||||
bool emscripten_set_audio_stream_playmode(ALLEGRO_AUDIO_STREAM *stream, ALLEGRO_PLAYMODE mode);
|
||||
bool emscripten_get_audio_stream_playing(ALLEGRO_AUDIO_STREAM *stream);
|
||||
bool emscripten_get_audio_stream_attached(ALLEGRO_AUDIO_STREAM *stream);
|
||||
ALLEGRO_PLAYMODE emscripten_get_audio_stream_playmode(ALLEGRO_AUDIO_STREAM *stream);
|
||||
bool emscripten_rewind_audio_stream(ALLEGRO_AUDIO_STREAM *stream);
|
||||
bool emscripten_attach_audio_stream_to_mixer(ALLEGRO_AUDIO_STREAM *stream, ALLEGRO_MIXER *mixer);
|
||||
bool emscripten_attach_audio_stream_to_voice(ALLEGRO_AUDIO_STREAM *stream, ALLEGRO_VOICE *voice);
|
||||
bool emscripten_detach_audio_stream(ALLEGRO_AUDIO_STREAM *stream);
|
||||
unsigned int emscripten_get_audio_stream_frequency(ALLEGRO_AUDIO_STREAM *stream);
|
||||
ALLEGRO_CHANNEL_CONF emscripten_get_audio_stream_channels(ALLEGRO_AUDIO_STREAM *stream);
|
||||
ALLEGRO_AUDIO_DEPTH emscripten_get_audio_stream_depth(ALLEGRO_AUDIO_STREAM *stream);
|
||||
unsigned int emscripten_get_audio_stream_length(ALLEGRO_AUDIO_STREAM *stream);
|
||||
float emscripten_get_audio_stream_speed(ALLEGRO_AUDIO_STREAM *stream);
|
||||
float emscripten_get_audio_stream_gain(ALLEGRO_AUDIO_STREAM *stream);
|
||||
float emscripten_get_audio_stream_pan(ALLEGRO_AUDIO_STREAM *stream);
|
||||
bool emscripten_set_audio_stream_speed(ALLEGRO_AUDIO_STREAM *stream, float val);
|
||||
bool emscripten_set_audio_stream_pan(ALLEGRO_AUDIO_STREAM *stream, float val);
|
||||
double emscripten_get_audio_stream_length_sec(ALLEGRO_AUDIO_STREAM *stream) __attribute__((deprecated("not implemented yet for Emscripten")));
|
||||
bool emscripten_seek_audio_stream_secs(ALLEGRO_AUDIO_STREAM *stream, double val) __attribute__((deprecated("not implemented yet for Emscripten")));
|
||||
double emscripten_get_audio_stream_position_secs(ALLEGRO_AUDIO_STREAM *stream) __attribute__((deprecated("not implemented yet for Emscripten")));
|
||||
void emscripten_destroy_audio_stream(ALLEGRO_AUDIO_STREAM *stream);
|
||||
#ifdef ALLEGRO_UNSTABLE
|
||||
bool emscripten_set_audio_stream_channel_matrix(ALLEGRO_AUDIO_STREAM *stream, const float *val);
|
||||
#endif
|
||||
|
||||
uint64_t emscripten_get_audio_stream_played_samples(ALLEGRO_AUDIO_STREAM *stream) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
void *emscripten_get_audio_stream_fragment(ALLEGRO_AUDIO_STREAM *stream) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
bool emscripten_set_audio_stream_fragment(ALLEGRO_AUDIO_STREAM *stream, void *val) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
bool emscripten_set_audio_stream_loop_secs(ALLEGRO_AUDIO_STREAM *stream, double start, double end) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
unsigned int emscripten_get_audio_stream_fragments(ALLEGRO_AUDIO_STREAM *stream) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
unsigned int emscripten_get_available_audio_stream_fragments(ALLEGRO_AUDIO_STREAM *stream) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
ALLEGRO_EVENT_SOURCE *emscripten_get_audio_stream_event_source(ALLEGRO_AUDIO_STREAM *stream) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
void emscripten_drain_audio_stream(ALLEGRO_AUDIO_STREAM *stream) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
ALLEGRO_AUDIO_STREAM* emscripten_create_audio_stream(size_t fragment_count, unsigned int frag_samples, unsigned int freq, ALLEGRO_AUDIO_DEPTH depth, ALLEGRO_CHANNEL_CONF chan_conf) __attribute__((unavailable("won't work in Emscripten until proper audio stream support is fixed!")));
|
||||
|
||||
|
||||
#define al_create_audio_stream emscripten_create_audio_stream
|
||||
#define al_load_audio_stream emscripten_load_audio_stream
|
||||
#define al_load_audio_stream_f emscripten_load_audio_stream_f
|
||||
#define al_destroy_audio_stream emscripten_destroy_audio_stream
|
||||
#define al_rewind_audio_stream emscripten_rewind_audio_stream
|
||||
#define al_drain_audio_stream emscripten_drain_audio_stream
|
||||
#define al_attach_audio_stream_to_mixer emscripten_attach_audio_stream_to_mixer
|
||||
#define al_attach_audio_stream_to_voice emscripten_attach_audio_stream_to_voice
|
||||
#define al_detach_audio_stream emscripten_detach_audio_stream
|
||||
#define al_seek_audio_stream_secs emscripten_seek_audio_stream_secs
|
||||
#define al_get_audio_stream_playing emscripten_get_audio_stream_playing
|
||||
#define al_get_audio_stream_playmode emscripten_get_audio_stream_playmode
|
||||
#define al_get_audio_stream_attached emscripten_get_audio_stream_attached
|
||||
#define al_get_audio_stream_frequency emscripten_get_audio_stream_frequency
|
||||
#define al_get_audio_stream_channels emscripten_get_audio_stream_channels
|
||||
#define al_get_audio_stream_depth emscripten_get_audio_stream_depth
|
||||
#define al_get_audio_stream_length emscripten_get_audio_stream_length
|
||||
#define al_get_audio_stream_speed emscripten_get_audio_stream_speed
|
||||
#define al_get_audio_stream_gain emscripten_get_audio_stream_gain
|
||||
#define al_get_audio_stream_pan emscripten_get_audio_stream_pan
|
||||
#define al_get_audio_stream_length_sec emscripten_get_audio_stream_length_sec
|
||||
#define al_get_audio_stream_position_secs emscripten_get_audio_stream_position_secs
|
||||
#define al_get_audio_stream_played_samples emscripten_get_audio_stream_played_samples
|
||||
#define al_get_audio_stream_fragment emscripten_get_audio_stream_fragment
|
||||
#define al_get_audio_stream_fragments emscripten_get_audio_stream_fragments
|
||||
#define al_get_available_audio_stream_fragments emscripten_get_available_audio_stream_fragmenst
|
||||
#define al_get_audio_stream_event_source emscripten_get_audio_stream_event_source
|
||||
#define al_set_audio_stream_fragment emscripten_set_audio_stream_fragment
|
||||
#define al_set_audio_stream_loop_secs emscripten_set_audio_stream_loop_secs
|
||||
#define al_set_audio_stream_gain emscripten_set_audio_stream_gain
|
||||
#define al_set_audio_stream_playing emscripten_set_audio_stream_playing
|
||||
#define al_set_audio_stream_playmode emscripten_set_audio_stream_playmode
|
||||
#define al_set_audio_stream_speed emscripten_set_audio_stream_speed
|
||||
#define al_set_audio_stream_pan emscripten_set_audio_stream_pan
|
||||
#ifdef ALLEGRO_UNSTABLE
|
||||
#define al_set_audio_stream_channel_matrix emscripten_set_audio_stream_channel_matrix
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -197,7 +197,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
return NULL;
|
||||
}
|
||||
|
||||
game->audio.v = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.v = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.fx = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.music = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*! \file main.h
|
||||
* \brief Headers of main file of SuperDerpy engine.
|
||||
/*! \file libsuperderpy.h
|
||||
* \brief Headers of main file of libsuperderpy engine.
|
||||
*
|
||||
* Contains basic functions shared by all views.
|
||||
* Include this to use the engine functions.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
|
@ -34,6 +34,7 @@
|
|||
#endif
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#include "emscripten-audio-stream.h"
|
||||
#endif
|
||||
#include <sys/param.h>
|
||||
#include "gamestate.h"
|
||||
|
@ -46,17 +47,6 @@
|
|||
#define LIBSUPERDERPY_DATA_TYPE void
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define al_load_audio_stream(x,y,z) NULL
|
||||
#define al_set_audio_stream_playing(x, y)
|
||||
#define al_set_audio_stream_playmode(x, y)
|
||||
#define al_get_audio_stream_playing(x) true
|
||||
#define al_attach_audio_stream_to_mixer(x, y)
|
||||
#define al_set_audio_stream_gain(x, y)
|
||||
#define al_destroy_audio_stream(x)
|
||||
#define al_rewind_audio_stream(x)
|
||||
#endif
|
||||
|
||||
struct Gamestate;
|
||||
|
||||
struct Viewport {
|
||||
|
|
16
src/utils.c
16
src/utils.c
|
@ -335,6 +335,22 @@ SYMBOL_EXPORT char* GetDataFilePath(struct Game *game, char* filename) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (defined __EMSCRIPTEN__) || (defined ALLEGRO_ANDROID)
|
||||
char* file = AddGarbage(game, strdup(filename));
|
||||
char* sub = strstr(file, ".flac");
|
||||
if (sub) {
|
||||
sub[0] = '.';
|
||||
sub[1] = 'o';
|
||||
sub[2] = 'g';
|
||||
sub[3] = 'g';
|
||||
sub[4] = 0;
|
||||
}
|
||||
result = TestDataFilePath(game, file);
|
||||
if (result) {
|
||||
return AddGarbage(game, result);
|
||||
}
|
||||
#endif
|
||||
|
||||
result = TestDataFilePath(game, filename);
|
||||
if (result) {
|
||||
return AddGarbage(game, result);
|
||||
|
|
Loading…
Reference in a new issue