From 7236c83bc4d958c6f03ffa7fd10a26b4e453eccd Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 27 Jul 2010 17:43:36 +0200 Subject: [PATCH] Changed: #1030 Implement music streaming in OpenAL driver --- .../nel/sound/driver}/music_buffer.h | 6 +- .../nel/sound/driver}/music_buffer_vorbis.h | 3 +- .../include/nel/sound/driver/sound_driver.h | 13 ++-- code/nel/src/sound.vcproj | 2 +- code/nel/src/sound/driver/CMakeLists.txt | 4 ++ code/nel/src/sound/driver/buffer.cpp | 4 +- code/nel/src/sound/driver/effect.cpp | 2 + code/nel/src/sound/driver/listener.cpp | 3 +- .../driver/{xaudio2 => }/music_buffer.cpp | 7 +- .../{xaudio2 => }/music_buffer_vorbis.cpp | 7 +- code/nel/src/sound/driver/music_channel.cpp | 3 +- code/nel/src/sound/driver/sound_driver.cpp | 2 + .../src/sound/driver/sound_lowlevel.vcproj | 70 ++++++++++++++++++- code/nel/src/sound/driver/source.cpp | 5 +- .../src/sound/driver/stdsound_lowlevel.cpp | 24 +++++++ code/nel/src/sound/driver/stdsound_lowlevel.h | 42 +++++++++++ .../driver/xaudio2/driver_xaudio2.vcproj | 30 ++------ .../driver/xaudio2/music_channel_xaudio2.cpp | 1 - .../driver/xaudio2/sound_driver_xaudio2.cpp | 1 - .../nel/src/sound/driver/xaudio2/stdxaudio2.h | 1 + code/nel/src/sound/stdsound.h | 2 + 21 files changed, 180 insertions(+), 52 deletions(-) rename code/nel/{src/sound/driver/xaudio2 => include/nel/sound/driver}/music_buffer.h (97%) rename code/nel/{src/sound/driver/xaudio2 => include/nel/sound/driver}/music_buffer_vorbis.h (96%) rename code/nel/src/sound/driver/{xaudio2 => }/music_buffer.cpp (92%) rename code/nel/src/sound/driver/{xaudio2 => }/music_buffer_vorbis.cpp (95%) create mode 100644 code/nel/src/sound/driver/stdsound_lowlevel.cpp create mode 100644 code/nel/src/sound/driver/stdsound_lowlevel.h diff --git a/code/nel/src/sound/driver/xaudio2/music_buffer.h b/code/nel/include/nel/sound/driver/music_buffer.h similarity index 97% rename from code/nel/src/sound/driver/xaudio2/music_buffer.h rename to code/nel/include/nel/sound/driver/music_buffer.h index a79f009d8..a9df6c495 100644 --- a/code/nel/src/sound/driver/xaudio2/music_buffer.h +++ b/code/nel/include/nel/sound/driver/music_buffer.h @@ -17,12 +17,14 @@ #ifndef NLSOUND_MUSIC_BUFFER_H #define NLSOUND_MUSIC_BUFFER_H -namespace NLMISC { +namespace NLMISC +{ class IStream; class CIFile; } -namespace NLSOUND { +namespace NLSOUND +{ /* * TODO: Streaming diff --git a/code/nel/src/sound/driver/xaudio2/music_buffer_vorbis.h b/code/nel/include/nel/sound/driver/music_buffer_vorbis.h similarity index 96% rename from code/nel/src/sound/driver/xaudio2/music_buffer_vorbis.h rename to code/nel/include/nel/sound/driver/music_buffer_vorbis.h index ece5caebb..8971a8a74 100644 --- a/code/nel/src/sound/driver/xaudio2/music_buffer_vorbis.h +++ b/code/nel/include/nel/sound/driver/music_buffer_vorbis.h @@ -34,7 +34,8 @@ // Project includes #include "music_buffer.h" -namespace NLSOUND { +namespace NLSOUND +{ /** * \brief CMusicBufferVorbis diff --git a/code/nel/include/nel/sound/driver/sound_driver.h b/code/nel/include/nel/sound/driver/sound_driver.h index 8cc2ee053..193026a42 100644 --- a/code/nel/include/nel/sound/driver/sound_driver.h +++ b/code/nel/include/nel/sound/driver/sound_driver.h @@ -16,16 +16,17 @@ #ifndef NL_SOUND_DRIVER_H #define NL_SOUND_DRIVER_H -#include -#include -#include -#include +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/file.h" +#include "nel/misc/string_mapper.h" #include "effect.h" /// This namespace contains the sound classes -namespace NLSOUND { +namespace NLSOUND +{ class IBuffer; class IListener; class ISource; @@ -40,7 +41,7 @@ namespace NLSOUND { /* * 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) diff --git a/code/nel/src/sound.vcproj b/code/nel/src/sound.vcproj index 1544192c9..9bac47fe2 100644 --- a/code/nel/src/sound.vcproj +++ b/code/nel/src/sound.vcproj @@ -1,7 +1,7 @@ . +#include "stdsound_lowlevel.h" + #include "nel/sound/driver/buffer.h" #include "nel/misc/fast_mem.h" #include "nel/misc/stream.h" @@ -117,7 +119,7 @@ void IBuffer::bufferFormatToSampleFormat(TBufferFormat bufferFormat, uint8 chann break; case FormatUnknown: default: - sampleFormat = (TSampleFormat)~0; + sampleFormat = SampleFormatUnknown; break; } } diff --git a/code/nel/src/sound/driver/effect.cpp b/code/nel/src/sound/driver/effect.cpp index a512fce35..23f242e6c 100644 --- a/code/nel/src/sound/driver/effect.cpp +++ b/code/nel/src/sound/driver/effect.cpp @@ -14,6 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "stdsound_lowlevel.h" + #include "nel/misc/types_nl.h" #include "nel/sound/driver/effect.h" diff --git a/code/nel/src/sound/driver/listener.cpp b/code/nel/src/sound/driver/listener.cpp index 9f9476ea8..2341421ac 100644 --- a/code/nel/src/sound/driver/listener.cpp +++ b/code/nel/src/sound/driver/listener.cpp @@ -14,8 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/sound/driver/listener.h" - +#include "stdsound_lowlevel.h" // leave not static else this workaround don't work void dummyToAvoidStupidCompilerWarning_sound_listener_cpp() diff --git a/code/nel/src/sound/driver/xaudio2/music_buffer.cpp b/code/nel/src/sound/driver/music_buffer.cpp similarity index 92% rename from code/nel/src/sound/driver/xaudio2/music_buffer.cpp rename to code/nel/src/sound/driver/music_buffer.cpp index 1ebf30b4c..bf38be0f5 100644 --- a/code/nel/src/sound/driver/xaudio2/music_buffer.cpp +++ b/code/nel/src/sound/driver/music_buffer.cpp @@ -14,11 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdxaudio2.h" +#include "stdsound_lowlevel.h" -// Project includes -#include "music_buffer_vorbis.h" -#include "music_buffer.h" +#include "nel/sound/driver/music_buffer_vorbis.h" +#include "nel/sound/driver/music_buffer.h" using namespace std; using namespace NLMISC; diff --git a/code/nel/src/sound/driver/xaudio2/music_buffer_vorbis.cpp b/code/nel/src/sound/driver/music_buffer_vorbis.cpp similarity index 95% rename from code/nel/src/sound/driver/xaudio2/music_buffer_vorbis.cpp rename to code/nel/src/sound/driver/music_buffer_vorbis.cpp index 8eaeb375f..e9df6d0d1 100644 --- a/code/nel/src/sound/driver/xaudio2/music_buffer_vorbis.cpp +++ b/code/nel/src/sound/driver/music_buffer_vorbis.cpp @@ -14,15 +14,16 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdxaudio2.h" +#include "stdsound_lowlevel.h" // Project includes -#include "music_buffer_vorbis.h" +#include "nel/sound/driver/music_buffer_vorbis.h" using namespace std; using namespace NLMISC; -namespace NLSOUND { +namespace NLSOUND +{ size_t vorbisReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) { diff --git a/code/nel/src/sound/driver/music_channel.cpp b/code/nel/src/sound/driver/music_channel.cpp index 4c658e077..8e488858e 100644 --- a/code/nel/src/sound/driver/music_channel.cpp +++ b/code/nel/src/sound/driver/music_channel.cpp @@ -14,7 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "stdsound_lowlevel.h" + #include "nel/sound/driver/music_channel.h" using namespace std; diff --git a/code/nel/src/sound/driver/sound_driver.cpp b/code/nel/src/sound/driver/sound_driver.cpp index 023104953..c0ca3d5bc 100644 --- a/code/nel/src/sound/driver/sound_driver.cpp +++ b/code/nel/src/sound/driver/sound_driver.cpp @@ -14,6 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "stdsound_lowlevel.h" + #include "nel/sound/driver/sound_driver.h" #ifdef NL_OS_WINDOWS diff --git a/code/nel/src/sound/driver/sound_lowlevel.vcproj b/code/nel/src/sound/driver/sound_lowlevel.vcproj index 48c25fd38..cd23e6ad0 100644 --- a/code/nel/src/sound/driver/sound_lowlevel.vcproj +++ b/code/nel/src/sound/driver/sound_lowlevel.vcproj @@ -1,7 +1,7 @@ + + + + @@ -356,6 +376,14 @@ RelativePath="listener.cpp" > + + + + @@ -368,6 +396,46 @@ RelativePath="source.cpp" > + + + + + + + + + + + + + + + + diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index 31fc14445..ace98ff81 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -14,10 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "nel/sound/driver/source.h" -#include "nel/misc/common.h" +#include "stdsound_lowlevel.h" -#include +#include "nel/sound/driver/source.h" using namespace NLMISC; diff --git a/code/nel/src/sound/driver/stdsound_lowlevel.cpp b/code/nel/src/sound/driver/stdsound_lowlevel.cpp new file mode 100644 index 000000000..3f4661768 --- /dev/null +++ b/code/nel/src/sound/driver/stdsound_lowlevel.cpp @@ -0,0 +1,24 @@ +// NeL - MMORPG Framework +// 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 . + +#include "stdsound_lowlevel.h" + + +// leave not static else this workaround don't work +void dummyToAvoidStupidCompilerWarning_std_sound_lowlevel_cpp() +{ +} + diff --git a/code/nel/src/sound/driver/stdsound_lowlevel.h b/code/nel/src/sound/driver/stdsound_lowlevel.h new file mode 100644 index 000000000..a4cc08094 --- /dev/null +++ b/code/nel/src/sound/driver/stdsound_lowlevel.h @@ -0,0 +1,42 @@ +// NeL - MMORPG Framework +// 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 . + +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "nel/misc/debug.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include + +#include "nel/misc/vector.h" +#include "nel/misc/path.h" +#include "nel/misc/file.h" diff --git a/code/nel/src/sound/driver/xaudio2/driver_xaudio2.vcproj b/code/nel/src/sound/driver/xaudio2/driver_xaudio2.vcproj index c4a40f23c..3f5cb403e 100644 --- a/code/nel/src/sound/driver/xaudio2/driver_xaudio2.vcproj +++ b/code/nel/src/sound/driver/xaudio2/driver_xaudio2.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - - #include "nel/misc/vector.h" +#include "nel/misc/path.h" +#include "nel/misc/file.h"