Merged: From default to pipeline_v3
--HG-- branch : build_pipeline_v3hg/feature/build_pipeline_v3
commit
3acb9620a5
@ -0,0 +1,49 @@
|
||||
# - Try to find OpenGL ES
|
||||
# Once done this will define
|
||||
#
|
||||
# OPENGLES_FOUND - system has OpenGL ES
|
||||
# OPENGLES_EGL_FOUND - system has EGL
|
||||
# OPENGLES_LIBRARIES - Link these to use OpenGL ES and EGL
|
||||
#
|
||||
# If you want to use just GL ES you can use these values
|
||||
# OPENGLES_GLES_LIBRARY - Path to OpenGL ES Library
|
||||
# OPENGLES_EGL_LIBRARY - Path to EGL Library
|
||||
|
||||
FIND_LIBRARY(OPENGLES_GLES_LIBRARY
|
||||
NAMES GLESv1_CM libGLESv1_CM gles_cm libgles_cm
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/usr/local/X11R6/lib
|
||||
/usr/X11R6/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
FIND_LIBRARY(OPENGLES_EGL_LIBRARY
|
||||
NAMES EGL libEGL
|
||||
PATHS
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
/usr/local/X11R6/lib
|
||||
/usr/X11R6/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
/opt/csw/lib
|
||||
/opt/lib
|
||||
/usr/freeware/lib64
|
||||
)
|
||||
|
||||
IF(OPENGLES_GLES_LIBRARY)
|
||||
SET(OPENGLES_FOUND "YES")
|
||||
SET(OPENGLES_LIBRARIES ${OPENGLES_GLES_LIBRARY} ${OPENGLES_LIBRARIES})
|
||||
IF(OPENGLES_EGL_LIBRARY)
|
||||
SET(OPENGLES_EGL_FOUND "YES")
|
||||
SET(OPENGLES_LIBRARIES ${OPENGLES_EGL_LIBRARY} ${OPENGLES_LIBRARIES})
|
||||
ELSE(OPENGLES_EGL_LIBRARY)
|
||||
SET(OPENGLES_EGL_FOUND "NO")
|
||||
ENDIF(OPENGLES_EGL_LIBRARY)
|
||||
ENDIF(OPENGLES_GLES_LIBRARY)
|
@ -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 = (uint16)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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -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 */
|
@ -0,0 +1,5 @@
|
||||
|
||||
ADD_SUBDIRECTORY(sound_sources)
|
||||
ADD_SUBDIRECTORY(stream_file)
|
||||
ADD_SUBDIRECTORY(stream_ogg_vorbis)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue