Changed: #1030 Implement music streaming in OpenAL driver

This commit is contained in:
kervala 2010-07-27 17:43:36 +02:00
parent b056f84343
commit 7236c83bc4
21 changed files with 180 additions and 52 deletions

View file

@ -17,12 +17,14 @@
#ifndef NLSOUND_MUSIC_BUFFER_H #ifndef NLSOUND_MUSIC_BUFFER_H
#define NLSOUND_MUSIC_BUFFER_H #define NLSOUND_MUSIC_BUFFER_H
namespace NLMISC { namespace NLMISC
{
class IStream; class IStream;
class CIFile; class CIFile;
} }
namespace NLSOUND { namespace NLSOUND
{
/* /*
* TODO: Streaming * TODO: Streaming

View file

@ -34,7 +34,8 @@
// Project includes // Project includes
#include "music_buffer.h" #include "music_buffer.h"
namespace NLSOUND { namespace NLSOUND
{
/** /**
* \brief CMusicBufferVorbis * \brief CMusicBufferVorbis

View file

@ -16,16 +16,17 @@
#ifndef NL_SOUND_DRIVER_H #ifndef NL_SOUND_DRIVER_H
#define NL_SOUND_DRIVER_H #define NL_SOUND_DRIVER_H
#include <nel/misc/types_nl.h>
#include <nel/misc/common.h> #include "nel/misc/types_nl.h"
#include <nel/misc/file.h> #include "nel/misc/common.h"
#include <nel/misc/string_mapper.h> #include "nel/misc/file.h"
#include "nel/misc/string_mapper.h"
#include "effect.h" #include "effect.h"
/// This namespace contains the sound classes /// This namespace contains the sound classes
namespace NLSOUND { namespace NLSOUND
{
class IBuffer; class IBuffer;
class IListener; class IListener;
class ISource; class ISource;
@ -40,7 +41,7 @@ namespace NLSOUND {
/* /*
* Sound sample format * Sound sample format
*/ */
enum TSampleFormat { Mono8, Mono16ADPCM, Mono16, Stereo8, Stereo16 }; enum TSampleFormat { SampleFormatUnknown, Mono8, Mono16ADPCM, Mono16, Stereo8, Stereo16 };
/** /**
* Abstract sound driver (implemented in sound driver dynamic library) * Abstract sound driver (implemented in sound driver dynamic library)

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9.00" Version="9,00"
Name="sound" Name="sound"
ProjectGUID="{4AF7ADB2-DAF8-4F04-9793-F92010001470}" ProjectGUID="{4AF7ADB2-DAF8-4F04-9793-F92010001470}"
RootNamespace="sound" RootNamespace="sound"

View file

@ -9,6 +9,10 @@ ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
NL_ADD_STATIC_VID_DRIVERS(nelsnd_lowlevel) NL_ADD_STATIC_VID_DRIVERS(nelsnd_lowlevel)
nl_add_lib_suffix(nelsnd_lowlevel) nl_add_lib_suffix(nelsnd_lowlevel)
IF(WITH_PCH)
ADD_NATIVE_PRECOMPILED_HEADER(nelsnd_lowlevel ${CMAKE_CURRENT_SOURCE_DIR}/stdsound_lowlevel.h ${CMAKE_CURRENT_SOURCE_DIR}/stdsound_lowlevel.cpp)
ENDIF(WITH_PCH)
INSTALL(TARGETS nelsnd_lowlevel LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries) INSTALL(TARGETS nelsnd_lowlevel LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
IF(WITH_DRIVER_OPENAL) IF(WITH_DRIVER_OPENAL)

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdsound_lowlevel.h"
#include "nel/sound/driver/buffer.h" #include "nel/sound/driver/buffer.h"
#include "nel/misc/fast_mem.h" #include "nel/misc/fast_mem.h"
#include "nel/misc/stream.h" #include "nel/misc/stream.h"
@ -117,7 +119,7 @@ void IBuffer::bufferFormatToSampleFormat(TBufferFormat bufferFormat, uint8 chann
break; break;
case FormatUnknown: case FormatUnknown:
default: default:
sampleFormat = (TSampleFormat)~0; sampleFormat = SampleFormatUnknown;
break; break;
} }
} }

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdsound_lowlevel.h"
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/sound/driver/effect.h" #include "nel/sound/driver/effect.h"

View file

@ -14,8 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/sound/driver/listener.h" #include "stdsound_lowlevel.h"
// leave not static else this workaround don't work // leave not static else this workaround don't work
void dummyToAvoidStupidCompilerWarning_sound_listener_cpp() void dummyToAvoidStupidCompilerWarning_sound_listener_cpp()

View file

@ -14,11 +14,10 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdxaudio2.h" #include "stdsound_lowlevel.h"
// Project includes #include "nel/sound/driver/music_buffer_vorbis.h"
#include "music_buffer_vorbis.h" #include "nel/sound/driver/music_buffer.h"
#include "music_buffer.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;

View file

@ -14,15 +14,16 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdxaudio2.h" #include "stdsound_lowlevel.h"
// Project includes // Project includes
#include "music_buffer_vorbis.h" #include "nel/sound/driver/music_buffer_vorbis.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
namespace NLSOUND { namespace NLSOUND
{
size_t vorbisReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) size_t vorbisReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource)
{ {

View file

@ -14,7 +14,8 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <nel/misc/types_nl.h> #include "stdsound_lowlevel.h"
#include "nel/sound/driver/music_channel.h" #include "nel/sound/driver/music_channel.h"
using namespace std; using namespace std;

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdsound_lowlevel.h"
#include "nel/sound/driver/sound_driver.h" #include "nel/sound/driver/sound_driver.h"
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9.00" Version="9,00"
Name="sound_lowlevel" Name="sound_lowlevel"
ProjectGUID="{89064E9B-14E9-4FB2-8536-A9151DF55C68}" ProjectGUID="{89064E9B-14E9-4FB2-8536-A9151DF55C68}"
RootNamespace="sound_lowlevel" RootNamespace="sound_lowlevel"
@ -54,6 +54,8 @@
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
SmallerTypeCheck="true" SmallerTypeCheck="true"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdsound_lowlevel.h"
WarningLevel="3" WarningLevel="3"
SuppressStartupBanner="true" SuppressStartupBanner="true"
DebugInformationFormat="3" DebugInformationFormat="3"
@ -71,6 +73,7 @@
/> />
<Tool <Tool
Name="VCLibrarianTool" Name="VCLibrarianTool"
AdditionalDependencies=" libogg.lib libvorbis.lib libvorbisfile.lib"
OutputFile="..\..\..\lib\nl$(ProjectName)_d.lib" OutputFile="..\..\..\lib\nl$(ProjectName)_d.lib"
/> />
<Tool <Tool
@ -126,6 +129,8 @@
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
SmallerTypeCheck="true" SmallerTypeCheck="true"
RuntimeLibrary="3" RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdsound_lowlevel.h"
WarningLevel="3" WarningLevel="3"
SuppressStartupBanner="true" SuppressStartupBanner="true"
DebugInformationFormat="3" DebugInformationFormat="3"
@ -143,6 +148,7 @@
/> />
<Tool <Tool
Name="VCLibrarianTool" Name="VCLibrarianTool"
AdditionalDependencies=" libogg.lib libvorbis.lib libvorbisfile.lib"
OutputFile="..\..\..\lib64\nl$(ProjectName)_d.lib" OutputFile="..\..\..\lib64\nl$(ProjectName)_d.lib"
/> />
<Tool <Tool
@ -201,6 +207,8 @@
ExceptionHandling="2" ExceptionHandling="2"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="false" BufferSecurityCheck="false"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdsound_lowlevel.h"
WarningLevel="3" WarningLevel="3"
SuppressStartupBanner="true" SuppressStartupBanner="true"
DebugInformationFormat="3" DebugInformationFormat="3"
@ -218,6 +226,7 @@
/> />
<Tool <Tool
Name="VCLibrarianTool" Name="VCLibrarianTool"
AdditionalDependencies=" libogg.lib libvorbis.lib libvorbisfile.lib"
OutputFile="..\..\..\lib\nl$(ProjectName)_r.lib" OutputFile="..\..\..\lib\nl$(ProjectName)_r.lib"
/> />
<Tool <Tool
@ -277,6 +286,8 @@
ExceptionHandling="2" ExceptionHandling="2"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="false" BufferSecurityCheck="false"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="stdsound_lowlevel.h"
WarningLevel="2" WarningLevel="2"
SuppressStartupBanner="true" SuppressStartupBanner="true"
DebugInformationFormat="3" DebugInformationFormat="3"
@ -294,6 +305,7 @@
/> />
<Tool <Tool
Name="VCLibrarianTool" Name="VCLibrarianTool"
AdditionalDependencies=" libogg.lib libvorbis.lib libvorbisfile.lib"
OutputFile="..\..\..\lib64\nl$(ProjectName)_r.lib" OutputFile="..\..\..\lib64\nl$(ProjectName)_r.lib"
/> />
<Tool <Tool
@ -331,6 +343,14 @@
RelativePath="..\..\..\include\nel\sound\driver\listener.h" RelativePath="..\..\..\include\nel\sound\driver\listener.h"
> >
</File> </File>
<File
RelativePath="..\..\..\include\nel\sound\driver\music_buffer.h"
>
</File>
<File
RelativePath="..\..\..\include\nel\sound\driver\music_buffer_vorbis.h"
>
</File>
<File <File
RelativePath="..\..\..\include\nel\sound\driver\music_channel.h" RelativePath="..\..\..\include\nel\sound\driver\music_channel.h"
> >
@ -356,6 +376,14 @@
RelativePath="listener.cpp" RelativePath="listener.cpp"
> >
</File> </File>
<File
RelativePath=".\music_buffer.cpp"
>
</File>
<File
RelativePath=".\music_buffer_vorbis.cpp"
>
</File>
<File <File
RelativePath=".\music_channel.cpp" RelativePath=".\music_channel.cpp"
> >
@ -368,6 +396,46 @@
RelativePath="source.cpp" RelativePath="source.cpp"
> >
</File> </File>
<File
RelativePath=".\stdsound_lowlevel.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\stdsound_lowlevel.h"
>
</File>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

View file

@ -14,10 +14,9 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/sound/driver/source.h" #include "stdsound_lowlevel.h"
#include "nel/misc/common.h"
#include <limits> #include "nel/sound/driver/source.h"
using namespace NLMISC; using namespace NLMISC;

View file

@ -0,0 +1,24 @@
// 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/>.
#include "stdsound_lowlevel.h"
// leave not static else this workaround don't work
void dummyToAvoidStupidCompilerWarning_std_sound_lowlevel_cpp()
{
}

View file

@ -0,0 +1,42 @@
// 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/>.
#include "nel/misc/types_nl.h"
#include "nel/misc/common.h"
#include "nel/misc/debug.h"
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
//#include <sstream>
#include <exception>
#include <utility>
#include <deque>
#include <limits>
#include <numeric>
#include <iomanip>
#include "nel/misc/vector.h"
#include "nel/misc/path.h"
#include "nel/misc/file.h"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9.00" Version="9,00"
Name="driver_xaudio2" Name="driver_xaudio2"
ProjectGUID="{23DCF574-1CEB-4DF4-9C59-D614580AC0C0}" ProjectGUID="{23DCF574-1CEB-4DF4-9C59-D614580AC0C0}"
RootNamespace="xaudio2" RootNamespace="xaudio2"
@ -67,7 +67,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="libogg.lib libvorbis.lib libvorbisfile.lib x3daudio.lib" AdditionalDependencies="x3daudio.lib"
OutputFile="..\..\..\..\lib\nel_drv_$(RootNamespace)_win_d.dll" OutputFile="..\..\..\..\lib\nel_drv_$(RootNamespace)_win_d.dll"
IgnoreDefaultLibraryNames="msvcrt.lib" IgnoreDefaultLibraryNames="msvcrt.lib"
ModuleDefinitionFile="$(ProjectName).def" ModuleDefinitionFile="$(ProjectName).def"
@ -148,7 +148,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="libogg.lib libvorbis.lib libvorbisfile.lib x3daudio.lib" AdditionalDependencies="x3daudio.lib"
OutputFile="..\..\..\..\lib64\nel_drv_$(RootNamespace)_win_d.dll" OutputFile="..\..\..\..\lib64\nel_drv_$(RootNamespace)_win_d.dll"
IgnoreDefaultLibraryNames="msvcrt.lib" IgnoreDefaultLibraryNames="msvcrt.lib"
ModuleDefinitionFile="$(ProjectName).def" ModuleDefinitionFile="$(ProjectName).def"
@ -231,7 +231,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="libogg.lib libvorbis.lib libvorbisfile.lib x3daudio.lib" AdditionalDependencies="x3daudio.lib"
OutputFile="..\..\..\..\lib\nel_drv_$(RootNamespace)_win_r.dll" OutputFile="..\..\..\..\lib\nel_drv_$(RootNamespace)_win_r.dll"
IgnoreDefaultLibraryNames="" IgnoreDefaultLibraryNames=""
ModuleDefinitionFile="$(ProjectName).def" ModuleDefinitionFile="$(ProjectName).def"
@ -317,7 +317,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="libogg.lib libvorbis.lib libvorbisfile.lib x3daudio.lib" AdditionalDependencies="x3daudio.lib"
OutputFile="..\..\..\..\lib64\nel_drv_$(RootNamespace)_win_r.dll" OutputFile="..\..\..\..\lib64\nel_drv_$(RootNamespace)_win_r.dll"
IgnoreDefaultLibraryNames="" IgnoreDefaultLibraryNames=""
ModuleDefinitionFile="$(ProjectName).def" ModuleDefinitionFile="$(ProjectName).def"
@ -405,26 +405,6 @@
RelativePath=".\music_channel_xaudio2.h" RelativePath=".\music_channel_xaudio2.h"
> >
</File> </File>
<Filter
Name="utility"
>
<File
RelativePath=".\music_buffer.cpp"
>
</File>
<File
RelativePath=".\music_buffer.h"
>
</File>
<File
RelativePath=".\music_buffer_vorbis.cpp"
>
</File>
<File
RelativePath=".\music_buffer_vorbis.h"
>
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="efx" Name="efx"

View file

@ -18,7 +18,6 @@
// Project includes // Project includes
#include "sound_driver_xaudio2.h" #include "sound_driver_xaudio2.h"
#include "music_buffer.h"
#include "music_channel_xaudio2.h" #include "music_channel_xaudio2.h"
using namespace std; using namespace std;

View file

@ -22,7 +22,6 @@
#include "music_channel_xaudio2.h" #include "music_channel_xaudio2.h"
#include "effect_xaudio2.h" #include "effect_xaudio2.h"
#include "sound_driver_xaudio2.h" #include "sound_driver_xaudio2.h"
#include "music_buffer.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;

View file

@ -57,6 +57,7 @@
#include "nel/sound/driver/listener.h" #include "nel/sound/driver/listener.h"
#include "nel/sound/driver/sound_driver.h" #include "nel/sound/driver/sound_driver.h"
#include "nel/sound/driver/source.h" #include "nel/sound/driver/source.h"
#include "nel/sound/driver/music_buffer.h"
// Defines // Defines
#define NLSOUND_XAUDIO2_NAME "NeLSound XAudio2 Driver" #define NLSOUND_XAUDIO2_NAME "NeLSound XAudio2 Driver"

View file

@ -38,3 +38,5 @@
#include <iomanip> #include <iomanip>
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
#include "nel/misc/path.h"
#include "nel/misc/file.h"