Implemented FFMpeg sound loading. Selecting sound library is controlled through the CMake file.

pull/7/head
Nicolay Korslund 15 years ago
parent 5d4dba981f
commit cad9712411

@ -1,5 +1,9 @@
project(OpenMW) project(OpenMW)
# Sound source selection
set(USE_AUDIERE "no")
set(USE_FFMPEG "yes")
# We probably support older versions than this. # We probably support older versions than this.
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
@ -93,13 +97,31 @@ set(OENGINE_GUI
${LIBDIR}/openengine/gui/events.cpp ${LIBDIR}/openengine/gui/events.cpp
${LIBDIR}/openengine/gui/manager.cpp ${LIBDIR}/openengine/gui/manager.cpp
) )
# Sound setup
if (USE_AUDIERE)
set(MANGLE_SOUND_OUTPUT
${LIBDIR}/mangle/sound/sources/audiere_source.cpp
${LIBDIR}/mangle/stream/clients/audiere_file.cpp)
find_package(Audiere REQUIRED)
set(SOUND_INPUT_LIBRARY ${AUDIERE_LIBRARY})
add_definitions(-DOPENMW_USE_AUDIERE)
endif (USE_AUDIERE)
if (USE_FFMPEG)
set(MANGLE_SOUND_OUTPUT
${LIBDIR}/mangle/sound/sources/ffmpeg_source.cpp)
find_package(FFMPEG REQUIRED)
set(SOUND_INPUT_LIBRARY ${FFMPEG_LIBRARIES})
add_definitions(-DOPENMW_USE_FFMPEG)
endif (USE_FFMPEG)
set(OENGINE_SOUND set(OENGINE_SOUND
# Mangle and OEngine sound files are sort of intertwined, so put # Mangle and OEngine sound files are sort of intertwined, so put
# them together here # them together here
${LIBDIR}/openengine/sound/sndmanager.cpp ${LIBDIR}/openengine/sound/sndmanager.cpp
${LIBDIR}/mangle/sound/sources/audiere_source.cpp
${LIBDIR}/mangle/sound/outputs/openal_out.cpp ${LIBDIR}/mangle/sound/outputs/openal_out.cpp
${LIBDIR}/mangle/stream/clients/audiere_file.cpp ${MANGLE_SOUND_OUTPUT}
) )
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_SOUND}) set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_SOUND})
source_group(libs\\openengine FILES ${OENGINE_ALL}) source_group(libs\\openengine FILES ${OENGINE_ALL})
@ -122,7 +144,6 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
find_package(OIS REQUIRED) find_package(OIS REQUIRED)
find_package(Iconv REQUIRED) find_package(Iconv REQUIRED)
find_package(OpenAL REQUIRED) find_package(OpenAL REQUIRED)
find_package(Audiere REQUIRED)
include_directories("." include_directories("."
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}

@ -184,7 +184,7 @@ target_link_libraries(openmw
${OIS_LIBRARIES} ${OIS_LIBRARIES}
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
${AUDIERE_LIBRARY} ${SOUND_INPUT_LIBRARY}
${ICONV_LIBRARIES} ${ICONV_LIBRARIES}
caelum caelum
MyGUIEngine MyGUIEngine

@ -5,17 +5,18 @@
#include <mangle/sound/clients/ogre_listener_mover.hpp> #include <mangle/sound/clients/ogre_listener_mover.hpp>
#include <mangle/sound/clients/ogre_output_updater.hpp> #include <mangle/sound/clients/ogre_output_updater.hpp>
/* Set up the sound manager to use Audiere for input (reading sound /* Set up the sound manager to use Audiere of FFMPEG for input. The
files) and OpenAL for output. OPENMW_USE_x macros are set in CMakeLists.txt.
*/ */
#ifdef OPENMW_USE_AUDIERE
#include <mangle/sound/filters/openal_audiere.hpp> #include <mangle/sound/filters/openal_audiere.hpp>
#define SOUND_FACTORY OpenAL_Audiere_Factory #define SOUND_FACTORY OpenAL_Audiere_Factory
/* #endif
We could allow several options for libraries via external #defines
if we like, controlled through CMake. The only things that need to #ifdef OPENMW_USE_FFMPEG
change is the include and #define above, and of course the linker #include <mangle/sound/filters/openal_ffmpeg.hpp>
parameters. #define SOUND_FACTORY OpenAL_FFMpeg_Factory
*/ #endif
using namespace Mangle::Sound; using namespace Mangle::Sound;
typedef OEngine::Sound::SoundManager OEManager; typedef OEngine::Sound::SoundManager OEManager;

@ -7,5 +7,5 @@ add_executable(sound_test main.cpp ${OENGINE_SOUND})
target_link_libraries(sound_test target_link_libraries(sound_test
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
${AUDIERE_LIBRARY} ${SOUND_INPUT_LIBRARY}
) )

@ -1,7 +1,6 @@
#include <iostream> #include <iostream>
#include <mangle/stream/servers/file_stream.hpp> #include <mangle/stream/servers/file_stream.hpp>
#include <mangle/sound/filters/openal_audiere.hpp>
#include <mangle/sound/sources/stream_source.hpp> #include <mangle/sound/sources/stream_source.hpp>
#include <mangle/stream/filters/buffer_stream.hpp> #include <mangle/stream/filters/buffer_stream.hpp>
@ -9,14 +8,23 @@ using namespace std;
using namespace Mangle::Stream; using namespace Mangle::Stream;
using namespace Mangle::Sound; using namespace Mangle::Sound;
#ifdef OPENMW_USE_AUDIERE
#include <mangle/sound/filters/openal_audiere.hpp>
AudiereLoader loader; AudiereLoader loader;
#endif
#ifdef OPENMW_USE_FFMPEG
#include <mangle/sound/filters/openal_ffmpeg.hpp>
FFMpegLoader loader;
#endif
OpenAL_Factory openal; OpenAL_Factory openal;
void play(const char* name) void play(const char* name)
{ {
try try
{ {
cout << "Opening " << name << " via Audiere\n"; cout << "Opening " << name << "\n";
SampleSourcePtr samples = loader.load(name); SampleSourcePtr samples = loader.load(name);
cout << "Loading entire file into memory\n"; cout << "Loading entire file into memory\n";
StreamPtr buf(new BufferStream(samples)); StreamPtr buf(new BufferStream(samples));

@ -0,0 +1,90 @@
# Find the FFmpeg library
#
# Sets
# FFMPEG_FOUND. If false, don't try to use ffmpeg
# FFMPEG_INCLUDE_DIR
# FFMPEG_LIBRARIES
#
# Modified by Nicolay Korslund for OpenMW
SET( FFMPEG_FOUND "NO" )
FIND_PATH( FFMPEG_avcodec_INCLUDE_DIR avcodec.h
HINTS
PATHS
/usr/include
/usr/local/include
/usr/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg/libavcodec
/usr/local/include/ffmpeg/libavcodec
/usr/include/libavcodec
/usr/local/include/libavcodec
)
FIND_PATH( FFMPEG_avformat_INCLUDE_DIR avformat.h
HINTS
PATHS
/usr/include
/usr/local/include
/usr/include/ffmpeg
/usr/local/include/ffmpeg
/usr/include/ffmpeg/libavformat
/usr/local/include/ffmpeg/libavformat
/usr/include/libavformat
/usr/local/include/libavformat
)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_avcodec_INCLUDE_DIR} ${FFMPEG_avformat_INCLUDE_DIR})
IF( FFMPEG_INCLUDE_DIR )
FIND_PROGRAM( FFMPEG_CONFIG ffmpeg-config
/usr/bin
/usr/local/bin
${HOME}/bin
)
IF( FFMPEG_CONFIG )
EXEC_PROGRAM( ${FFMPEG_CONFIG} ARGS "--libs avformat" OUTPUT_VARIABLE FFMPEG_LIBS )
SET( FFMPEG_FOUND "YES" )
SET( FFMPEG_LIBRARIES "${FFMPEG_LIBS}" )
ELSE( FFMPEG_CONFIG )
FIND_LIBRARY( FFMPEG_avcodec_LIBRARY avcodec
/usr/lib
/usr/local/lib
/usr/lib64
/usr/local/lib64
)
FIND_LIBRARY( FFMPEG_avformat_LIBRARY avformat
/usr/lib
/usr/local/lib
/usr/lib64
/usr/local/lib64
)
FIND_LIBRARY( FFMPEG_avutil_LIBRARY avutil
/usr/lib
/usr/local/lib
/usr/lib64
/usr/local/lib64
)
IF( FFMPEG_avcodec_LIBRARY )
IF( FFMPEG_avformat_LIBRARY )
SET( FFMPEG_FOUND "YES" )
SET( FFMPEG_LIBRARIES ${FFMPEG_avformat_LIBRARY} ${FFMPEG_avcodec_LIBRARY} )
IF( FFMPEG_avutil_LIBRARY )
SET( FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_avutil_LIBRARY} )
ENDIF( FFMPEG_avutil_LIBRARY )
ENDIF( FFMPEG_avformat_LIBRARY )
ENDIF( FFMPEG_avcodec_LIBRARY )
ENDIF( FFMPEG_CONFIG )
ENDIF( FFMPEG_INCLUDE_DIR )

@ -1 +1 @@
Subproject commit f95ea1677cc5c52790e1342aa6d3d6bba950b8be Subproject commit 160e8655d2503ad93992200d6d131186ede22aa3
Loading…
Cancel
Save