From 912c8b1f2d23055e43f1c11200e57d6b33f72cd5 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Fri, 13 Aug 2010 22:30:22 +0200 Subject: [PATCH] Added mpg123 file reader --- CMakeLists.txt | 17 +++++++--- apps/openmw/CMakeLists.txt | 5 +++ apps/openmw/mwsound/soundmanager.cpp | 5 +++ apps/soundtest/CMakeLists.txt | 3 ++ apps/soundtest/main.cpp | 5 +++ cmake/FindMPG123.cmake | 47 ++++++++++++++++++++++++++++ libs/mangle | 2 +- 7 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 cmake/FindMPG123.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a0a945f97..c7edb10721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,8 @@ project(OpenMW) # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) -option(USE_FFMPEG "use ffmpeg for sound" ON) +option(USE_FFMPEG "use ffmpeg for sound" OFF) +option(USE_MPG123 "use mpg123 for sound" ON) # We probably support older versions than this. cmake_minimum_required(VERSION 2.6) @@ -106,7 +107,7 @@ if (USE_AUDIERE) find_package(Audiere REQUIRED) set(SOUND_INPUT_INCLUDES ${AUDIERE_INCLUDE_DIR}) set(SOUND_INPUT_LIBRARY ${AUDIERE_LIBRARY}) - add_definitions(-DOPENMW_USE_AUDIERE) + set(SOUND_DEFINE -DOPENMW_USE_AUDIERE) endif (USE_AUDIERE) if (USE_FFMPEG) @@ -115,9 +116,18 @@ if (USE_FFMPEG) find_package(FFMPEG REQUIRED) set(SOUND_INPUT_INCLUDES ${FFMPEG_INCLUDE_DIR}) set(SOUND_INPUT_LIBRARY ${FFMPEG_LIBRARIES}) - add_definitions(-DOPENMW_USE_FFMPEG) + set(SOUND_DEFINE -DOPENMW_USE_FFMPEG) endif (USE_FFMPEG) +if (USE_MPG123) + set(MANGLE_SOUND_OUTPUT + ${LIBDIR}/mangle/sound/sources/mpg123_source.cpp) + find_package(MPG123 REQUIRED) + set(SOUND_INPUT_INCLUDES ${MPG123_INCLUDE_DIR}) + set(SOUND_INPUT_LIBRARY ${MPG123_LIBRARY}) + set(SOUND_DEFINE -DOPENMW_USE_MPG123) +endif (USE_MPG123) + set(OENGINE_SOUND # Mangle and OEngine sound files are sort of intertwined, so put # them together here @@ -150,7 +160,6 @@ include_directories("." ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${ICONV_INCLUDE_DIR} - ${SOUND_INPUT_INCLUDES} ${PLATFORM_INCLUDE_DIR} ${CMAKE_HOME_DIRECTORY}/extern/caelum/include ${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index a4a6f6c278..87cc31954e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -179,6 +179,11 @@ add_executable(openmw ${APPLE_BUNDLE_RESOURCES} ) +# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING +# when we change the backend. +include_directories(${SOUND_INPUT_INCLUDES}) +add_definitions(${SOUND_DEFINE}) + target_link_libraries(openmw ${OGRE_LIBRARIES} ${OIS_LIBRARIES} diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 1754fdf285..28b4ef6cad 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -18,6 +18,11 @@ #define SOUND_FACTORY OpenAL_FFMpeg_Factory #endif +#ifdef OPENMW_USE_MPG123 +#include +#define SOUND_FACTORY OpenAL_Mpg123_Factory +#endif + using namespace Mangle::Sound; typedef OEngine::Sound::SoundManager OEManager; typedef OEngine::Sound::SoundManagerPtr OEManagerPtr; diff --git a/apps/soundtest/CMakeLists.txt b/apps/soundtest/CMakeLists.txt index 71c870e042..b7ff040398 100644 --- a/apps/soundtest/CMakeLists.txt +++ b/apps/soundtest/CMakeLists.txt @@ -5,6 +5,9 @@ project(SoundTest) # Main executable add_executable(sound_test main.cpp ${OENGINE_SOUND}) +include_directories(${SOUND_INPUT_INCLUDES}) +add_definitions(${SOUND_DEFINE}) + target_link_libraries(sound_test ${OPENAL_LIBRARY} ${SOUND_INPUT_LIBRARY} diff --git a/apps/soundtest/main.cpp b/apps/soundtest/main.cpp index 1e88020e10..dde76d9bd1 100644 --- a/apps/soundtest/main.cpp +++ b/apps/soundtest/main.cpp @@ -18,6 +18,11 @@ AudiereLoader loader; FFMpegLoader loader; #endif +#ifdef OPENMW_USE_MPG123 +#include +Mpg123Loader loader; +#endif + OpenAL_Factory openal; void play(const char* name) diff --git a/cmake/FindMPG123.cmake b/cmake/FindMPG123.cmake new file mode 100644 index 0000000000..51e562c910 --- /dev/null +++ b/cmake/FindMPG123.cmake @@ -0,0 +1,47 @@ +# Locate MPG123 +# This module defines +# MPG123_LIBRARY +# MPG123_FOUND, if false, do not try to link to Mpg123 +# MPG123_INCLUDE_DIR, where to find the headers +# +# Created by Nicolay Korslund for OpenMW (http://openmw.com) +# +# Ripped off from other sources. In fact, this file is so generic (I +# just did a search and replace on another file) that I wonder why the +# CMake guys haven't wrapped this entire thing in a single +# function. Do we really need to repeat this stuff for every single +# library when they all work the same? + +FIND_PATH(MPG123_INCLUDE_DIR mpg123.h + HINTS + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +FIND_LIBRARY(MPG123_LIBRARY + NAMES mpg123 + HINTS + PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt +) + +SET(MPG123_FOUND "NO") +IF(MPG123_LIBRARY AND MPG123_INCLUDE_DIR) + SET(MPG123_FOUND "YES") +ENDIF(MPG123_LIBRARY AND MPG123_INCLUDE_DIR) + diff --git a/libs/mangle b/libs/mangle index dc0c026ce0..5b8e8d6b48 160000 --- a/libs/mangle +++ b/libs/mangle @@ -1 +1 @@ -Subproject commit dc0c026ce054a96cdd4093237031ca63048a7393 +Subproject commit 5b8e8d6b48847cd99d14064e8c7a1115efdd4fed