sound fix
parent
a6ff654ae3
commit
f0e76ad446
|
@ -38,6 +38,8 @@ option(CBOT_STATIC "Build CBot as static libary" OFF)
|
||||||
# Doxygen docs are optional for installation
|
# Doxygen docs are optional for installation
|
||||||
option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
|
option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
|
||||||
|
|
||||||
|
# Build openal sound support
|
||||||
|
option(OPENAL_SOUND "Build openal sound support" OFF)
|
||||||
|
|
||||||
##
|
##
|
||||||
# Required packages
|
# Required packages
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
# Find the native LTDL includes and library
|
|
||||||
# Copied verbatim from
|
|
||||||
# http://code.metager.de/source/xref/hshannover/trust/tnc-fhh/shared/cmake_modules/FindLTDL.cmake
|
|
||||||
# The above version was under GPL-2, this one is under GPL-3, for consistency
|
|
||||||
# with the rest of the colobot project.
|
|
||||||
#
|
|
||||||
# This module defines
|
|
||||||
# LTDL_INCLUDE_DIR, where to find ltdl.h, etc.
|
|
||||||
# LTDL_LIBRARY, where to find the LTDL library.
|
|
||||||
# LTDL_FOUND, If false, do not try to use LTDL.
|
|
||||||
|
|
||||||
FIND_PATH(LTDL_INCLUDE_DIR ltdl.h)
|
|
||||||
|
|
||||||
FIND_LIBRARY(LTDL_LIBRARY ltdl)
|
|
||||||
|
|
||||||
IF (LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
|
|
||||||
SET(LTDL_FOUND TRUE)
|
|
||||||
ELSE(LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
|
|
||||||
SET(LTDL_FOUND FALSE)
|
|
||||||
ENDIF (LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
|
|
||||||
|
|
||||||
IF (LTDL_FOUND)
|
|
||||||
IF (NOT LTDL_FIND_QUIETLY)
|
|
||||||
MESSAGE(STATUS "Found LTDL: ${LTDL_LIBRARY}")
|
|
||||||
ENDIF (NOT LTDL_FIND_QUIETLY)
|
|
||||||
ELSE (LTDL_FOUND)
|
|
||||||
IF (LTDL_FIND_REQUIRED)
|
|
||||||
MESSAGE(FATAL_ERROR "Could not find LTDL")
|
|
||||||
ENDIF (LTDL_FIND_REQUIRED)
|
|
||||||
ENDIF (LTDL_FOUND)
|
|
|
@ -23,6 +23,7 @@ if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libjpeg.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libjpeg.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libwinmm.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libwinmm.a
|
||||||
${CMAKE_FIND_ROOT_PATH}/lib/libdxguid.a
|
${CMAKE_FIND_ROOT_PATH}/lib/libdxguid.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libbz2.a
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
set(MXE 0)
|
set(MXE 0)
|
||||||
|
|
|
@ -16,6 +16,5 @@ if(${CBOT_STATIC})
|
||||||
add_library(CBot STATIC ${SOURCES})
|
add_library(CBot STATIC ${SOURCES})
|
||||||
else()
|
else()
|
||||||
add_library(CBot SHARED ${SOURCES})
|
add_library(CBot SHARED ${SOURCES})
|
||||||
|
install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR})
|
|
||||||
|
|
|
@ -27,9 +27,24 @@ endif()
|
||||||
|
|
||||||
# Additional libraries per platform
|
# Additional libraries per platform
|
||||||
set(PLATFORM_LIBS "")
|
set(PLATFORM_LIBS "")
|
||||||
|
set(OPENAL_LIBS "")
|
||||||
|
|
||||||
|
if (${OPENAL_SOUND})
|
||||||
|
if (${MXE})
|
||||||
|
set(OPENAL_LIBS
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libOpenAL32.a
|
||||||
|
${CMAKE_FIND_ROOT_PATH}/lib/libalut.a
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(OPENAL_LIBS
|
||||||
|
openal
|
||||||
|
alut
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${MXE}) # MXE requires special treatment
|
if (${MXE}) # MXE requires special treatment
|
||||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
set(PLATFORM_LIBS ${MXE_LIBS})
|
||||||
elseif (${PLATFORM_WINDOWS})
|
elseif (${PLATFORM_WINDOWS})
|
||||||
# because it isn't included in standard linking libraries
|
# because it isn't included in standard linking libraries
|
||||||
set(PLATFORM_LIBS "-lintl")
|
set(PLATFORM_LIBS "-lintl")
|
||||||
|
@ -42,6 +57,15 @@ endif()
|
||||||
# Configure file
|
# Configure file
|
||||||
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
|
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
|
||||||
|
|
||||||
|
set(OPENAL_SRC "")
|
||||||
|
|
||||||
|
if (${OPENAL_SOUND})
|
||||||
|
set(OPENAL_SRC
|
||||||
|
sound/oalsound/alsound.cpp
|
||||||
|
sound/oalsound/buffer.cpp
|
||||||
|
sound/oalsound/channel.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Source files
|
# Source files
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
@ -160,8 +184,10 @@ ui/slider.cpp
|
||||||
ui/studio.cpp
|
ui/studio.cpp
|
||||||
ui/target.cpp
|
ui/target.cpp
|
||||||
ui/window.cpp
|
ui/window.cpp
|
||||||
|
${OPENAL_SRC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
set(LIBS
|
set(LIBS
|
||||||
${SDL_LIBRARY}
|
${SDL_LIBRARY}
|
||||||
${SDLIMAGE_LIBRARY}
|
${SDLIMAGE_LIBRARY}
|
||||||
|
@ -172,6 +198,7 @@ ${OPTIONAL_LIBS}
|
||||||
${PLATFORM_LIBS}
|
${PLATFORM_LIBS}
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
CBot
|
CBot
|
||||||
|
${OPENAL_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
|
|
@ -89,7 +89,6 @@ CApplication::CApplication()
|
||||||
m_private = new ApplicationPrivate();
|
m_private = new ApplicationPrivate();
|
||||||
m_iMan = new CInstanceManager();
|
m_iMan = new CInstanceManager();
|
||||||
m_eventQueue = new CEventQueue(m_iMan);
|
m_eventQueue = new CEventQueue(m_iMan);
|
||||||
m_pluginManager = new CPluginManager();
|
|
||||||
m_profile = new CProfile();
|
m_profile = new CProfile();
|
||||||
|
|
||||||
m_engine = nullptr;
|
m_engine = nullptr;
|
||||||
|
@ -158,9 +157,6 @@ CApplication::~CApplication()
|
||||||
delete m_eventQueue;
|
delete m_eventQueue;
|
||||||
m_eventQueue = nullptr;
|
m_eventQueue = nullptr;
|
||||||
|
|
||||||
delete m_pluginManager;
|
|
||||||
m_pluginManager = nullptr;
|
|
||||||
|
|
||||||
delete m_profile;
|
delete m_profile;
|
||||||
m_profile = nullptr;
|
m_profile = nullptr;
|
||||||
|
|
||||||
|
@ -336,8 +332,7 @@ bool CApplication::Create()
|
||||||
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
|
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
|
||||||
m_dataPath = path;
|
m_dataPath = path;
|
||||||
|
|
||||||
m_pluginManager->LoadFromProfile();
|
m_sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
|
||||||
m_sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
|
|
||||||
|
|
||||||
if (!m_sound) {
|
if (!m_sound) {
|
||||||
GetLogger()->Error("Sound not loaded, falling back to fake sound!\n");
|
GetLogger()->Error("Sound not loaded, falling back to fake sound!\n");
|
||||||
|
|
|
@ -25,13 +25,12 @@
|
||||||
|
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
#include "common/profile.h"
|
||||||
|
|
||||||
#include "graphics/core/device.h"
|
#include "graphics/core/device.h"
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
#include "graphics/opengl/gldevice.h"
|
#include "graphics/opengl/gldevice.h"
|
||||||
|
|
||||||
#include "plugins/pluginmanager.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -337,7 +336,6 @@ protected:
|
||||||
CSoundInterface* m_sound;
|
CSoundInterface* m_sound;
|
||||||
//! Main class of the proper game engine
|
//! Main class of the proper game engine
|
||||||
CRobotMain* m_robotMain;
|
CRobotMain* m_robotMain;
|
||||||
CPluginManager* m_pluginManager;
|
|
||||||
CProfile* m_profile;
|
CProfile* m_profile;
|
||||||
|
|
||||||
//! Code to return at exit
|
//! Code to return at exit
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
set(SOURCES
|
|
||||||
alsound.cpp
|
|
||||||
buffer.cpp
|
|
||||||
channel.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x -fPIC")
|
|
||||||
SET (CMAKE_CXX_FLAGS_DEBUG "-g")
|
|
||||||
|
|
||||||
include(FindPkgConfig)
|
|
||||||
include(FindOpenAL)
|
|
||||||
pkg_check_modules(OPENAL_LIB REQUIRED openal)
|
|
||||||
|
|
||||||
set(OPENAL_LIBRARIES
|
|
||||||
openal
|
|
||||||
alut
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(../../..)
|
|
||||||
include_directories(.)
|
|
||||||
add_library(openalsound SHARED ${SOURCES})
|
|
||||||
target_link_libraries(openalsound ${OPENAL_LIBRARIES})
|
|
|
@ -23,51 +23,23 @@
|
||||||
|
|
||||||
#define MIN(a, b) (a > b ? b : a)
|
#define MIN(a, b) (a > b ? b : a)
|
||||||
|
|
||||||
|
|
||||||
PLUGIN_INTERFACE(ALSound)
|
|
||||||
|
|
||||||
|
|
||||||
std::string ALSound::PluginName()
|
|
||||||
{
|
|
||||||
return "Sound plugin using OpenAL library to play sounds.";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int ALSound::PluginVersion()
|
|
||||||
{
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ALSound::InstallPlugin()
|
|
||||||
{
|
|
||||||
auto pointer = CInstanceManager::GetInstancePointer();
|
|
||||||
if (pointer != nullptr)
|
|
||||||
CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ALSound::UninstallPlugin(std::string &reason)
|
|
||||||
{
|
|
||||||
auto pointer = CInstanceManager::GetInstancePointer();
|
|
||||||
if (pointer != nullptr)
|
|
||||||
CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
|
|
||||||
CleanUp();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ALSound::ALSound()
|
ALSound::ALSound()
|
||||||
{
|
{
|
||||||
mEnabled = false;
|
mEnabled = false;
|
||||||
m3D = false;
|
m3D = false;
|
||||||
mAudioVolume = MAXVOLUME;
|
mAudioVolume = MAXVOLUME;
|
||||||
mMute = false;
|
mMute = false;
|
||||||
|
auto pointer = CInstanceManager::GetInstancePointer();
|
||||||
|
if (pointer != nullptr)
|
||||||
|
CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ALSound::~ALSound()
|
ALSound::~ALSound()
|
||||||
{
|
{
|
||||||
|
auto pointer = CInstanceManager::GetInstancePointer();
|
||||||
|
if (pointer != nullptr)
|
||||||
|
CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
|
||||||
CleanUp();
|
CleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_BUILD_TYPE debug)
|
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -rdynamic")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
|
||||||
|
|
||||||
add_executable(plugin_test plugin_test.cpp ../../../../common/iman.cpp ../../../../common/logger.cpp ../../../../plugins/pluginloader.cpp)
|
|
||||||
|
|
||||||
include_directories(".")
|
|
||||||
include_directories("../../../../")
|
|
||||||
|
|
||||||
target_link_libraries(plugin_test ${LTDL_LIBRARY})
|
|
|
@ -1,40 +0,0 @@
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <common/logger.h>
|
|
||||||
#include <common/iman.h>
|
|
||||||
#include <sound/sound.h>
|
|
||||||
#include <plugins/pluginloader.h>
|
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
new CLogger();
|
|
||||||
new CInstanceManager();
|
|
||||||
|
|
||||||
lt_dlinit();
|
|
||||||
|
|
||||||
CPluginLoader *plugin = new CPluginLoader("libopenalsound");
|
|
||||||
if (plugin->LoadPlugin()) {
|
|
||||||
CSoundInterface *sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
|
|
||||||
|
|
||||||
sound->Create(true);
|
|
||||||
sound->CacheAll();
|
|
||||||
sound->Play((Sound)8);
|
|
||||||
sound->Play((Sound)18);
|
|
||||||
|
|
||||||
sleep(10);
|
|
||||||
/*
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
// just a test, very slow
|
|
||||||
plugin->FrameMove(0);
|
|
||||||
//if ('n' == getchar())
|
|
||||||
// break;
|
|
||||||
}*/
|
|
||||||
plugin->UnloadPlugin();
|
|
||||||
}
|
|
||||||
|
|
||||||
lt_dlexit();
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue