This commit is contained in:
sfb 2012-04-18 11:08:44 -05:00
commit 3c1895960c
369 changed files with 5093 additions and 2872 deletions

View file

@ -54,10 +54,14 @@ ELSE(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
IF(MYSQL_INCLUDE_DIR)
IF(MYSQL_LIBRARY_RELEASE)
SET(MYSQL_LIBRARIES "optimized;${MYSQL_LIBRARY_RELEASE}")
SET(MYSQL_LIBRARIES optimized ${MYSQL_LIBRARY_RELEASE})
IF(MYSQL_LIBRARY_DEBUG)
SET(MYSQL_LIBRARIES "${MYSQL_LIBRARIES};debug;${MYSQL_LIBRARY_DEBUG}")
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} debug ${MYSQL_LIBRARY_DEBUG})
ENDIF(MYSQL_LIBRARY_DEBUG)
FIND_PACKAGE(OpenSSL)
IF(OPENSSL_FOUND)
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${OPENSSL_LIBRARIES})
ENDIF(OPENSSL_FOUND)
ENDIF(MYSQL_LIBRARY_RELEASE)
ENDIF(MYSQL_INCLUDE_DIR)

View file

@ -25,7 +25,8 @@ MACRO(NOW RESULT)
STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}")
ENDIF(NOT DATETIME MATCHES "ERROR")
ELSEIF(UNIX)
EXECUTE_PROCESS(COMMAND "date" "+'%Y-%m-%d %H:%M:%S'" OUTPUT_VARIABLE ${RESULT})
EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME)
STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}")
ELSE (WIN32)
MESSAGE(SEND_ERROR "date not implemented")
SET(${RESULT} "0000-00-00 00:00:00")

View file

@ -1,3 +1,11 @@
# Force Release configuration for compiler checks
SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release")
# Force Release configuration by default
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
###
# Helper macro that generates .pc and installs it.
# Argument: name - the name of the .pc package, e.g. "nel-pacs.pc"
@ -5,7 +13,11 @@
MACRO(NL_GEN_PC name)
IF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}")
IF(CMAKE_LIBRARY_ARCHITECTURE)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig)
ELSE(CMAKE_LIBRARY_ARCHITECTURE)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/pkgconfig)
ENDIF(CMAKE_LIBRARY_ARCHITECTURE)
ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
ENDMACRO(NL_GEN_PC)
@ -186,7 +198,7 @@ Remove the CMakeCache.txt file and try again from another folder, e.g.:
rm CMakeCache.txt
mkdir cmake
cd cmake
cmake -G \"Unix Makefiles\" ..
cmake ..
")
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
@ -231,6 +243,17 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
###
# Optional support
###
# Check if CMake is launched from a Debian packaging script
SET(DEB_HOST_GNU_CPU $ENV{DEB_HOST_GNU_CPU})
# Don't strip if generating a .deb
IF(DEB_HOST_GNU_CPU)
OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" ON )
ELSE(DEB_HOST_GNU_CPU)
OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF)
ENDIF(DEB_HOST_GNU_CPU)
IF(WIN32)
OPTION(WITH_STLPORT "With STLport support." ON )
ELSE(WIN32)
@ -334,6 +357,12 @@ MACRO(NL_SETUP_BUILD)
SET(HOST_CPU ${CMAKE_SYSTEM_PROCESSOR})
IF(HOST_CPU MATCHES "amd64")
SET(HOST_CPU "x86_64")
ELSEIF(HOST_CPU MATCHES "i.86")
SET(HOST_CPU "x86")
ENDIF(HOST_CPU MATCHES "amd64")
# Determine target CPU
IF(NOT TARGET_CPU)
SET(TARGET_CPU $ENV{DEB_HOST_GNU_CPU})
@ -376,19 +405,27 @@ MACRO(NL_SETUP_BUILD)
IF(TARGET_CPU STREQUAL "x86_64")
SET(TARGET_X64 1)
SET(PLATFORM_CFLAGS "-DHAVE_X86_64")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86_64")
ELSEIF(TARGET_CPU STREQUAL "x86")
SET(TARGET_X86 1)
SET(PLATFORM_CFLAGS "-DHAVE_X86")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86")
ENDIF(TARGET_CPU STREQUAL "x86_64")
# Fix library paths suffixes for Debian MultiArch
IF(NOT CMAKE_LIBRARY_ARCHITECTURE)
SET(CMAKE_LIBRARY_ARCHITECTURE $ENV{DEB_HOST_MULTIARCH})
ENDIF(NOT CMAKE_LIBRARY_ARCHITECTURE)
SET(DEBIAN_MULTIARCH $ENV{DEB_HOST_MULTIARCH})
IF(DEBIAN_MULTIARCH)
SET(CMAKE_LIBRARY_ARCHITECTURE ${DEBIAN_MULTIARCH})
ENDIF(DEBIAN_MULTIARCH)
IF(CMAKE_LIBRARY_ARCHITECTURE)
SET(CMAKE_LIBRARY_PATH "/lib/${CMAKE_LIBRARY_ARCHITECTURE};/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE};${CMAKE_LIBRARY_PATH}")
SET(CMAKE_LIBRARY_PATH /lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
IF(TARGET_X64)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)
ENDIF(TARGET_X64)
IF(TARGET_X86)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)
ENDIF(TARGET_X86)
ENDIF(CMAKE_LIBRARY_ARCHITECTURE)
IF(MSVC)
@ -411,10 +448,10 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC10)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000 /MP /Gy-")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zm1000 /MP /Gy-")
# Common link flags
SET(PLATFORM_LINKFLAGS "-DEBUG")
SET(PLATFORM_LINKFLAGS "")
IF(TARGET_X64)
# Fix a bug with Intellisense
@ -429,10 +466,17 @@ MACRO(NL_SETUP_BUILD)
# Exceptions are only set for C++
SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa")
SET(NL_DEBUG_CFLAGS "/MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS}")
SET(NL_RELEASE_CFLAGS "/MD /D NDEBUG ${SPEED_OPTIMIZATIONS}")
SET(NL_DEBUG_LINKFLAGS "/NODEFAULTLIB:msvcrt /INCREMENTAL:YES")
SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO")
IF(WITH_SYMBOLS)
SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}")
SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}")
ELSE(WITH_SYMBOLS)
SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")
ENDIF(WITH_SYMBOLS)
SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS} ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${SPEED_OPTIMIZATIONS} ${NL_RELEASE_CFLAGS}")
SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt /INCREMENTAL:YES ${NL_DEBUG_LINKFLAGS}")
SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}")
ELSE(MSVC)
IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m32 -march=i686")
@ -442,7 +486,11 @@ MACRO(NL_SETUP_BUILD)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m64")
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -g -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -ansi -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
IF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -ansi")
ENDIF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
IF(WITH_COVERAGE)
SET(PLATFORM_CFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CFLAGS}")
@ -463,8 +511,16 @@ MACRO(NL_SETUP_BUILD)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed")
ENDIF(NOT APPLE)
SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG")
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O6")
IF(WITH_SYMBOLS)
SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g")
ELSE(WITH_SYMBOLS)
IF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}")
ENDIF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
ENDIF(WITH_SYMBOLS)
SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}")
ENDIF(MSVC)
ENDMACRO(NL_SETUP_BUILD)
@ -615,23 +671,33 @@ MACRO(SETUP_EXTERNAL)
ENDIF(WITH_EXTERNAL)
IF(WIN32)
INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
FIND_PACKAGE(External REQUIRED)
IF(MSVC10)
IF(NOT MSVC10_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC10_REDIST_DIR)
IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR)
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config;InstallDir]" ABSOLUTE)
# VC_ROOT_DIR is set to "registry" when a key is not found
IF(VC_ROOT_DIR MATCHES "registry")
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
FILE(TO_CMAKE_PATH $ENV{VS100COMNTOOLS} VC_ROOT_DIR)
IF(NOT VC_ROOT_DIR)
MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!")
ENDIF(NOT VC_ROOT_DIR)
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(NOT VC_ROOT_DIR)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR)
ELSE(MSVC10)
IF(NOT VC_DIR)
IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM})
@ -639,6 +705,7 @@ MACRO(SETUP_EXTERNAL)
# convert compiler fullpath to VC++ path
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
ENDIF(NOT VC_DIR)
ENDIF(MSVC10)
ELSE(WIN32)
IF(APPLE)
@ -659,12 +726,12 @@ MACRO(SETUP_EXTERNAL)
IF(WITH_STLPORT)
FIND_PACKAGE(STLport REQUIRED)
INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR})
IF(WIN32)
IF(MSVC)
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
FIND_PACKAGE(WindowsSDK REQUIRED)
# use VC++ and Windows SDK include paths
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
ENDIF(WIN32)
ENDIF(MSVC)
ENDIF(WITH_STLPORT)
ENDMACRO(SETUP_EXTERNAL)

View file

@ -27,12 +27,16 @@
#include <vector>
#include <limits>
namespace NLMISC {
class CMatrix;
}
namespace NL3D {
class CTextureFont;
class CMatrix;
struct CComputedString;
// ***************************************************************************

View file

@ -227,7 +227,7 @@ void CCubeGrid<TCell>::compile()
// build the _StaticGrid
_StaticGrids[i].build(_Grids[i]);
// And reset the grid. contReset is necessary to clean the CBlockMemory.
contReset(_Grids[i]);
NLMISC::contReset(_Grids[i]);
}
// done

View file

@ -782,7 +782,7 @@ inline void CIndexBuffer::lock (CIndexBufferRead &accessor, uint first, uint las
// ***************************************************************************
inline void CIndexBuffer::unlock (uint first, uint end)
inline void CIndexBuffer::unlock (uint /* first */, uint /* end */)
{
nlassertex (_LockCounter!=0, ("Index buffer not locked"));
nlassert (_LockedBuffer || (!isResident() && _NonResidentIndexes.empty()));

View file

@ -147,7 +147,7 @@ public:
static void addTriangles (const IShape &shape, const NLMISC::CMatrix& modelMT, std::vector<CTriangle>& triangleArray, sint instanceId);
// Progress callback
virtual void progress (const char *message, float progress) {}
virtual void progress (const char * /* message */, float /* progress */) {}
/// \name Static PointLights mgt.

View file

@ -96,7 +96,7 @@ public:
try
{
newStart = new uint8[sizeof(T) * capacity + (1 << snapPower)];
T *newTab = (T *) ( (uint) (newStart + (1 << snapPower)) & ~((1 << snapPower) - 1)); // snap to a page
T *newTab = (T *) ( (size_t) (newStart + (1 << snapPower)) & ~((1 << snapPower) - 1)); // snap to a page

View file

@ -157,7 +157,7 @@ public:
}
/// return true if an operation is supported. The default support all ops
bool supportOp(CPSBinOp::BinOp op) { return true; }
bool supportOp(CPSBinOp::BinOp /* op */) { return true; }
/// get the current operator
CPSBinOp::BinOp getOp(void) const { return _Op; }

View file

@ -57,13 +57,13 @@ inline CPlaneBasis PSBinOpModulate(CPlaneBasis p1, CPlaneBasis p2)
}
template <>
inline CPlaneBasis PSBinOpAdd(CPlaneBasis p1, CPlaneBasis p2)
inline CPlaneBasis PSBinOpAdd(CPlaneBasis /* p1 */, CPlaneBasis /* p2 */)
{
nlassert(0); // not allowed for now
return CPlaneBasis(NLMISC::CVector::Null);
}
template <>
inline CPlaneBasis PSBinOpSubtract(CPlaneBasis p1, CPlaneBasis p2)
inline CPlaneBasis PSBinOpSubtract(CPlaneBasis /* p1 */, CPlaneBasis /* p2 */)
{
nlassert(0); // not allowed for now
return CPlaneBasis(NLMISC::CVector::Null);

View file

@ -60,7 +60,7 @@ namespace NL3D
{
GET_INLINE float get() const { return float(rand() * (1 / double(RAND_MAX))); } // this may be optimized with a table...
void advance() {}
void advance(uint quantity) {}
void advance(uint /* quantity */) {}
};
/// this iterator just return the same value
@ -69,7 +69,7 @@ namespace NL3D
float Value;
GET_INLINE float get() const { return Value; }
void advance() {}
void advance(uint quantity) {}
void advance(uint /* quantity */) {}
};
/// iterator that use dist to compute the value

View file

@ -38,7 +38,7 @@ public :
/** The direction is taken from a global vector defined in the particle system
* NULL or an empty string as a name disable the use of a global value
*/
virtual void enableGlobalVectorValue(const std::string &name) {}
virtual void enableGlobalVectorValue(const std::string &/* name */) {}
virtual std::string getGlobalVectorValueName() const { return ""; }
};

View file

@ -65,13 +65,13 @@ struct IPSMover
virtual bool supportNonUniformScaling(void) const { NL_PS_FUNC(supportNonUniformScaling); return false ; }
// set the scale of the object (uniform scale). The default does nothing
virtual void setScale(uint32 index, float scale) {} ;
virtual void setScale(uint32 /* index */, float /* scale */) {}
// set a non uniform scale (if supported)
virtual void setScale(uint32 index, const NLMISC::CVector &s) { NL_PS_FUNC(setScale); }
virtual void setScale(uint32 /* index */, const NLMISC::CVector &/* s */) { NL_PS_FUNC(setScale); }
// get the scale of the object
virtual NLMISC::CVector getScale(uint32 index) const { NL_PS_FUNC(getScale); return NLMISC::CVector(1.f, 1.f, 1.f) ; }
virtual NLMISC::CVector getScale(uint32 /* index */) const { NL_PS_FUNC(getScale); return NLMISC::CVector(1.f, 1.f, 1.f) ; }
/** some object may not store a whole matrix (e.g planes)
* this return true if only a normal is needed to set the orientation of the object
@ -79,10 +79,10 @@ struct IPSMover
virtual bool onlyStoreNormal(void) const { NL_PS_FUNC(onlyStoreNormal); return false ; }
/// if the object only needs a normal, this return the normal. If not, is return (0, 0, 0)
virtual NLMISC::CVector getNormal(uint32 index) { NL_PS_FUNC(getNormal); return NLMISC::CVector::Null ; }
virtual NLMISC::CVector getNormal(uint32 /* index */) { NL_PS_FUNC(getNormal); return NLMISC::CVector::Null ; }
/// if the object only stores a normal, this set the normal of the object. Otherwise it has no effect
virtual void setNormal(uint32 index, NLMISC::CVector n) { NL_PS_FUNC(setNormal); }
virtual void setNormal(uint32 /* index */, NLMISC::CVector /* n */) { NL_PS_FUNC(setNormal); }
// set a new orthogonal matrix for the object
virtual void setMatrix(uint32 index, const NLMISC::CMatrix &m) = 0 ;

View file

@ -87,9 +87,9 @@ public:
* 'accumulate' set to false.
* NB : works only with integrable forces
*/
virtual void integrate(float date, CPSLocated *src, uint32 startIndex, uint32 numObjects, NLMISC::CVector *destPos = NULL, NLMISC::CVector *destSpeed = NULL,
bool accumulate = false,
uint posStride = sizeof(NLMISC::CVector), uint speedStride = sizeof(NLMISC::CVector)
virtual void integrate(float /* date */, CPSLocated * /* src */, uint32 /* startIndex */, uint32 /* numObjects */, NLMISC::CVector * /* destPos */ = NULL, NLMISC::CVector * /* destSpeed */ = NULL,
bool /* accumulate */ = false,
uint /* posStride */ = sizeof(NLMISC::CVector), uint /* speedStride */ = sizeof(NLMISC::CVector)
) const
{
nlassert(0); // not an integrable force
@ -100,11 +100,11 @@ public:
* If the start date is lower than the creation date, the initial position is used
* NB : works only with integrable forces
*/
virtual void integrateSingle(float startDate, float deltaT, uint numStep,
const CPSLocated *src, uint32 indexInLocated,
NLMISC::CVector *destPos,
bool accumulate = false,
uint posStride = sizeof(NLMISC::CVector)) const
virtual void integrateSingle(float /* startDate */, float /* deltaT */, uint /* numStep */,
const CPSLocated * /* src */, uint32 /* indexInLocated */,
NLMISC::CVector * /* destPos */,
bool /* accumulate */ = false,
uint /* posStride */ = sizeof(NLMISC::CVector)) const
{
nlassert(0); // not an integrable force
}
@ -170,7 +170,7 @@ public:
virtual void setIntensityScheme(CPSAttribMaker<float> *scheme);
// deriver have here the opportunity to setup the functor object. The default does nothing
virtual void setupFunctor(uint32 indexInLocated) { }
virtual void setupFunctor(uint32 /* indexInLocated */) { }
/// get the attribute maker for a non constant intensity
CPSAttribMaker<float> *getIntensityScheme(void) { return _IntensityScheme; }
@ -493,7 +493,7 @@ public:
#ifdef NL_OS_WINDOWS
__forceinline
#endif
void operator() (const NLMISC::CVector &pos, NLMISC::CVector &speed, float invMass)
void operator() (const NLMISC::CVector &/* pos */, NLMISC::CVector &speed, float invMass)
{
speed -= (CParticleSystem::EllapsedTime * _K * invMass * speed);
}
@ -630,7 +630,7 @@ struct CPSTurbulForceFunc
#ifdef NL_OS_WINDOWS
__forceinline
#endif
void operator() (const NLMISC::CVector &pos, NLMISC::CVector &speed, float invMass)
void operator() (const NLMISC::CVector &/* pos */, NLMISC::CVector &/* speed */, float /* invMass */)
{
nlassert(0);

View file

@ -172,7 +172,7 @@ template<class T>
void CStaticQuadGrid<T>::build(CQuadGrid<T> &quadGrid)
{
clear();
contReset(_Grid);
NLMISC::contReset(_Grid);
// Copy from quadGrid, and init quads
_Size= quadGrid.getSize();

View file

@ -218,7 +218,7 @@ protected:
date*= previous->OODeltaTime;
NLMISC::clamp(date, 0,1);
date = ease(previous, date);
date = this->ease(previous, date);
float hb[4];
this->computeHermiteBasis(date, hb);
@ -242,7 +242,7 @@ protected:
ITrackKeyFramer<CKeyT>::compile();
// Ease Precompute.
compileTCBEase(this->_MapKey, this->getLoopMode());
this->compileTCBEase(this->_MapKey, this->getLoopMode());
// Tangents Precompute.
@ -314,7 +314,7 @@ private:
float ksm,ksp,kdm,kdp;
// compute tangents factors.
computeTCBFactors(key, timeBefore, time, timeAfter, rangeDelta, firstKey, endKey, isLoop, ksm,ksp,kdm,kdp);
this->computeTCBFactors(key, timeBefore, time, timeAfter, rangeDelta, firstKey, endKey, isLoop, ksm,ksp,kdm,kdp);
// Delta.
TKeyValueType delm, delp;
@ -413,7 +413,7 @@ public:
ITrackKeyFramer<CKeyTCBQuat>::compile();
// Ease Precompute.
compileTCBEase(_MapKey, getLoopMode());
this->compileTCBEase(_MapKey, getLoopMode());
TMapTimeCKey::iterator it;
TMapTimeCKey::iterator itNext;

View file

@ -1223,7 +1223,7 @@ inline void CVertexBuffer::lock (CVertexBufferRead &accessor, uint first, uint l
// --------------------------------------------------
inline void CVertexBuffer::unlock (uint first, uint end)
inline void CVertexBuffer::unlock (uint /* first */, uint /* end */)
{
nlassertex (_LockCounter!=0, ("Vertex buffer not locked"));
nlassert (_LockedBuffer || (!isResident() && _NonResidentVertices.empty()));

View file

@ -209,6 +209,8 @@ public:
{
#ifdef NL_DEBUG
std::swap(_DbgData, other._DbgData);
#else
nlunreferenced(other);
#endif
}
@ -225,6 +227,10 @@ public:
TBMSSerialInfo serialItem( bitpos, size, type, _DbgData->NextSymbol );
_DbgData->List.push_back( serialItem );
_DbgData->NextSymbol = NULL;
#else
nlunreferenced(bitpos);
nlunreferenced(size);
nlunreferenced(type);
#endif
}
@ -258,6 +264,10 @@ public:
nlwarning( "Missing reserve() corresponding to poke()" );
}
_DbgData->NextSymbol = NULL;
#else
nlunreferenced(bitpos);
nlunreferenced(size);
nlunreferenced(type);
#endif
}
@ -266,6 +276,8 @@ public:
{
#ifdef NL_DEBUG
_DbgData->NextSymbol = symbol;
#else
nlunreferenced(symbol);
#endif
}
@ -308,6 +320,8 @@ public:
}
//nlassert( bitpos < (*_List)[_CurrentBrowsedItem].BitPos ); // occurs if stream overflow
}
#else
nlunreferenced(bitpos);
#endif
*eventId = -1;
return std::string();
@ -380,7 +394,7 @@ public:
* If you are using the stream only in output mode, you can use this method as a faster version
* of clear() *if you don't serialize pointers*.
*/
void resetBufPos()
virtual void resetBufPos()
{
// This is ensured in CMemStream::CMemStream() and CMemStream::clear()
//if ( (!isReading()) && _Buffer.empty() )
@ -463,7 +477,7 @@ public:
}
/// See doc in CMemStream::bufferToFill()
uint8 *bufferToFill( uint32 msgsize )
virtual uint8 *bufferToFill( uint32 msgsize )
{
_FreeBits = 8;
_DbgInfo.clear();
@ -640,7 +654,7 @@ public:
virtual void serial(ucstring &b);
virtual void serial(CBitMemStream &b) { serialMemStream(b); }
virtual void serialMemStream(CBitMemStream &b);
virtual void serialMemStream(CMemStream &b);
//@}
@ -787,11 +801,7 @@ void displayBitStream( const CBitMemStream& msg, sint beginbitpos, sint endbitpo
inline std::string CBMSDbgInfo::getEventLegendAtBitPos( CBitMemStream& bms, sint32 eventId )
{
#ifdef NL_DEBUG
if ( eventId == -1 )
{
return std::string();
}
else
if ( eventId != -1 )
{
nlassert( eventId < (sint32)_DbgData->List.size() );
TBMSSerialInfo& serialItem = _DbgData->List[eventId]; // works only with a vector!
@ -800,8 +810,11 @@ inline std::string CBMSDbgInfo::getEventLegendAtBitPos( CBitMemStream& bms, sint
bms.getSerialItem( serialItem ).c_str(), (serialItem.Symbol!=NULL)?serialItem.Symbol:"" );
}
#else
return std::string();
nlunreferenced(bms);
nlunreferenced(eventId);
#endif
return std::string();
}

View file

@ -501,8 +501,8 @@ namespace STRING_MANAGER
// callback->onSwap(it - context.Reference.begin(), refCount, context);
callback->onSwap(index, refCount, context);
// swap(*it, context.Reference[refCount]);
swap(context.Reference[index], context.Reference[refCount]);
// std::swap(*it, context.Reference[refCount]);
std::swap(context.Reference[index], context.Reference[refCount]);
}
}
else if (getHashValue(context.Addition, addCount) != getHashValue(context.Reference, refCount))

View file

@ -0,0 +1,151 @@
/**
* \file fast_id_map.h
* \brief CFastIdMap
* \date 2012-04-10 19:28GMT
* \author Jan Boon (Kaetemi)
* CFastIdMap
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLMISC_FAST_ID_MAP_H
#define NLMISC_FAST_ID_MAP_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#include <nel/misc/debug.h>
// Project includes
namespace NLMISC {
/**
* \brief CFastIdMap
* \date 2012-04-10 19:28GMT
* \author Jan Boon (Kaetemi)
* This template allows for assigning unique uint32 identifiers to pointers.
* Useful when externally only exposing an identifier, when pointers may have been deleted.
* The identifier is made from two uint16's, one being the direct index in the identifier vector,
* and the other being a verification value that is increased when the identifier index is re-used.
* TId must be a typedef of uint32.
* TValue should be a pointer.
*/
template<typename TId, class TValue>
class CFastIdMap
{
protected:
struct CIdInfo
{
CIdInfo() { }
CIdInfo(uint16 verification, uint16 next, TValue value) :
Verification(verification), Next(next), Value(value) { }
uint16 Verification;
uint16 Next;
TValue Value;
};
/// ID memory
std::vector<CIdInfo> m_Ids;
/// Nb of assigned IDs
uint m_Size;
/// Assigned IDs
uint16 m_Next;
public:
CFastIdMap(TValue defaultValue) : m_Size(0), m_Next(0)
{
// Id 0 will contain the last available unused id, and be 0 if no more unused id's are available
// defaultValue will be returned when the ID is not found
m_Ids.push_back(CIdInfo(0, 0, defaultValue));
}
virtual ~CFastIdMap() { }
void clear()
{
m_Ids.resize(1);
m_Ids[0].Next = 0;
}
TId insert(TValue value)
{
// get next unused index
uint16 idx = m_Ids[0].Next;
if (idx == 0)
{
// size of used elements must be equal to the vector size minus one, when everything is allocated
nlassert((m_Ids.size() - 1) == m_Size);
idx = m_Ids.size();
uint16 verification = rand();
m_Ids.push_back(CIdInfo(verification, m_Next, value));
m_Next = idx;
return (TId)(((uint32)verification) << 16) & idx;
}
else
{
m_Ids[0].Next = m_Ids[idx].Next; // restore the last unused id
m_Ids[idx].Value = value;
return (TId)(((uint32)m_Ids[idx].Verification) << 16) & idx;
}
}
void erase(TId id)
{
uint32 idx = ((uint32)id) & 0xFFFF;
uint16 verification = (uint16)(((uint32)id) >> 16);
if (m_Ids[idx].Verification == verification)
{
m_Ids[idx].Value = m_Ids[0].Value; // clean value for safety
m_Ids[idx].Verification = (uint16)(((uint32)m_Ids[idx].Verification + 1) & 0xFFFF); // change verification value, allow overflow :)
m_Ids[idx].Next = m_Ids[0].Next; // store the last unused id
m_Ids[0].Next = (uint16)idx; // set this as last unused id
}
else
{
nlwarning("Invalid ID");
}
}
TValue get(TId id)
{
uint32 idx = ((uint32)id) & 0xFFFF;
uint16 verification = (uint16)(((uint32)id) >> 16);
if (m_Ids[idx].Verification == verification)
{
return m_Ids[idx].Value;
}
else
{
nldebug("Invalid ID");
return m_Ids[0].Value;
}
}
inline uint size() { return m_Size; }
}; /* class CFastIdMap */
} /* namespace NLMISC */
#endif /* #ifndef NLMISC_FAST_ID_MAP_H */
/* end of file */

View file

@ -301,7 +301,7 @@ public:
* If you are using the stream only in output mode, you can use this method as a faster version
* of clear() *if you don't serialize pointers*.
*/
void resetBufPos() { _Buffer.Pos = 0; }
virtual void resetBufPos() { _Buffer.Pos = 0; }
/**
* Resize the message buffer and fill data at position 0.
@ -340,7 +340,7 @@ public:
* fill it with raw data using any filling function (warning: don't fill more than 'msgsize'
* bytes!), then you are ready to read, using serial(), the data you've just filled.
*/
uint8 *bufferToFill( uint32 msgsize )
virtual uint8 *bufferToFill( uint32 msgsize )
{
#ifdef NL_DEBUG
nlassert( isReading() );

View file

@ -717,11 +717,11 @@ class CAutoMutex
TMutex &_Mutex;
// forbeden copy or assignent
CAutoMutex(const CAutoMutex &other)
CAutoMutex(const CAutoMutex &/* other */)
{
}
CAutoMutex &operator = (const CAutoMutex &other)
CAutoMutex &operator = (const CAutoMutex &/* other */)
{
return *this;
}

View file

@ -36,6 +36,12 @@ namespace NLMISC {
class CPThread : public IThread
{
public:
enum TThreadState
{
ThreadStateNone,
ThreadStateRunning,
ThreadStateFinished,
};
/// Constructor
CPThread( IRunnable *runnable, uint32 stackSize);
@ -48,6 +54,7 @@ public:
virtual void wait();
virtual bool setCPUMask(uint64 cpuMask);
virtual uint64 getCPUMask();
virtual void setPriority(TThreadPriority priority);
virtual std::string getUserName();
virtual IRunnable *getRunnable()
@ -58,10 +65,11 @@ public:
/// Internal use
IRunnable *Runnable;
private:
uint8 _State; // 0=not created, 1=started, 2=finished
uint32 _StackSize;
TThreadState _State;
pthread_t _ThreadHandle;
private:
uint32 _StackSize;
};
/**

View file

@ -118,7 +118,7 @@ namespace NLMISC
_Speaker->registerListener(this);
}
void unregisterListener(ISpeaker *speaker)
void unregisterListener(ISpeaker * /* speaker */)
{
nlassert(_Speaker != NULL);
_Speaker->unregisterListener(this);

View file

@ -55,7 +55,7 @@ public:
/// ctor
CSString(int i,const char *fmt="%d");
/// ctor
CSString(unsigned u,const char *fmt="%u");
CSString(uint32 u,const char *fmt="%u");
/// ctor
CSString(double d,const char *fmt="%f");
/// ctor
@ -76,14 +76,14 @@ public:
char back() const;
/// Return the n left hand most characters of a string
CSString left(unsigned count) const;
CSString left(uint32 count) const;
/// Return the n right hand most characters of a string
CSString right(unsigned count) const;
CSString right(uint32 count) const;
/// Return the string minus the n left hand most characters of a string
CSString leftCrop(unsigned count) const;
CSString leftCrop(uint32 count) const;
/// Return the string minus the n right hand most characters of a string
CSString rightCrop(unsigned count) const;
CSString rightCrop(uint32 count) const;
/// Return sub string up to but not including first instance of given character, starting at 'iterator'
/// on exit 'iterator' indexes first character after extracted string segment
@ -116,9 +116,9 @@ public:
/// Return sub string remaining after the first word
CSString tailFromFirstWord() const;
/// Count the number of words in a string
unsigned countWords() const;
uint32 countWords() const;
/// Extract the given word
CSString word(unsigned idx) const;
CSString word(uint32 idx) const;
/// Return first word or quote-encompassed sub-string - can remove extracted sub-string from source string
CSString firstWordOrWords(bool truncateThis=false,bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true);
@ -127,9 +127,9 @@ public:
/// Return sub string following first word (or quote-encompassed sub-string)
CSString tailFromFirstWordOrWords(bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const;
/// Count the number of words (or quote delimited sub-strings) in a string
unsigned countWordOrWords(bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const;
uint32 countWordOrWords(bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const;
/// Extract the given words (or quote delimited sub-strings)
CSString wordOrWords(unsigned idx,bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const;
CSString wordOrWords(uint32 idx,bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const;
/// Return first line - can remove extracted line from source string
CSString firstLine(bool truncateThis=false);
@ -138,9 +138,9 @@ public:
/// Return sub string remaining after the first line
CSString tailFromFirstLine() const;
/// Count the number of lines in a string
unsigned countLines() const;
uint32 countLines() const;
/// Extract the given line
CSString line(unsigned idx) const;
CSString line(uint32 idx) const;
/// A handy utility routine for knowing if a character is a white space character or not (' ','\t','\n','\r',26)
static bool isWhiteSpace(char c);
@ -377,7 +377,7 @@ public:
/// assignment operator
CSString& operator=(int i);
/// assignment operator
CSString& operator=(unsigned u);
CSString& operator=(uint32 u);
/// assignment operator
CSString& operator=(double d);
@ -561,7 +561,7 @@ inline CSString::CSString(int i,const char *fmt)
*this=buf;
}
inline CSString::CSString(unsigned u,const char *fmt)
inline CSString::CSString(uint32 u,const char *fmt)
{
char buf[1024];
sprintf(buf,fmt,u);
@ -611,26 +611,26 @@ inline char CSString::back() const
return (*this)[size()-1];
}
inline CSString CSString::right(unsigned count) const
inline CSString CSString::right(uint32 count) const
{
if (count>=size())
return *this;
return substr(size()-count);
}
inline CSString CSString::rightCrop(unsigned count) const
inline CSString CSString::rightCrop(uint32 count) const
{
if (count>=size())
return CSString();
return substr(0,size()-count);
}
inline CSString CSString::left(unsigned count) const
inline CSString CSString::left(uint32 count) const
{
return substr(0,count);
}
inline CSString CSString::leftCrop(unsigned count) const
inline CSString CSString::leftCrop(uint32 count) const
{
if (count>=size())
return CSString();
@ -639,7 +639,7 @@ inline CSString CSString::leftCrop(unsigned count) const
inline CSString CSString::splitToWithIterator(char c,uint32& iterator) const
{
unsigned i;
uint32 i;
CSString result;
for (i=iterator;i<size() && (*this)[i]!=c;++i)
result+=(*this)[i];
@ -713,7 +713,7 @@ inline bool CSString::isPrintable(char c)
if (c==',') return true;
if (c==';') return true;
if (c=='$') return true;
if ((unsigned char)c==156) return true; // Sterling Pound char causing error in gcc 4.1.2
if ((uint8)c==156) return true; // Sterling Pound char causing error in gcc 4.1.2
if (c=='^') return true;
if (c=='~') return true;
if (c=='\'') return true;
@ -784,7 +784,7 @@ inline CSString& CSString::operator=(int i)
return *this;
}
inline CSString& CSString::operator=(unsigned u)
inline CSString& CSString::operator=(uint32 u)
{
CSString other(u);
*this = other;

View file

@ -93,7 +93,7 @@ public:
{
}
explicit CStaticMap (const Comp& __comp) : _DataSorted(true)
explicit CStaticMap (const Comp& /* __comp */) : _DataSorted(true)
{
}

View file

@ -61,7 +61,7 @@ namespace NLMISC {
{
public:
/// Constructor. Must gives a blockMemory to ctor. NB: must gives a CBlockMemory<T, false> !!!
CSTLBlockAllocator(CBlockMemory<T, false> *bm)
CSTLBlockAllocator(CBlockMemory<T, false> * /* bm */)
{
}
/// copy ctor

View file

@ -68,6 +68,16 @@ public:
}
};
/// Thread priorities, numbering follows Win32 for now
enum TThreadPriority
{
ThreadPriorityLowest = -2,
ThreadPriorityLow = -1,
ThreadPriorityNormal = 0,
ThreadPriorityHigh = 1,
ThreadPriorityHighest = 2,
};
/**
* Thread base interface, must be implemented for all OS
* \author Vianney Lecroart
@ -119,6 +129,9 @@ public:
*/
virtual uint64 getCPUMask()=0;
/// Set the thread priority. Thread must have been started before.
virtual void setPriority(TThreadPriority priority) = 0;
/**
* Get the thread user name.
* Under Linux return thread owner, under windows return the name of the logon user.

View file

@ -49,6 +49,7 @@ public:
virtual void wait();
virtual bool setCPUMask(uint64 cpuMask);
virtual uint64 getCPUMask();
virtual void setPriority(TThreadPriority priority);
virtual std::string getUserName();
virtual IRunnable *getRunnable()
@ -69,8 +70,7 @@ public:
void suspend();
// Resume the thread. No-op if already resumed
void resume();
// set priority as defined by "SetThreadpriority"
void setPriority(int priority);
// Priority boost
void enablePriorityBoost(bool enabled);
/// private use

View file

@ -188,8 +188,8 @@ namespace NLNET
// unused interceptors
std::string fwdBuildModuleManifest() const { return std::string(); }
void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}
bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message) {return false;}
void fwdOnModuleSecurityChange(NLNET::IModuleProxy * /* moduleProxy */) {}
bool fwdOnProcessModuleMessage(NLNET::IModuleProxy * /* sender */, const NLNET::CMessage &/* message */) {return false;}
// check module up
void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy)

View file

@ -335,7 +335,7 @@ protected:
T *Value;
virtual void serialDefaultValue (NLMISC::IStream &f)
virtual void serialDefaultValue (NLMISC::IStream &/* f */)
{
// nothing
}

View file

@ -0,0 +1,107 @@
/**
* \file audio_decoder.h
* \brief IAudioDecoder
* \date 2012-04-11 09:34GMT
* \author Jan Boon (Kaetemi)
* IAudioDecoder
*/
/*
* Copyright (C) 2008-2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_AUDIO_DECODER_H
#define NLSOUND_AUDIO_DECODER_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
namespace NLSOUND {
/**
* \brief IAudioDecoder
* \date 2008-08-30 11:38GMT
* \author Jan Boon (Kaetemi)
* IAudioDecoder is only used by the driver implementation to stream
* music files into a readable format (it's a simple decoder interface).
* You should not call these functions (getSongTitle) on nlsound or user level,
* as a driver might have additional music types implemented.
* TODO: Split IAudioDecoder into IAudioDecoder (actual decoding) and IMediaDemuxer (stream splitter), and change the interface to make more sense.
* TODO: Allow user application to register more decoders.
* TODO: Look into libavcodec for decoding audio?
*/
class IAudioDecoder
{
private:
// pointers
/// Stream from file created by IAudioDecoder
NLMISC::IStream *_InternalStream;
public:
IAudioDecoder();
virtual ~IAudioDecoder();
/// Create a new music buffer, may return NULL if unknown type, destroy with delete. Filepath lookup done here. If async is true, it will stream from hd, else it will load in memory first.
static IAudioDecoder *createAudioDecoder(const std::string &filepath, bool async, bool loop);
/// Create a new music buffer from a stream, type is file extension like "ogg" etc.
static IAudioDecoder *createAudioDecoder(const std::string &type, NLMISC::IStream *stream, bool loop);
/// Get information on a music file (only artist and title at the moment).
static bool getInfo(const std::string &filepath, std::string &artist, std::string &title);
/// Get audio/container extensions that are currently supported by the nel sound library.
static void getMusicExtensions(std::vector<std::string> &extensions);
/// Return if a music extension is supported by the nel sound library.
static bool isMusicExtensionSupported(const std::string &extension);
/// Get how many bytes the music buffer requires for output minimum.
virtual uint32 getRequiredBytes() = 0;
/// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end).
virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) = 0;
/// Get the amount of channels (2 is stereo) in output.
virtual uint8 getChannels() = 0;
/// Get the samples per second (often 44100) in output.
virtual uint getSamplesPerSec() = 0;
/// Get the bits per sample (often 16) in output.
virtual uint8 getBitsPerSample() = 0;
/// Get if the music has ended playing (never true if loop).
virtual bool isMusicEnded() = 0;
/// Get the total time in seconds.
virtual float getLength() = 0;
/// Set looping
virtual void setLooping(bool loop) = 0;
}; /* class IAudioDecoder */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_AUDIO_DECODER_H */
/* end of file */

View file

@ -1,21 +1,33 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/**
* \file audio_decoder_vorbis.h
* \brief CAudioDecoderVorbis
* \date 2012-04-11 09:35GMT
* \author Jan Boon (Kaetemi)
* CAudioDecoderVorbis
*/
#ifndef NLSOUND_MUSIC_BUFFER_VORBIS_H
#define NLSOUND_MUSIC_BUFFER_VORBIS_H
/*
* Copyright (C) 2008-2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_AUDIO_DECODER_VORBIS_H
#define NLSOUND_AUDIO_DECODER_VORBIS_H
#include <nel/misc/types_nl.h>
// STL includes
@ -30,21 +42,20 @@
#endif
// NeL includes
#include <nel/sound/audio_decoder.h>
// Project includes
#include "music_buffer.h"
namespace NLSOUND
{
namespace NLSOUND {
/**
* \brief CMusicBufferVorbis
* \brief CAudioDecoderVorbis
* \date 2008-08-30 11:38GMT
* \author Jan Boon (Kaetemi)
* CMusicBufferVorbis
* Create trough IMusicBuffer, type "ogg"
* CAudioDecoderVorbis
* Create trough IAudioDecoder, type "ogg"
*/
class CMusicBufferVorbis : public IMusicBuffer
class CAudioDecoderVorbis : public IAudioDecoder
{
protected:
// outside pointers
@ -59,8 +70,8 @@ protected:
sint32 _StreamOffset;
sint32 _StreamSize;
public:
CMusicBufferVorbis(NLMISC::IStream *stream, bool loop);
virtual ~CMusicBufferVorbis();
CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop);
virtual ~CAudioDecoderVorbis();
inline NLMISC::IStream *getStream() { return _Stream; }
inline sint32 getStreamSize() { return _StreamSize; }
inline sint32 getStreamOffset() { return _StreamOffset; }
@ -78,7 +89,7 @@ public:
virtual uint8 getChannels();
/// Get the samples per second (often 44100) in output.
virtual uint32 getSamplesPerSec();
virtual uint getSamplesPerSec();
/// Get the bits per sample (often 16) in output.
virtual uint8 getBitsPerSample();
@ -89,12 +100,12 @@ public:
/// Get the total time in seconds.
virtual float getLength();
/// Get the size of uncompressed data in bytes.
virtual uint getUncompressedSize();
}; /* class CMusicBufferVorbis */
/// Set looping
virtual void setLooping(bool loop);
}; /* class CAudioDecoderVorbis */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_MUSIC_BUFFER_VORBIS_H */
#endif /* #ifndef NLSOUND_AUDIO_DECODER_VORBIS_H */
/* end of file */

View file

@ -34,6 +34,11 @@
#include "nel/sound/mixing_track.h"
#include "nel/sound/sound.h"
#include "nel/sound/music_channel_fader.h"
#include "nel/sound/group_controller_root.h"
// Current version is 2, Ryzom Live uses 1
// Provided to allow compatibility with old binary files
#define NLSOUND_SHEET_VERSION_BUILT 1
namespace NLLIGO {
class CLigoConfig;
@ -51,26 +56,6 @@ namespace NLSOUND {
class CMusicSoundManager;
class IReverbEffect;
/// Hasher functor for hashed container with pointer key.
template <class Pointer>
struct THashPtr : public std::unary_function<const Pointer &, size_t>
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
size_t operator () (const Pointer &ptr) const
{
//CHashSet<uint>::hasher h;
// transtype the pointer into int then hash it
//return h.operator()(uint(uintptr_t(ptr)));
return (size_t)(uintptr_t)ptr;
}
inline bool operator() (const Pointer &ptr1, const Pointer &ptr2) const
{
// delegate the work to someone else as well?
return (uintptr_t)ptr1 < (uintptr_t)ptr2;
}
};
/**
* Implementation of UAudioMixer
*
@ -197,6 +182,9 @@ public:
/// Get a TSoundId from a name (returns NULL if not found)
virtual TSoundId getSoundId( const NLMISC::TStringId &name );
/// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created.
/// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera
virtual UGroupController *getGroupController(const std::string &path);
/** Add a logical sound source (returns NULL if name not found).
* If spawn is true, the source will auto-delete after playing. If so, the return USource* pointer
@ -204,9 +192,9 @@ public:
* pass a callback function that will be called (if not NULL) just before deleting the spawned
* source.
*/
virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0 );
virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL);
/// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*)
virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0 );
virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL);
/// Add a source which was created by an EnvSound
void addSource( CSourceCommon *source );
/** Delete a logical sound source. If you don't call it, the source will be auto-deleted
@ -242,6 +230,8 @@ public:
virtual uint getSourcesInstanceCount() const { return (uint)_Sources.size(); }
/// Return the number of playing sources (slow)
virtual uint getPlayingSourcesCount() const;
uint countPlayingSimpleSources() const; // debug
uint countSimpleSources() const; // debug
/// Return the number of available tracks
virtual uint getAvailableTracksCount() const;
/// Return the number of used tracks
@ -415,6 +405,7 @@ public:
/// Add a source for play as possible (for non discadable sound)
void addSourceWaitingForPlay(CSourceCommon *source);
void removeSourceWaitingForPlay(CSourceCommon *source);
/// Read all user controled var sheets
void initUserVar();
@ -431,8 +422,6 @@ private:
// utility function for automatic sample bank loading.
bool tryToLoadSampleBank(const std::string &sampleName);
typedef CHashSet<CSourceCommon*, THashPtr<CSourceCommon*> > TSourceContainer;
typedef CHashSet<IMixerUpdate*, THashPtr<IMixerUpdate*> > TMixerUpdateContainer;
typedef CHashMap<IBuffer*, std::vector<class CSound*>, THashPtr<IBuffer*> > TBufferToSourceContainer;
// typedef std::multimap<NLMISC::TTime, IMixerEvent*> TTimedEventContainer;
@ -565,6 +554,9 @@ private:
// Instance of the background music manager
CMusicSoundManager *_BackgroundMusicManager;
/// Group controller
CGroupControllerRoot _GroupController;
public:
struct TSampleBankHeader
{

View file

@ -36,7 +36,7 @@ class CBackgroundSource : public CSourceCommon , public CAudioMixerUser::IMixerU
{
public:
/// Constructor
CBackgroundSource (CBackgroundSound *backgroundSound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0);
CBackgroundSource (CBackgroundSound *backgroundSound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL);
/// Destructor
~CBackgroundSource ();

View file

@ -34,7 +34,7 @@ class CComplexSource : public CSourceCommon, public CAudioMixerUser::IMixerEvent
{
public:
/// Constructor
CComplexSource (CComplexSound *soundPattern=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0);
CComplexSource (CComplexSound *soundPattern=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL);
/// Destructor
~CComplexSource ();

View file

@ -0,0 +1,67 @@
/**
* \file containers.h
* \brief CContainers
* \date 2012-04-10 13:57GMT
* \author Unknown (Unknown)
* CContainers
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_CONTAINERS_H
#define NLSOUND_CONTAINERS_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
namespace NLSOUND {
class CSourceCommon;
/// Hasher functor for hashed container with pointer key.
template <class Pointer>
struct THashPtr : public std::unary_function<const Pointer &, size_t>
{
static const size_t bucket_size = 4;
static const size_t min_buckets = 8;
size_t operator () (const Pointer &ptr) const
{
//CHashSet<uint>::hasher h;
// transtype the pointer into int then hash it
//return h.operator()(uint(uintptr_t(ptr)));
return (size_t)(uintptr_t)ptr;
}
inline bool operator() (const Pointer &ptr1, const Pointer &ptr2) const
{
// delegate the work to someone else as well?
return (uintptr_t)ptr1 < (uintptr_t)ptr2;
}
};
typedef CHashSet<CSourceCommon*, THashPtr<CSourceCommon*> > TSourceContainer;
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_CONTAINERS_H */
/* end of file */

View file

@ -48,6 +48,8 @@ public:
/// Intel/DVI ADPCM format, only available for 1 channel at 16 bits per sample, encoded at 4 bits per sample.
/// This is only implemented in the DSound and XAudio2 driver.
FormatDviAdpcm = 11,
/// No format set. Used when a TBufferFormat value has not been set to any value yet.
FormatNotSet = (~0),
};
/// The storage mode of this buffer. Also controls the X-RAM extension of OpenAL.
enum TStorageMode

View file

@ -1,119 +0,0 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NLSOUND_MUSIC_BUFFER_H
#define NLSOUND_MUSIC_BUFFER_H
namespace NLMISC
{
class IStream;
class CIFile;
}
namespace NLSOUND
{
/*
* TODO: Streaming
* Some kind of decent streaming functionality, to get rid of the current music implementation. Audio decoding should be done on nlsound level. IBuffer needs a writable implementation, it allocates and owns the data memory, which can be written to by nlsound. When buffer is written, a function needs to be called to 'finalize' the buffer (so it can be submitted to OpenAL for example).
* Required interface functions, IBuffer:
* /// Allocate a new writable buffer. If this buffer was already allocated, the previous data is released.
* /// May return NULL if the format or frequency is not supported by the driver.
* uint8 *IBuffer::openWritable(uint size, TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, uint32 frequency);
* /// Tell that you are done writing to this buffer, so it can be copied over to hardware if needed.
* /// If keepLocal is true, a local copy of the buffer will be kept (so allocation can be re-used later).
* /// keepLocal overrides the OptionLocalBufferCopy flag. The buffer can use this function internally.
* void IBuffer::lockWritable(bool keepLocal);
* Required interface functions, ISource:
* /// Enable or disable the streaming facilities.
* void ISource::setStreaming(bool streaming);
* /// Submits a new buffer to the stream. A buffer of 100ms length is optimal for streaming.
* /// Should be called by a thread which checks countStreamingBuffers every 100ms
* void ISource::submitStreamingBuffer(IBuffer *buffer);
* /// Returns the number of buffers that are queued (includes playing buffer). 3 buffers is optimal.
* uint ISource::countStreamingBuffers();
* Other required interface functions, ISource:
* /// Enable or disable 3d calculations (to send directly to speakers).
* void ISource::set3DMode(bool enable);
* For compatibility with music trough fmod, ISoundDriver:
* /// Returns true if the sound driver has a native implementation of IMusicChannel (bad!).
* /// If this returns false, use the nlsound music channel, which goes trough Ctrack/ISource,
* /// The nlsound music channel requires support for IBuffer/ISource streaming.
* bool ISoundDriver::hasMusicChannel();
*/
/**
* \brief IMusicBuffer
* \date 2008-08-30 11:38GMT
* \author Jan Boon (Kaetemi)
* IMusicBuffer is only used by the driver implementation to stream
* music files into a readable format (it's a simple decoder interface).
* You should not call these functions (getSongTitle) on nlsound or user level,
* as a driver might have additional music types implemented.
* TODO: Change IMusicBuffer to IAudioDecoder, and change the interface to make more sense.
* TODO: Allow user application to register more decoders.
* TODO: Look into libavcodec for decoding audio.
*/
class IMusicBuffer
{
private:
// pointers
/// Stream from file created by IMusicBuffer
NLMISC::IStream *_InternalStream;
public:
IMusicBuffer();
virtual ~IMusicBuffer();
/// Create a new music buffer, may return NULL if unknown type, destroy with delete. Filepath lookup done here. If async is true, it will stream from hd, else it will load in memory first.
static IMusicBuffer *createMusicBuffer(const std::string &filepath, bool async, bool loop);
/// Create a new music buffer from a stream, type is file extension like "ogg" etc.
static IMusicBuffer *createMusicBuffer(const std::string &type, NLMISC::IStream *stream, bool loop);
/// Get information on a music file (only artist and title at the moment).
static bool getInfo(const std::string &filepath, std::string &artist, std::string &title);
/// Get how many bytes the music buffer requires for output minimum.
virtual uint32 getRequiredBytes() =0;
/// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end).
virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) =0;
/// Get the amount of channels (2 is stereo) in output.
virtual uint8 getChannels() =0;
/// Get the samples per second (often 44100) in output.
virtual uint32 getSamplesPerSec() =0;
/// Get the bits per sample (often 16) in output.
virtual uint8 getBitsPerSample() =0;
/// Get if the music has ended playing (never true if loop).
virtual bool isMusicEnded() =0;
/// Get the total time in seconds.
virtual float getLength() =0;
/// Get the size of uncompressed data in bytes.
virtual uint getUncompressedSize() =0;
}; /* class IMusicBuffer */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_MUSIC_BUFFER_H */
/* end of file */

View file

@ -45,6 +45,9 @@ public:
/// Stop the music previously loaded and played (the Memory is also freed)
virtual void stop() =0;
/// Makes sure any resources are freed, but keeps available for next play call
virtual void reset() =0;
/// Pause the music previously loaded and played (the Memory is not freed)
virtual void pause() =0;

View file

@ -39,9 +39,11 @@ namespace NLSOUND
#endif
/*
* Sound sample format
* Deprecated sound sample format.
* For compatibility with old code.
* Do not modify.
*/
enum TSampleFormat { SampleFormatUnknown, Mono8, Mono16ADPCM, Mono16, Stereo8, Stereo16 };
enum TSampleFormat { Mono8, Mono16ADPCM, Mono16, Stereo8, Stereo16, SampleFormatUnknown = (~0) };
/**
* Abstract sound driver (implemented in sound driver dynamic library)

View file

@ -353,7 +353,7 @@ public:
* In streaming mode, the time spent during buffer outruns is not
* counted towards the playback time, and the playback time is
* be the current time position in the entire submitted queue.
* When using static buffers, the result is the tot time that the
* When using static buffers, the result is the total time that the
* attached buffer has been playing. If the source is looping, the
* time will be the total of all playbacks of the buffer.
* When the source is stopped, this will return the time where the
@ -397,7 +397,7 @@ public:
virtual void setSourceRelativeMode(bool mode = true) = 0;
/// Get the source relative mode
virtual bool getSourceRelativeMode() const = 0;
/// Set the min and max distances (default: 1, MAX_FLOAT) (3D mode only)
/// Set the min and max distances (default: 1, sqrt(MAX_FLOAT)) (3D mode only)
virtual void setMinMaxDistances(float mindist, float maxdist, bool deferred = true) = 0;
/// Get the min and max distances
virtual void getMinMaxDistances(float& mindist, float& maxdist) const = 0;

View file

@ -0,0 +1,102 @@
/**
* \file group_controller.h
* \brief CGroupController
* \date 2012-04-10 09:29GMT
* \author Jan Boon (Kaetemi)
* CGroupController
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_GROUP_CONTROLLER_H
#define NLSOUND_GROUP_CONTROLLER_H
#include <nel/misc/types_nl.h>
// STL includes
#include <string>
#include <map>
// NeL includes
#include <nel/misc/common.h>
#include <nel/sound/u_group_controller.h>
#include <nel/sound/containers.h>
// Project includes
namespace NLSOUND {
class CGroupControllerRoot;
/**
* \brief CGroupController
* \date 2012-04-10 09:29GMT
* \author Jan Boon (Kaetemi)
* CGroupController
*/
class CGroupController : public UGroupController
{
public:
friend class CGroupControllerRoot;
private:
CGroupController *m_Parent;
std::map<std::string, CGroupController *> m_Children;
/// Gain as set by the interface
float m_Gain;
/// Gain including parent gain
float m_FinalGain;
int m_NbSourcesInclChild;
TSourceContainer m_Sources;
public:
CGroupController(CGroupController *parent);
/// \name UGroupController
//@{
virtual void setGain(float gain) { NLMISC::clamp(gain, 0.0f, 1.0f); if (m_Gain != gain) { m_Gain = gain; updateSourceGain(); } }
virtual float getGain() { return m_Gain; }
//@}
inline float getFinalGain() const { return m_FinalGain; }
void addSource(CSourceCommon *source);
void removeSource(CSourceCommon *source);
virtual std::string getPath();
protected:
virtual ~CGroupController(); // subnodes can only be deleted by the root
private:
inline float calculateTotalGain() { return m_Gain; }
virtual void calculateFinalGain();
virtual void increaseSources();
virtual void decreaseSources();
void updateSourceGain();
}; /* class CGroupController */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_GROUP_CONTROLLER_H */
/* end of file */

View file

@ -0,0 +1,70 @@
/**
* \file group_controller_root.h
* \brief CGroupControllerRoot
* \date 2012-04-10 09:44GMT
* \author Jan Boon (Kaetemi)
* CGroupControllerRoot
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_GROUP_CONTROLLER_ROOT_H
#define NLSOUND_GROUP_CONTROLLER_ROOT_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#include <nel/misc/singleton.h>
// Project includes
#include <nel/sound/group_controller.h>
namespace NLSOUND {
/**
* \brief CGroupControllerRoot
* \date 2012-04-10 09:44GMT
* \author Jan Boon (Kaetemi)
* CGroupControllerRoot
*/
class CGroupControllerRoot : public CGroupController, public NLMISC::CManualSingleton<CGroupControllerRoot>
{
public:
CGroupControllerRoot();
virtual ~CGroupControllerRoot();
/// Gets the group controller in a certain path with separator '/', if it doesn't exist yet it will be created.
CGroupController *getGroupController(const std::string &path);
protected:
virtual std::string getPath();
virtual void calculateFinalGain();
virtual void increaseSources();
virtual void decreaseSources();
static bool isReservedName(const std::string &nodeName);
}; /* class CGroupControllerRoot */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_GROUP_CONTROLLER_ROOT_H */
/* end of file */

View file

@ -87,6 +87,8 @@ public:
void init(ISoundDriver *soundDriver);
void release();
void reset();
void update(); // time in seconds
inline bool isInitOk() { return _SoundDriver != NULL; }

View file

@ -35,7 +35,7 @@ class CMusicSource : public CSourceCommon
{
public:
/// Constructor
CMusicSource (class CMusicSound *sound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0);
CMusicSource (class CMusicSound *sound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL);
/// Destructor
~CMusicSource ();

View file

@ -40,7 +40,7 @@ class CSimpleSource : public CSourceCommon, public CAudioMixerUser::IMixerEvent
{
public:
/// Constructor
CSimpleSource(CSimpleSound *simpleSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0);
CSimpleSource(CSimpleSound *simpleSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL);
/// Destructor
virtual ~CSimpleSource();
@ -97,14 +97,7 @@ public:
* 1.0 -> no attenuation
* values > 1 (amplification) not supported by most drivers
*/
virtual void setGain( float gain );
/** Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain
* (which is getSource()->getGain()). Does nothing if getSource() is null.
*/
virtual void setRelativeGain( float gain );
/** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift
* of one octave. 0 is not a legal value.
*/
virtual void updateFinalGain();
virtual void setPitch( float pitch );
/// Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false)
virtual void setSourceRelativeMode( bool mode );
@ -149,6 +142,8 @@ private:
/// True when the sound is played muted and until the mixer event notifying the end.
bool _PlayMuted;
bool _WaitingForPlay;
};

View file

@ -30,6 +30,7 @@ namespace NLSOUND {
class ISoundDriver;
class IBuffer;
class CSound;
class CGroupController;
/// Sound names hash map
@ -60,8 +61,9 @@ public:
SOUND_COMPLEX,
SOUND_BACKGROUND,
SOUND_CONTEXT,
SOUND_MUSIC,
SOUND_STREAM
SOUND_MUSIC, // soon to be deprecated hopefully
SOUND_STREAM,
SOUND_STREAM_FILE
};
@ -104,6 +106,8 @@ public:
/// Return the max distance (if detailed())
virtual float getMaxDistance() const { return _MaxDist; }
inline CGroupController *getGroupController() const { return _GroupController; }
/// Set looping
void setLooping( bool looping ) { _Looping = looping; }
@ -142,6 +146,9 @@ protected:
/// An optional user var controler.
NLMISC::TStringId _UserVarControler;
/// The group controller, always exists, owned by the audio mixer
CGroupController *_GroupController;
};

View file

@ -22,7 +22,7 @@
#include "nel/sound/u_stream_source.h"
#include "nel/3d/cluster.h"
#include "nel/sound/sound.h"
#include "nel/sound/group_controller.h"
namespace NLSOUND {
@ -36,11 +36,13 @@ public:
SOURCE_SIMPLE,
SOURCE_COMPLEX,
SOURCE_BACKGROUND,
SOURCE_MUSIC,
SOURCE_STREAM
SOURCE_MUSIC, // DEPRECATED
SOURCE_STREAM,
SOURCE_STREAM_FILE
};
CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster);
/// When groupController is NULL it will use the groupcontroller specified in the TSoundId. You should manually specify the groupController if this source is a child of another source, so that the parent source controller of the user-specified .sound file is the one that will be used.
CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController);
~CSourceCommon();
@ -63,6 +65,8 @@ public:
void setGain( float gain );
void setRelativeGain( float gain );
float getRelativeGain() const;
/// Called whenever the gain is changed trough setGain, setRelativeGain or the group controller's gain settings change.
virtual void updateFinalGain() { }
void setSourceRelativeMode( bool mode );
/// return the user param for the user callback
void *getCallbackUserParam(void) const { return _CbUserParam; }
@ -74,6 +78,8 @@ public:
virtual void getDirection( NLMISC::CVector& dir ) const { dir = _Direction; }
/// Get the gain
virtual float getGain() const { return _Gain; }
/// Get the final gain, including group controller changes. Use this when setting the physical source output gain.
inline float getFinalGain() const { return _Gain * _GroupController->getFinalGain(); }
/// Get the pitch
virtual float getPitch() const { return _Pitch; }
/// Get the source relative mode
@ -99,15 +105,15 @@ public:
/// \name Streaming source controls
//@{
/// Set the sample format. (channels = 1, 2, ...; bitsPerSample = 8, 16; frequency = samples per second, 44100, ...)
virtual void setFormat(uint8 channels, uint8 bitsPerSample, uint32 frequency) { nlassert(false); }
virtual void setFormat(uint8 /* channels */, uint8 /* bitsPerSample */, uint32 /* frequency */) { nlassert(false); }
/// Return the sample format information.
virtual void getFormat(uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const { nlassert(false); }
virtual void getFormat(uint8 &/* channels */, uint8 &/* bitsPerSample */, uint32 &/* frequency */) const { nlassert(false); }
/// Get a writable pointer to the buffer of specified size. Use capacity to specify the required bytes. Returns NULL when all the buffer space is already filled. Call setFormat() first.
virtual uint8 *lock(uint capacity) { nlassert(false); return NULL; }
virtual uint8 *lock(uint /* capacity */) { nlassert(false); return NULL; }
/// Notify that you are done writing to the locked buffer, so it can be copied over to hardware if needed. Set size to the number of bytes actually written to the buffer. Returns true if ok.
virtual bool unlock(uint size) { nlassert(false); return false; }
virtual bool unlock(uint /* size */) { nlassert(false); return false; }
/// Get the recommended buffer size to use with lock()/unlock()
virtual void getRecommendedBufferSize(uint &samples, uint &bytes) const { nlassert(false); }
virtual void getRecommendedBufferSize(uint &/* samples */, uint &/* bytes */) const { nlassert(false); }
/// Get the recommended sleep time based on the size of the last submitted buffer and the available buffer space
virtual uint32 getRecommendedSleepTime() const { nlassert(false); return 0; }
/// Return if there are still buffers available for playback.
@ -145,6 +151,9 @@ protected:
/// An optional user var controler.
NLMISC::TStringId _UserVarControler;
/// Group controller for gain
CGroupController *_GroupController;
};
} // NLSOUND

View file

@ -0,0 +1,100 @@
/**
* \file source_music_channel.h
* \brief CSourceMusicChannel
* \date 2012-04-11 16:08GMT
* \author Jan Boon (Kaetemi)
* CSourceMusicChannel
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_SOURCE_MUSIC_CHANNEL_H
#define NLSOUND_SOURCE_MUSIC_CHANNEL_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#include <nel/sound/driver/music_channel.h>
#include <nel/sound/stream_file_sound.h>
// Project includes
namespace NLSOUND {
class CStreamFileSource;
/**
* \brief CSourceMusicChannel
* \date 2012-04-11 16:08GMT
* \author Jan Boon (Kaetemi)
* CSourceMusicChannel
*/
class CSourceMusicChannel : public IMusicChannel
{
public:
CSourceMusicChannel();
virtual ~CSourceMusicChannel();
/** Play some music (.ogg etc...)
* NB: if an old music was played, it is first stop with stopMusic()
* \param filepath file path, CPath::lookup is done here
* \param async stream music from hard disk, preload in memory if false
* \param loop must be true to play the music in loop.
*/
virtual bool play(const std::string &filepath, bool async, bool loop);
/// Stop the music previously loaded and played (the Memory is also freed)
virtual void stop();
/// Makes sure any resources are freed, but keeps available for next play call
virtual void reset();
/// Pause the music previously loaded and played (the Memory is not freed)
virtual void pause();
/// Resume the music previously paused
virtual void resume();
/// Return true if a song is finished.
virtual bool isEnded();
/// Return true if the song is still loading asynchronously and hasn't started playing yet (false if not async), used to delay fading
virtual bool isLoadingAsync();
/// Return the total length (in second) of the music currently played
virtual float getLength();
/** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1)
* NB: the volume of music is NOT affected by IListener::setGain()
*/
virtual void setVolume(float gain);
private:
CStreamFileSound m_Sound;
CStreamFileSource *m_Source;
float m_Gain;
}; /* class CSourceMusicChannel */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_SOURCE_MUSIC_CHANNEL_H */
/* end of file */

View file

@ -0,0 +1,94 @@
/**
* \file stream_file_sound.h
* \brief CStreamFileSound
* \date 2012-04-11 09:57GMT
* \author Jan Boon (Kaetemi)
* CStreamFileSound
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_STREAM_FILE_SOUND_H
#define NLSOUND_STREAM_FILE_SOUND_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
#include <nel/sound/stream_sound.h>
namespace NLSOUND {
class CSourceMusicChannel;
/**
* \brief CStreamFileSound
* \date 2012-04-11 09:57GMT
* \author Jan Boon (Kaetemi)
* CStreamFileSound
*/
class CStreamFileSound : public CStreamSound
{
public:
friend class CSourceMusicChannel;
public:
CStreamFileSound();
virtual ~CStreamFileSound();
/// Get the type of the sound.
virtual TSOUND_TYPE getSoundType() { return SOUND_STREAM_FILE; }
/// Load the sound parameters from georges' form
virtual void importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot);
/// Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...).
virtual void getSubSoundList(std::vector<std::pair<std::string, CSound*> > &/* subsounds */) const { }
/// Serialize the sound data.
virtual void serial(NLMISC::IStream &s);
/// Return the length of the sound in ms
virtual uint32 getDuration() { return 0; }
inline bool getAsync() { return m_Async; }
inline const std::string &getFilePath() { return m_FilePath; }
private:
/// Used by CSourceMusicChannel to set the filePath and default settings on other parameters.
void setMusicFilePath(const std::string &filePath, bool async = true, bool loop = false);
private:
CStreamFileSound(const CStreamFileSound &);
CStreamFileSound &operator=(const CStreamFileSound &);
private:
bool m_Async;
std::string m_FilePath;
}; /* class CStreamFileSound */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_STREAM_FILE_SOUND_H */
/* end of file */

View file

@ -0,0 +1,110 @@
/**
* \file stream_file_source.h
* \brief CStreamFileSource
* \date 2012-04-11 09:57GMT
* \author Jan Boon (Kaetemi)
* CStreamFileSource
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_STREAM_FILE_SOURCE_H
#define NLSOUND_STREAM_FILE_SOURCE_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#include <nel/misc/thread.h>
// Project includes
#include <nel/sound/stream_source.h>
#include <nel/sound/stream_file_sound.h>
namespace NLSOUND {
class IAudioDecoder;
/**
* \brief CStreamFileSource
* \date 2012-04-11 09:57GMT
* \author Jan Boon (Kaetemi)
* CStreamFileSource
*/
class CStreamFileSource : public CStreamSource, private NLMISC::IRunnable
{
public:
CStreamFileSource(CStreamFileSound *streamFileSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL);
virtual ~CStreamFileSource();
/// Return the source type
TSOURCE_TYPE getType() const { return SOURCE_STREAM_FILE; }
/// \name Playback control
//@{
/// Play
virtual void play();
/// Stop playing
virtual void stop();
/// Get playing state. Return false even if the source has stopped on its own.
virtual bool isPlaying();
/// Pause (following legacy music channel implementation)
void pause();
/// Resume (following legacy music channel implementation)
void resume();
/// check if song ended (following legacy music channel implementation)
bool isEnded();
/// (following legacy music channel implementation)
float getLength();
/// check if still loading (following legacy music channel implementation)
bool isLoadingAsync();
//@}
/// \name Decoding thread
//@{
virtual void getName (std::string &result) const { result = "CStreamFileSource"; }
virtual void run();
//@}
// TODO: getTime
private:
bool prepareDecoder();
inline bool bufferMore(uint bytes);
private:
CStreamFileSource(const CStreamFileSource &);
CStreamFileSource &operator=(const CStreamFileSource &);
private:
inline CStreamFileSound *getStreamFileSound() { return static_cast<CStreamFileSound *>(m_StreamSound); }
NLMISC::IThread *m_Thread;
IAudioDecoder *m_AudioDecoder;
bool m_Paused;
}; /* class CStreamFileSource */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_STREAM_FILE_SOURCE_H */
/* end of file */

View file

@ -46,7 +46,7 @@ public:
virtual void importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot);
/// Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...).
virtual void getSubSoundList(std::vector<std::pair<std::string, CSound*> > &subsounds) const { }
virtual void getSubSoundList(std::vector<std::pair<std::string, CSound*> > &/* subsounds */) const { }
/// Serialize the sound data.
virtual void serial(NLMISC::IStream &s);

View file

@ -41,7 +41,7 @@ namespace NLSOUND {
class CStreamSource : public CSourceCommon
{
public:
CStreamSource(CStreamSound *streamSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0);
CStreamSource(CStreamSound *streamSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL);
virtual ~CStreamSource();
/// Return the sound binded to the source (or NULL if there is no sound)
@ -55,6 +55,9 @@ public:
virtual void setLooping(bool l);
/// Play
virtual void play();
protected:
void stopInt();
public:
/// Stop playing
virtual void stop();
/// Get playing state. Return false even if the source has stopped on its own.
@ -80,18 +83,7 @@ public:
virtual void setVelocity(const NLMISC::CVector& vel);
/// Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional)
virtual void setDirection(const NLMISC::CVector& dir);
/** Set the gain (volume value inside [0 , 1]). (default: 1)
* 0.0 -> silence
* 0.5 -> -6dB
* 1.0 -> no attenuation
* values > 1 (amplification) not supported by most drivers
*/
virtual void setGain(float gain);
/** Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain
* (which is getSource()->getGain()). Does nothing if getSource() is null.
*/
virtual void setRelativeGain(float gain);
virtual void updateFinalGain();
/** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift
* of one octave. 0 is not a legal value.
*/
@ -118,6 +110,9 @@ public:
virtual bool hasFilledBuffersAvailable() const;
//@}
/// Prepare the buffers in this stream for the given maximum capacity. (TODO: Move this into UStreamSource)
void preAllocate(uint capacity);
/// Return the track
CTrack *getTrack() { return m_Track; }
@ -125,7 +120,7 @@ private:
CStreamSource(const CStreamSource &);
CStreamSource &operator=(const CStreamSource &);
private:
protected:
/// Return the source type
TSOURCE_TYPE getType() const { return SOURCE_STREAM; }
@ -174,6 +169,12 @@ private:
/// The bytes per second according to the buffer format
uint m_BytesPerSecond;
/// Waiting for play for high priority sources
bool m_WaitingForPlay;
/// Inverse pitch
float m_PitchInv;
}; /* class CStreamSource */
} /* namespace NLSOUND */

View file

@ -20,6 +20,7 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/string_mapper.h"
#include "nel/sound/u_source.h"
#include "nel/sound/u_group_controller.h"
#include "nel/ligo/primitive.h"
#include <vector>
@ -285,15 +286,19 @@ public:
/// Get a TSoundId from a name (returns NULL if not found)
virtual TSoundId getSoundId( const NLMISC::TStringId &name ) = 0;
/// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created.
/// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera
virtual UGroupController *getGroupController(const std::string &path) = 0;
/** Add a logical sound source (returns NULL if name not found).
* If spawn is true, the source will auto-delete after playing. If so, the return USource* pointer
* is valid only before the time when calling play() plus the duration of the sound. You can
* pass a callback function that will be called (if not NULL) just before deleting the spawned
* source.
*/
virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context=0) = 0;
virtual USource *createSource(const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0;
/// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*)
virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context=0 ) = 0;
virtual USource *createSource(TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0;
/** Use this method to set the listener position instead of using getListener->setPos();
* It's because we have to update the background sounds in this case.

View file

@ -0,0 +1,65 @@
/**
* \file u_group_controller.h
* \brief UGroupController
* \date 2012-04-10 12:49GMT
* \author Jan Boon (Kaetemi)
* UGroupController
*/
/*
* Copyright (C) 2012 by authors
*
* This file is part of RYZOM CORE.
* RYZOM CORE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* RYZOM CORE 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
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with RYZOM CORE. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLSOUND_U_GROUP_CONTROLLER_H
#define NLSOUND_U_GROUP_CONTROLLER_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
// Project includes
#define NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER "sound:effects:game"
#define NLSOUND_SHEET_V1_DEFAULT_SOUND_MUSIC_GROUP_CONTROLLER "sound:music:game"
#define NLSOUND_SHEET_V1_DEFAULT_SOUND_STREAM_GROUP_CONTROLLER "sound:dialog:game"
namespace NLSOUND {
/**
* \brief UGroupController
* \date 2012-04-10 12:49GMT
* \author Jan Boon (Kaetemi)
* UGroupController
*/
class UGroupController
{
public:
virtual void setGain(float gain) = 0;
virtual float getGain() = 0;
protected:
virtual ~UGroupController() { }
}; /* class UGroupController */
} /* namespace NLSOUND */
#endif /* #ifndef NLSOUND_U_GROUP_CONTROLLER_H */
/* end of file */

View file

@ -17,5 +17,5 @@ IF(WITH_PACS)
ENDIF(WITH_PACS)
IF(WITH_SOUND)
ADD_SUBDIRECTORY(sound_sources)
ADD_SUBDIRECTORY(sound)
ENDIF(WITH_SOUND)

View file

@ -0,0 +1,5 @@
ADD_SUBDIRECTORY(sound_sources)
ADD_SUBDIRECTORY(stream_file)
ADD_SUBDIRECTORY(stream_ogg_vorbis)

View file

@ -7,7 +7,7 @@ ADD_DEFINITIONS(-DNL_SOUND_DATA="\\"${NL_SHARE_PREFIX}/nl_sample_sound/\\"" ${LI
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(nl_sample_sound_sources nelmisc nelsound)
NL_DEFAULT_PROPS(nl_sample_sound_sources "NeL, Samples: Sound System")
NL_DEFAULT_PROPS(nl_sample_sound_sources "NeL, Samples: Sound: Sound Sources")
NL_ADD_RUNTIME_FLAGS(nl_sample_sound_sources)
INSTALL(TARGETS nl_sample_sound_sources RUNTIME DESTINATION bin COMPONENT samplessound)

Some files were not shown because too many files have changed in this diff Show more