Support building nlsound lowlevel as dll

feature/nel-dll
kaetemi 6 years ago
parent 40a000c0c5
commit c2a6fad386

@ -544,14 +544,21 @@ typedef uint16 ucchar;
#define NL_DECL_DLLIMP
#endif
// TODO: Move this within libraries?
#ifdef NL_DLLEXP
#ifdef NLMISC_DLLEXP
#define NLMISC_API NL_DECL_DLLEXP
#else
#define NLMISC_API NL_DECL_DLLIMP
#endif
#ifdef NLSOUND_LOWLEVEL_DLLEXP
#define NLSOUND_LOWLEVEL_API NL_DECL_DLLEXP
#else
#define NLSOUND_LOWLEVEL_API NL_DECL_DLLIMP
#endif
#else
#define NLMISC_API
#define NLSOUND_LOWLEVEL_API
#endif
// To define a 64bits constant; ie: UINT64_CONSTANT(0x123456781234)

@ -99,21 +99,21 @@ public:
//@{
//\name ***deprecated***
/// Set the sample format. Example: freq=44100. ***deprecated***
void setFormat(TSampleFormat format, uint freq);
NLSOUND_LOWLEVEL_API void setFormat(TSampleFormat format, uint freq);
/// Return the format and frequency. ***deprecated***
void getFormat(TSampleFormat& format, uint& freq) const;
NLSOUND_LOWLEVEL_API void getFormat(TSampleFormat &format, uint &freq) const;
/// Convert old sample format to new buffer format
static void sampleFormatToBufferFormat(TSampleFormat sampleFormat, TBufferFormat &bufferFormat, uint8 &channels, uint8 &bitsPerSample);
NLSOUND_LOWLEVEL_API static void sampleFormatToBufferFormat(TSampleFormat sampleFormat, TBufferFormat &bufferFormat, uint8 &channels, uint8 &bitsPerSample);
/// Convert new buffer format to old sample format
static void bufferFormatToSampleFormat(TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, TSampleFormat &sampleFormat);
NLSOUND_LOWLEVEL_API static void bufferFormatToSampleFormat(TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, TSampleFormat &sampleFormat);
//@}
//@{
//\name Utility functions
/// Return pcm size in bytes from duration in seconds.
static uint getPCMSizeFromDuration(float duration, uint8 channels, uint8 bitsPerSample, uint32 frequency);
NLSOUND_LOWLEVEL_API static uint getPCMSizeFromDuration(float duration, uint8 channels, uint8 bitsPerSample, uint32 frequency);
/// Return duration in seconds from pcm size in bytes.
static float getDurationFromPCMSize(uint size, uint8 channels, uint8 bitsPerSample, uint32 frequency);
NLSOUND_LOWLEVEL_API static float getDurationFromPCMSize(uint size, uint8 channels, uint8 bitsPerSample, uint32 frequency);
//@}
//@{
@ -126,17 +126,17 @@ public:
uint8 StepIndex;
};
/// Encode 16bit Mono PCM buffer into Mono ADPCM.
static void encodeADPCM(const sint16 *indata, uint8 *outdata, uint nbSample, TADPCMState &state);
NLSOUND_LOWLEVEL_API static void encodeADPCM(const sint16 *indata, uint8 *outdata, uint nbSample, TADPCMState &state);
/// Decode Mono ADPCM into 16bit Mono PCM.
static void decodeADPCM(const uint8 *indata, sint16 *outdata, uint nbSample, TADPCMState &state);
NLSOUND_LOWLEVEL_API static void decodeADPCM(const uint8 *indata, sint16 *outdata, uint nbSample, TADPCMState &state);
/// Read a wav file. Data type uint8 is used as unspecified buffer format.
static bool readWav(const uint8 *wav, uint size, std::vector<uint8> &result, TBufferFormat &bufferFormat, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency);
NLSOUND_LOWLEVEL_API static bool readWav(const uint8 *wav, uint size, std::vector<uint8> &result, TBufferFormat &bufferFormat, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency);
/// Write a wav file. Data type uint8 does not imply a buffer of any format.
static bool writeWav(const uint8 *buffer, uint size, TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, uint32 frequency, NLMISC::IStream &out);
NLSOUND_LOWLEVEL_API static bool writeWav(const uint8 *buffer, uint size, TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, uint32 frequency, NLMISC::IStream &out);
/// Convert buffer data to 16bit Mono PCM. Resulting vector size is in samples.
static bool convertToMono16PCM(const uint8 *buffer, uint size, std::vector<sint16> &result, TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample);
NLSOUND_LOWLEVEL_API static bool convertToMono16PCM(const uint8 *buffer, uint size, std::vector<sint16> &result, TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample);
/// Convert 16bit Mono PCM buffer data to ADPCM.
static bool convertMono16PCMToMonoADPCM(const sint16 *buffer, uint samples, std::vector<uint8> &result);
NLSOUND_LOWLEVEL_API static bool convertMono16PCMToMonoADPCM(const sint16 *buffer, uint samples, std::vector<uint8> &result);
//@}
private:

@ -165,8 +165,8 @@ public:
/* This struct can *float* on water! */
};
IReverbEffect();
virtual ~IReverbEffect();
IReverbEffect() {}
virtual ~IReverbEffect() {}
/// Set the environment (you have full control now, have fun); size: [1.0, 100.0] in meters, default: 7.5 m; influences environment parameters, 7.5 is no change
virtual void setEnvironment(const CEnvironment &environment = CEnvironment(), float roomSize = 7.5f) = 0;

@ -25,8 +25,8 @@
#include "effect.h"
/// This namespace contains the sound classes
namespace NLSOUND
{
namespace NLSOUND {
class IBuffer;
class IListener;
class ISource;
@ -38,6 +38,12 @@ namespace NLSOUND
# define EAX_AVAILABLE 0
#endif
/// Version of the driver interface. To increment when the interface change.
/// Interface version, increase when any part of sound_lowlevel is changed.
/// Put your name in comment to make sure you don't commit with
/// the same interface version number as someone else.
#define NLSOUND_INTERFACE_VERSION 0x17 // Kaetemi
/*
* Deprecated sound sample format.
* For compatibility with old code.
@ -119,16 +125,14 @@ public:
virtual const std::string &unmap(const NLMISC::TStringId &stringId) = 0;
};
/// Version of the driver interface. To increment when the interface change.
static const uint32 InterfaceVersion;
/// Return driver name from type.
static const char *getDriverName(TDriver driverType);
NLSOUND_LOWLEVEL_API static const char *getDriverName(TDriver driverType);
/** The static method which builds the sound driver instance
* In case of failure, can throw one of these ESoundDriver exception objects:
* ESoundDriverNotFound, ESoundDriverCorrupted, ESoundDriverOldVersion, ESoundDriverUnknownVersion
*/
static ISoundDriver *createDriver(IStringMapperProvider *stringMapper, TDriver driverType = DriverAuto);
NLSOUND_LOWLEVEL_API static ISoundDriver *createDriver(int interfaceVersion, IStringMapperProvider *stringMapper, TDriver driverType = DriverAuto);
inline static ISoundDriver *createDriver(IStringMapperProvider *stringMapper, TDriver driverType = DriverAuto) { return createDriver(NLSOUND_INTERFACE_VERSION, stringMapper, driverType); }
/// Constructor
ISoundDriver() { }

@ -481,9 +481,9 @@ public:
protected:
// common method used only with OptionManualRolloff. return the volume in 1/100th DB ( = mB)modified
static sint32 computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax, double alpha, float sqrdist, float distMin, float distMax);
NLSOUND_LOWLEVEL_API static sint32 computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax, double alpha, float sqrdist, float distMin, float distMax);
// common method used only with OptionManualRolloff. return the rolloff in amplitude ratio (gain)
static float computeManualRolloff(double alpha, float sqrdist, float distMin, float distMax);
NLSOUND_LOWLEVEL_API static float computeManualRolloff(double alpha, float sqrdist, float distMin, float distMax);
};

@ -1,7 +1,7 @@
FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../../../include/nel/sound/driver/*.h)
NL_TARGET_LIB(nelsnd_lowlevel ${HEADERS} ${SRC})
NL_TARGET_LIB2(nelsnd_lowlevel ${HEADERS} ${SRC})
TARGET_LINK_LIBRARIES(nelsnd_lowlevel nelmisc)
NL_DEFAULT_PROPS(nelsnd_lowlevel "NeL, Library: Sound Lowlevel")
@ -10,6 +10,10 @@ NL_ADD_STATIC_SND_DRIVERS(nelsnd_lowlevel)
NL_ADD_LIB_SUFFIX(nelsnd_lowlevel)
IF(WIN32 AND NOT WITH_STATIC2)
ADD_DEFINITIONS(-DNLSOUND_LOWLEVEL_DLLEXP)
ENDIF()
IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(nelsnd_lowlevel ${CMAKE_CURRENT_SOURCE_DIR}/stdsound_lowlevel.h ${CMAKE_CURRENT_SOURCE_DIR}/stdsound_lowlevel.cpp)
ENDIF()

@ -143,7 +143,7 @@ uint32 interfaceVersionDSound()
__declspec(dllexport) uint32 NLSOUND_interfaceVersion()
#endif
{
return ISoundDriver::InterfaceVersion;
return NLSOUND_INTERFACE_VERSION;
}
// ******************************************************************

@ -22,17 +22,12 @@
using namespace std;
// using namespace NLMISC;
namespace NLSOUND {
IReverbEffect::IReverbEffect()
// leave not static else this workaround don't work
void dummyToAvoidStupidCompilerWarning_effect_cpp()
{
}
IReverbEffect::~IReverbEffect()
{
}
namespace NLSOUND {
} /* namespace NLSOUND */

@ -122,7 +122,7 @@ uint32 interfaceVersionOpenAl()
__declspec(dllexport) uint32 NLSOUND_interfaceVersion()
#endif
{
return ISoundDriver::InterfaceVersion;
return NLSOUND_INTERFACE_VERSION;
}
// ******************************************************************
@ -172,7 +172,7 @@ ISoundDriver* NLSOUND_createISoundDriverInstance(ISoundDriver::IStringMapperProv
uint32 NLSOUND_interfaceVersion ()
{
return ISoundDriver::InterfaceVersion;
return NLSOUND_INTERFACE_VERSION;
}
#ifndef NL_STATIC

@ -47,13 +47,7 @@
using namespace NLMISC;
namespace NLSOUND
{
/// Interface version, increase when any part of sound_lowlevel is changed.
/// Put your name in comment to make sure you don't commit with
/// the same interface version number as someone else.
const uint32 ISoundDriver::InterfaceVersion = 0x16; // Kaetemi
namespace NLSOUND {
#ifdef NL_STATIC
@ -103,8 +97,13 @@ const char *ISoundDriver::getDriverName(TDriver driverType)
/*
* The static method which builds the sound driver instance
*/
ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TDriver driverType)
ISoundDriver *ISoundDriver::createDriver(int interfaceVersion, IStringMapperProvider *stringMapper, TDriver driverType)
{
if (interfaceVersion < NLSOUND_INTERFACE_VERSION)
throw ESoundDriverUnknownVersion("nlsnd_lowlevel");
else if (interfaceVersion > NLSOUND_INTERFACE_VERSION)
throw ESoundDriverOldVersion("nlsnd_lowlevel");
#ifdef NL_STATIC
nlinfo("Creating statically linked sound driver %s", getDriverName(driverType));
@ -245,9 +244,9 @@ ISoundDriver *ISoundDriver::createDriver(IStringMapperProvider *stringMapper, TD
versionDriver = (ISDRV_VERSION_PROC) driverLib.getSymbolAddress(IDRV_VERSION_PROC_NAME);
if (versionDriver != NULL)
{
if (versionDriver()<ISoundDriver::InterfaceVersion)
if (versionDriver() < NLSOUND_INTERFACE_VERSION)
throw ESoundDriverOldVersion(dllName);
else if (versionDriver()>ISoundDriver::InterfaceVersion)
else if (versionDriver() > NLSOUND_INTERFACE_VERSION)
throw ESoundDriverUnknownVersion(dllName);
}

@ -83,7 +83,7 @@ uint32 interfaceVersionXAudio2()
__declspec(dllexport) uint32 NLSOUND_interfaceVersion()
#endif
{
return ISoundDriver::InterfaceVersion;
return NLSOUND_INTERFACE_VERSION;
}
// ******************************************************************

Loading…
Cancel
Save