diff options
author | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-09-15 22:01:18 +0400 |
---|---|---|
committer | Arystanbek Dyussenov <arystan.d@gmail.com> | 2009-09-15 22:01:18 +0400 |
commit | 816377cc02fe5dd4be945c0f3d415861114b4980 (patch) | |
tree | 306e9d1363aa66bc919e43b80b3380fab9f60ea9 /intern/audaspace | |
parent | c8af263e5d8d9d41a757e8438cdcf3b64d57e0c0 (diff) | |
parent | ee768ada680ce0a8aa184c882005c0ef1c0140fb (diff) |
Undo revision 23130 which was a merge with 2.5, a messy one because I did something wrong (`svn status` output: http://www.pasteall.org/7887).soc-2009-kazanbas
The command: svn merge -r 23130:23129 https://svn.blender.org/svnroot/bf-blender/branches/soc-2009-kazanbas
Diffstat (limited to 'intern/audaspace')
24 files changed, 129 insertions, 769 deletions
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 587ef30979b..940a4b2bedc 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -25,40 +25,34 @@ SET(INC . intern FX SRC ${PTHREADS_INC} ${LIBSAMPLERATE_INC}) FILE(GLOB SRC intern/*.cpp intern/*.h FX/*.cpp SRC/*.cpp) IF(WITH_FFMPEG) - SET(INC ${INC} ffmpeg ${FFMPEG_INC}) - FILE(GLOB FFMPEGSRC ffmpeg/*.cpp) - ADD_DEFINITIONS(-DWITH_FFMPEG) + SET(INC ${INC} ffmpeg ${FFMPEG_INC}) + FILE(GLOB FFMPEGSRC ffmpeg/*.cpp) + ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) IF(WITH_SDL) - SET(INC ${INC} SDL ${SDL_INCLUDE_DIR}) - FILE(GLOB SDLSRC SDL/*.cpp) - ADD_DEFINITIONS(-DWITH_SDL) + SET(INC ${INC} SDL ${SDL_INCLUDE_DIR}) + FILE(GLOB SDLSRC SDL/*.cpp) + ADD_DEFINITIONS(-DWITH_SDL) ENDIF(WITH_SDL) IF(WITH_OPENAL) - SET(INC ${INC} OpenAL ${OPENAL_INCLUDE_DIR}) - FILE(GLOB OPENALSRC OpenAL/*.cpp) - ADD_DEFINITIONS(-DWITH_OPENAL) - - STRING(REGEX MATCH ".*ramework.*" FRAMEWORK ${OPENAL_INCLUDE_DIR}) - IF(FRAMEWORK) - ADD_DEFINITIONS(-DAPPLE_FRAMEWORK_FIX) - ENDIF(FRAMEWORK) + SET(INC ${INC} OpenAL ${OPENAL_INCLUDE_DIR}) + FILE(GLOB OPENALSRC OpenAL/*.cpp) + ADD_DEFINITIONS(-DWITH_OPENAL) + + STRING(REGEX MATCH ".*ramework.*" FRAMEWORK ${OPENAL_INCLUDE_DIR}) + IF(FRAMEWORK) + ADD_DEFINITIONS(-DAPPLE_FRAMEWORK_FIX) + ENDIF(FRAMEWORK) ENDIF(WITH_OPENAL) IF(WITH_JACK) - SET(INC ${INC} jack ${JACK_INC}) - FILE(GLOB JACKSRC jack/*.cpp) - ADD_DEFINITIONS(-DWITH_JACK) + SET(INC ${INC} jack ${JACK_INC}) + FILE(GLOB JACKSRC jack/*.cpp) + ADD_DEFINITIONS(-DWITH_JACK) ENDIF(WITH_JACK) -IF(WITH_SNDFILE) - SET(INC ${INC} sndfile ${SNDFILE_INC}) - FILE(GLOB SNDFILESRC sndfile/*.cpp) - ADD_DEFINITIONS(-DWITH_SNDFILE) -ENDIF(WITH_SNDFILE) - -SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC}) +SET(SRC ${SRC} ${FFMPEGSRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC}) BLENDERLIB(bf_audaspace "${SRC}" "${INC}") diff --git a/intern/audaspace/FX/AUD_DoubleReader.cpp b/intern/audaspace/FX/AUD_DoubleReader.cpp index 8d3afbf2f1d..181e394da98 100644 --- a/intern/audaspace/FX/AUD_DoubleReader.cpp +++ b/intern/audaspace/FX/AUD_DoubleReader.cpp @@ -47,7 +47,7 @@ AUD_DoubleReader::AUD_DoubleReader(AUD_IReader* reader1, AUD_THROW(AUD_ERROR_READER); } - catch(AUD_Exception) + catch(AUD_Exception e) { if(reader1) { diff --git a/intern/audaspace/FX/AUD_PingPongFactory.cpp b/intern/audaspace/FX/AUD_PingPongFactory.cpp index 8b72afe05e7..a030d581b1a 100644 --- a/intern/audaspace/FX/AUD_PingPongFactory.cpp +++ b/intern/audaspace/FX/AUD_PingPongFactory.cpp @@ -46,7 +46,7 @@ AUD_IReader* AUD_PingPongFactory::createReader() { reader2 = factory.createReader(); } - catch(AUD_Exception) + catch(AUD_Exception e) { reader2 = 0; } diff --git a/intern/audaspace/Makefile b/intern/audaspace/Makefile index 474f53f0e0f..2d66dcf67fa 100644 --- a/intern/audaspace/Makefile +++ b/intern/audaspace/Makefile @@ -44,63 +44,19 @@ ifeq ($(WITH_FFMPEG),true) DIRS += ffmpeg endif -ifeq ($(WITH_OPENAL),true) - DIRS += OpenAL -endif - -ifeq ($(WITH_JACK),true) - DIRS += jack -endif - -ifeq ($(WITH_SNDFILE),true) - DIRS += sndfile -endif - include nan_subdirs.mk install: $(ALL_OR_DEBUG) @[ -d $(NAN_AUDASPACE) ] || mkdir $(NAN_AUDASPACE) @[ -d $(NAN_AUDASPACE)/include ] || mkdir $(NAN_AUDASPACE)/include @[ -d $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) ] || mkdir $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaudaspace.a $(DIR)/$(DEBUG_DIR)libaud_sdl.a $(DIR)/$(DEBUG_DIR)libaud_fx.a $(DIR)/$(DEBUG_DIR)libaud_src.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) - -ifeq ($(WITH_FFMPEG),true) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_ffmpeg.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) -endif - -ifeq ($(WITH_OPENAL),true) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_openal.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) -endif - -ifeq ($(WITH_JACK),true) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_jack.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) -endif - -ifeq ($(WITH_SNDFILE),true) - @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaud_sndfile.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) -endif + @../tools/cpifdiff.sh $(DIR)/$(DEBUG_DIR)libaudaspace.a $(DIR)/$(DEBUG_DIR)libaud_fx.a $(DIR)/$(DEBUG_DIR)libaud_src.a $(NAN_AUDASPACE)/lib/$(DEBUG_DIR) ifeq ($(OS),darwin) ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaudaspace.a ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_src.a ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_fx.a - ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sdl.a - -ifeq ($(WITH_FFMPEG),true) - ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_ffmpeg.a -endif - -ifeq ($(WITH_OPENAL),true) - ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_openal.a -endif - -ifeq ($(WITH_JACK),true) - ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_jack.a endif + @../tools/cpifdiff.sh intern/*.h $(NAN_AUDASPACE)/include/ -ifeq ($(WITH_SNDFILE),true) - ranlib $(NAN_AUDASPACE)/lib/$(DEBUG_DIR)libaud_sndfile.a -endif -endif - @../tools/cpifdiff.sh intern/*.h $(NAN_AUDASPACE)/include/ diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp index b33afa2b955..f94b11a11b8 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp @@ -544,13 +544,13 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep) if(alGetError() != AL_NO_ERROR) AUD_THROW(AUD_ERROR_OPENAL); } - catch(AUD_Exception) + catch(AUD_Exception e) { alDeleteSources(1, &sound->source); throw; } } - catch(AUD_Exception) + catch(AUD_Exception e) { delete sound; AUD_DELETE("handle") alcProcessContext(m_context); @@ -648,19 +648,19 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep) if(alGetError() != AL_NO_ERROR) AUD_THROW(AUD_ERROR_OPENAL); } - catch(AUD_Exception) + catch(AUD_Exception e) { alDeleteSources(1, &sound->source); throw; } } - catch(AUD_Exception) + catch(AUD_Exception e) { alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers); throw; } } - catch(AUD_Exception) + catch(AUD_Exception e) { delete sound; AUD_DELETE("handle") delete reader; AUD_DELETE("reader") @@ -1051,13 +1051,13 @@ bool AUD_OpenALDevice::setCapability(int capability, void *value) if(alGetError() != AL_NO_ERROR) AUD_THROW(AUD_ERROR_OPENAL); } - catch(AUD_Exception) + catch(AUD_Exception e) { alDeleteBuffers(1, &bf->buffer); throw; } } - catch(AUD_Exception) + catch(AUD_Exception e) { delete bf; AUD_DELETE("bufferedfactory") delete reader; AUD_DELETE("reader") diff --git a/intern/audaspace/SConscript b/intern/audaspace/SConscript index 025fa5a2379..caae070359a 100644 --- a/intern/audaspace/SConscript +++ b/intern/audaspace/SConscript @@ -26,9 +26,4 @@ if env['WITH_BF_JACK']: incs += ' jack ' + env['BF_JACK_INC'] defs.append('WITH_JACK') -if env['WITH_BF_SNDFILE']: - sources += env.Glob('sndfile/*.cpp') - incs += ' sndfile ' + env['BF_SNDFILE_INC'] - defs.append('WITH_SNDFILE') - -env.BlenderLib ('bf_audaspace', sources, Split(incs), defs, libtype=['intern','player'], priority = [25,215] ) +env.BlenderLib ('bf_audaspace', sources, Split(incs), defs, libtype=['intern'], priority = [25] ) diff --git a/intern/audaspace/SDL/AUD_SDLMixerReader.cpp b/intern/audaspace/SDL/AUD_SDLMixerReader.cpp index 0a47e36533a..ec61f99f02d 100644 --- a/intern/audaspace/SDL/AUD_SDLMixerReader.cpp +++ b/intern/audaspace/SDL/AUD_SDLMixerReader.cpp @@ -87,7 +87,7 @@ AUD_SDLMixerReader::AUD_SDLMixerReader(AUD_IReader* reader, specs.rate) == -1) AUD_THROW(AUD_ERROR_SDL); } - catch(AUD_Exception) + catch(AUD_Exception e) { delete m_reader; AUD_DELETE("reader") throw; diff --git a/intern/audaspace/SDL/Makefile b/intern/audaspace/SDL/Makefile index 02a4068f3dc..e36b2de41fe 100644 --- a/intern/audaspace/SDL/Makefile +++ b/intern/audaspace/SDL/Makefile @@ -29,7 +29,7 @@ # LIBNAME = aud_sdl -DIR = $(OCGDIR)/intern/audaspace +DIR = $(OCGDIR)/intern/$(LIBNAME) include nan_compile.mk diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp index f67c819ff10..5f9006b0ec0 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp @@ -25,24 +25,31 @@ #include "AUD_FFMPEGFactory.h" #include "AUD_FFMPEGReader.h" -#include "AUD_Buffer.h" +#include "AUD_Space.h" + +extern "C" { +#include <libavformat/avformat.h> +} AUD_FFMPEGFactory::AUD_FFMPEGFactory(const char* filename) { - if(filename != NULL) + if(filename != 0) { m_filename = new char[strlen(filename)+1]; AUD_NEW("string") strcpy(m_filename, filename); } else - m_filename = NULL; + m_filename = 0; + m_buffer = 0; + m_size = 0; } AUD_FFMPEGFactory::AUD_FFMPEGFactory(unsigned char* buffer, int size) { - m_filename = NULL; - m_buffer = AUD_Reference<AUD_Buffer>(new AUD_Buffer(size)); - memcpy(m_buffer.get()->getBuffer(), buffer, size); + m_filename = 0; + m_buffer = (unsigned char*)av_malloc(size); AUD_NEW("buffer") + m_size = size; + memcpy(m_buffer, buffer, size); } AUD_FFMPEGFactory::~AUD_FFMPEGFactory() @@ -51,15 +58,31 @@ AUD_FFMPEGFactory::~AUD_FFMPEGFactory() { delete[] m_filename; AUD_DELETE("string") } + if(m_buffer) + { + av_free(m_buffer); AUD_DELETE("buffer") + } } AUD_IReader* AUD_FFMPEGFactory::createReader() { - AUD_IReader* reader; - if(m_filename) - reader = new AUD_FFMPEGReader(m_filename); - else - reader = new AUD_FFMPEGReader(m_buffer); - AUD_NEW("reader") - return reader; + try + { + AUD_IReader* reader; + if(m_filename) + reader = new AUD_FFMPEGReader(m_filename); + else + reader = new AUD_FFMPEGReader(m_buffer, m_size); + AUD_NEW("reader") + return reader; + } + catch(AUD_Exception e) + { + // return 0 if ffmpeg cannot read the file + if(e.error == AUD_ERROR_FFMPEG) + return 0; + // but throw an exception if the file doesn't exist + else + throw; + } } diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h index 22560303a73..0a9fcc22c8b 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h @@ -27,8 +27,6 @@ #define AUD_FFMPEGFACTORY #include "AUD_IFactory.h" -#include "AUD_Reference.h" -class AUD_Buffer; /** * This factory reads a sound file via ffmpeg. @@ -46,7 +44,12 @@ private: /** * The buffer to read from. */ - AUD_Reference<AUD_Buffer> m_buffer; + unsigned char* m_buffer; + + /** + * The size of the buffer. + */ + int m_size; public: /** diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp index 0384ba5e0e6..b79375c2dc5 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp @@ -119,7 +119,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(const char* filename) // find audio stream and codec m_stream = -1; - for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++) + for(int i = 0; i < m_formatCtx->nb_streams; i++) if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) && (m_stream < 0)) { @@ -146,7 +146,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(const char* filename) m_specs.format = FFMPEG_TO_AUD(m_codecCtx->sample_fmt); m_specs.rate = (AUD_SampleRate) m_codecCtx->sample_rate; } - catch(AUD_Exception) + catch(AUD_Exception e) { av_close_input_file(m_formatCtx); throw; @@ -158,22 +158,21 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(const char* filename) AUD_NEW("buffer") } -AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) +AUD_FFMPEGReader::AUD_FFMPEGReader(unsigned char* buffer, int size) { m_position = 0; m_pkgbuf_left = 0; m_byteiocontext = (ByteIOContext*)av_mallocz(sizeof(ByteIOContext)); AUD_NEW("byteiocontext") - m_membuffer = buffer; - if(init_put_byte(m_byteiocontext, buffer.get()->getBuffer(), buffer.get()->getSize(), 0, + if(init_put_byte(m_byteiocontext, buffer, size, 0, NULL, NULL, NULL, NULL) != 0) AUD_THROW(AUD_ERROR_FILE); AVProbeData probe_data; probe_data.filename = ""; - probe_data.buf = buffer.get()->getBuffer(); - probe_data.buf_size = buffer.get()->getSize(); + probe_data.buf = buffer; + probe_data.buf_size = size; AVInputFormat* fmt = av_probe_input_format(&probe_data, 1); // open stream @@ -188,7 +187,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) // find audio stream and codec m_stream = -1; - for(unsigned int i = 0; i < m_formatCtx->nb_streams; i++) + for(int i = 0; i < m_formatCtx->nb_streams; i++) if((m_formatCtx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) && (m_stream < 0)) { @@ -215,7 +214,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) m_specs.format = FFMPEG_TO_AUD(m_codecCtx->sample_fmt); m_specs.rate = (AUD_SampleRate) m_codecCtx->sample_rate; } - catch(AUD_Exception) + catch(AUD_Exception e) { av_close_input_stream(m_formatCtx); av_free(m_byteiocontext); AUD_DELETE("byteiocontext") @@ -334,6 +333,7 @@ void AUD_FFMPEGReader::read(int & length, sample_t* & buffer) // read packages and decode them AVPacket packet; int data_size = 0; + int pkgbuf_size = m_pkgbuf->getSize(); int pkgbuf_pos; int left = length; int sample_size = AUD_SAMPLE_SIZE(m_specs); diff --git a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h index 6e303934f36..645f5f356f0 100644 --- a/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h +++ b/intern/audaspace/ffmpeg/AUD_FFMPEGReader.h @@ -27,9 +27,7 @@ #define AUD_FFMPEGREADER #include "AUD_IReader.h" -#include "AUD_Reference.h" class AUD_Buffer; - struct AVCodecContext; extern "C" { #include <libavformat/avformat.h> @@ -92,11 +90,6 @@ private: int m_stream; /** - * The memory file to read from, only saved to keep the buffer alive. - */ - AUD_Reference<AUD_Buffer> m_membuffer; - - /** * Decodes a packet into the given buffer. * \param packet The AVPacket to decode. * \param buffer The target buffer. @@ -116,10 +109,11 @@ public: /** * Creates a new reader. * \param buffer The buffer to read from. + * \param size The size of the buffer. * \exception AUD_Exception Thrown if the buffer specified cannot be read * with ffmpeg. */ - AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer); + AUD_FFMPEGReader(unsigned char* buffer, int size); /** * Destroys the reader and closes the file. diff --git a/intern/audaspace/ffmpeg/Makefile b/intern/audaspace/ffmpeg/Makefile index 492ac83f532..0bfe6494559 100644 --- a/intern/audaspace/ffmpeg/Makefile +++ b/intern/audaspace/ffmpeg/Makefile @@ -29,7 +29,7 @@ # LIBNAME = aud_ffmpeg -DIR = $(OCGDIR)/intern/audaspace +DIR = $(OCGDIR)/intern/$(LIBNAME) include nan_compile.mk diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index 7a624aa53fd..d2c8e94c949 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -25,7 +25,6 @@ #include "AUD_NULLDevice.h" #include "AUD_I3DDevice.h" -#include "AUD_FileFactory.h" #include "AUD_StreamBufferFactory.h" #include "AUD_DelayFactory.h" #include "AUD_LimiterFactory.h" @@ -49,6 +48,7 @@ #endif #ifdef WITH_FFMPEG +#include "AUD_FFMPEGFactory.h" extern "C" { #include <libavformat/avformat.h> } @@ -77,9 +77,6 @@ int AUD_init(AUD_DeviceType device, AUD_Specs specs, int buffersize) #endif AUD_IDevice* dev = NULL; - if(AUD_device) - AUD_exit(); - try { switch(device) @@ -110,13 +107,16 @@ int AUD_init(AUD_DeviceType device, AUD_Specs specs, int buffersize) return false; } + if(AUD_device) + AUD_exit(); + AUD_device = dev; if(AUD_device->checkCapability(AUD_CAPS_3D_DEVICE)) AUD_3ddevice = dynamic_cast<AUD_I3DDevice*>(AUD_device); return true; } - catch(AUD_Exception) + catch(AUD_Exception e) { return false; } @@ -187,13 +187,21 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound* sound) AUD_Sound* AUD_load(const char* filename) { assert(filename); - return new AUD_FileFactory(filename); +#ifdef WITH_FFMPEG + return new AUD_FFMPEGFactory(filename); +#else + return NULL; +#endif } AUD_Sound* AUD_loadBuffer(unsigned char* buffer, int size) { assert(buffer); - return new AUD_FileFactory(buffer, size); +#ifdef WITH_FFMPEG + return new AUD_FFMPEGFactory(buffer, size); +#else + return NULL; +#endif } AUD_Sound* AUD_bufferSound(AUD_Sound* sound) @@ -204,7 +212,7 @@ AUD_Sound* AUD_bufferSound(AUD_Sound* sound) { return new AUD_StreamBufferFactory(sound); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -218,7 +226,7 @@ AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay) { return new AUD_DelayFactory(sound, delay); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -232,7 +240,7 @@ extern AUD_Sound* AUD_limitSound(AUD_Sound* sound, float start, float end) { return new AUD_LimiterFactory(sound, start, end); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -246,7 +254,7 @@ AUD_Sound* AUD_pingpongSound(AUD_Sound* sound) { return new AUD_PingPongFactory(sound); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -260,7 +268,7 @@ AUD_Sound* AUD_loopSound(AUD_Sound* sound) { return new AUD_LoopFactory(sound); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -278,7 +286,7 @@ int AUD_stopLoop(AUD_Handle* handle) { return AUD_device->sendMessage(handle, message); } - catch(AUD_Exception) + catch(AUD_Exception e) { } } @@ -299,7 +307,7 @@ AUD_Handle* AUD_play(AUD_Sound* sound, int keep) { return AUD_device->play(sound, keep); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -360,7 +368,7 @@ AUD_Handle* AUD_play3D(AUD_Sound* sound, int keep) else return AUD_device->play(sound, keep); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -376,7 +384,7 @@ int AUD_updateListener(AUD_3DData* data) if(AUD_3ddevice) return AUD_3ddevice->updateListener(*data); } - catch(AUD_Exception) + catch(AUD_Exception e) { } return false; @@ -391,7 +399,7 @@ int AUD_set3DSetting(AUD_3DSetting setting, float value) if(AUD_3ddevice) return AUD_3ddevice->setSetting(setting, value); } - catch(AUD_Exception) + catch(AUD_Exception e) { } return false; @@ -406,7 +414,7 @@ float AUD_get3DSetting(AUD_3DSetting setting) if(AUD_3ddevice) return AUD_3ddevice->getSetting(setting); } - catch(AUD_Exception) + catch(AUD_Exception e) { } return 0.0; @@ -424,7 +432,7 @@ int AUD_update3DSource(AUD_Handle* handle, AUD_3DData* data) if(AUD_3ddevice) return AUD_3ddevice->updateSource(handle, *data); } - catch(AUD_Exception) + catch(AUD_Exception e) { } } @@ -443,7 +451,7 @@ int AUD_set3DSourceSetting(AUD_Handle* handle, if(AUD_3ddevice) return AUD_3ddevice->setSourceSetting(handle, setting, value); } - catch(AUD_Exception) + catch(AUD_Exception e) { } } @@ -461,7 +469,7 @@ float AUD_get3DSourceSetting(AUD_Handle* handle, AUD_3DSourceSetting setting) if(AUD_3ddevice) return AUD_3ddevice->getSourceSetting(handle, setting); } - catch(AUD_Exception) + catch(AUD_Exception e) { } } @@ -481,7 +489,7 @@ int AUD_setSoundVolume(AUD_Handle* handle, float volume) { return AUD_device->setCapability(AUD_CAPS_SOURCE_VOLUME, &caps); } - catch(AUD_Exception) {} + catch(AUD_Exception e) {} } return false; } @@ -499,7 +507,7 @@ int AUD_setSoundPitch(AUD_Handle* handle, float pitch) { return AUD_device->setCapability(AUD_CAPS_SOURCE_PITCH, &caps); } - catch(AUD_Exception) {} + catch(AUD_Exception e) {} } return false; } @@ -510,7 +518,7 @@ AUD_Device* AUD_openReadDevice(AUD_Specs specs) { return new AUD_ReadDevice(specs); } - catch(AUD_Exception) + catch(AUD_Exception e) { return NULL; } @@ -525,7 +533,7 @@ int AUD_playDevice(AUD_Device* device, AUD_Sound* sound) { return device->play(sound) != NULL; } - catch(AUD_Exception) + catch(AUD_Exception e) { return false; } @@ -540,7 +548,7 @@ int AUD_readDevice(AUD_Device* device, sample_t* buffer, int length) { return device->read(buffer, length); } - catch(AUD_Exception) + catch(AUD_Exception e) { return false; } @@ -554,7 +562,7 @@ void AUD_closeReadDevice(AUD_Device* device) { delete device; } - catch(AUD_Exception) + catch(AUD_Exception e) { } } diff --git a/intern/audaspace/intern/Makefile b/intern/audaspace/intern/Makefile index 4bdca04c1cb..2dcc7798f1c 100644 --- a/intern/audaspace/intern/Makefile +++ b/intern/audaspace/intern/Makefile @@ -35,32 +35,6 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) -ifeq ($(WITH_SDL),true) - CPPFLAGS += -DWITH_SDL - CPPFLAGS += $(NAN_SDLCFLAGS) -endif - -ifeq ($(WITH_OPENAL),true) - CPPFLAGS += -DWITH_OPENAL - CPPFLAGS += -I../OpenAL -endif - -ifeq ($(WITH_JACK),true) - CPPFLAGS += -DWITH_JACK - CPPFLAGS += $(NAN_JACKCFLAGS) - CPPFLAGS += -I../jack -endif - -ifeq ($(WITH_FFMPEG),true) - CPPFLAGS += -DWITH_FFMPEG - CPPFLAGS += $(NAN_FFMPEGCFLAGS) -endif - -ifeq ($(WITH_SNDFILE),true) - CPPFLAGS += -DWITH_SNDFILE - CPPFLAGS += -I../sndfile -endif - CPPFLAGS += -I$(LCGDIR)/samplerate/include/ CPPFLAGS += -I../ffmpeg CPPFLAGS += -I../FX diff --git a/intern/audaspace/jack/AUD_JackDevice.cpp b/intern/audaspace/jack/AUD_JackDevice.cpp index 4d8ab93d672..445e68e1a9a 100644 --- a/intern/audaspace/jack/AUD_JackDevice.cpp +++ b/intern/audaspace/jack/AUD_JackDevice.cpp @@ -35,7 +35,7 @@ int AUD_JackDevice::jack_mix(jack_nframes_t length, void *data) { AUD_JackDevice* device = (AUD_JackDevice*)data; - unsigned int samplesize = AUD_SAMPLE_SIZE(device->m_specs); + int samplesize = AUD_SAMPLE_SIZE(device->m_specs); if(device->m_buffer->getSize() < samplesize * length) device->m_buffer->resize(samplesize * length); device->mix(device->m_buffer->getBuffer(), length); @@ -44,10 +44,10 @@ int AUD_JackDevice::jack_mix(jack_nframes_t length, void *data) float* out; int count = device->m_specs.channels; - for(unsigned int i = 0; i < count; i++) + for(int i = 0; i < count; i++) { out = (float*)jack_port_get_buffer(device->m_ports[i], length); - for(unsigned int j = 0; j < length; j++) + for(int j = 0; j < length; j++) out[j] = in[j * count + i]; } @@ -105,7 +105,7 @@ AUD_JackDevice::AUD_JackDevice(AUD_Specs specs) if(jack_activate(m_client)) AUD_THROW(AUD_ERROR_JACK); } - catch(AUD_Exception) + catch(AUD_Exception e) { jack_client_close(m_client); delete[] m_ports; AUD_DELETE("jack_port") diff --git a/intern/audaspace/jack/AUD_JackDevice.h b/intern/audaspace/jack/AUD_JackDevice.h index f0c887a2f43..0b09e20b354 100644 --- a/intern/audaspace/jack/AUD_JackDevice.h +++ b/intern/audaspace/jack/AUD_JackDevice.h @@ -26,7 +26,6 @@ #ifndef AUD_JACKDEVICE #define AUD_JACKDEVICE - #include "AUD_SoftwareDevice.h" class AUD_Buffer; diff --git a/intern/audaspace/jack/Makefile b/intern/audaspace/jack/Makefile index 23cadf559c0..a6cc9119c6d 100644 --- a/intern/audaspace/jack/Makefile +++ b/intern/audaspace/jack/Makefile @@ -35,10 +35,6 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) -# If we are here, jack is enable. -CPPFLAGS += -DWITH_JACK -CPPFLAGS += $(NAN_JACKCFLAGS) - CPPFLAGS += -I../intern CPPFLAGS += -I.. CPPFLAGS += -I. diff --git a/intern/audaspace/make/msvc_9_0/audaspace.vcproj b/intern/audaspace/make/msvc_9_0/audaspace.vcproj index 0d8ade43e07..2bb97502c4e 100644 --- a/intern/audaspace/make/msvc_9_0/audaspace.vcproj +++ b/intern/audaspace/make/msvc_9_0/audaspace.vcproj @@ -43,7 +43,7 @@ <Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="2"
- AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include"
+ AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
StringPooling="true"
RuntimeLibrary="0"
@@ -117,7 +117,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include"
+ AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -192,7 +192,7 @@ <Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="2"
- AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include"
+ AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
StringPooling="true"
RuntimeLibrary="2"
@@ -266,7 +266,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include"
+ AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include"
PreprocessorDefinitions="WIN32,_DEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -381,14 +381,6 @@ >
</File>
<File
- RelativePath="..\..\intern\AUD_FileFactory.cpp"
- >
- </File>
- <File
- RelativePath="..\..\intern\AUD_FileFactory.h"
- >
- </File>
- <File
RelativePath="..\..\intern\AUD_FloatMixer.cpp"
>
</File>
@@ -725,38 +717,6 @@ >
</File>
</Filter>
- <Filter
- Name="jack"
- >
- <File
- RelativePath="..\..\jack\AUD_JackDevice.cpp"
- >
- </File>
- <File
- RelativePath="..\..\jack\AUD_JackDevice.h"
- >
- </File>
- </Filter>
- <Filter
- Name="sndfile"
- >
- <File
- RelativePath="..\..\sndfile\AUD_SndFileFactory.cpp"
- >
- </File>
- <File
- RelativePath="..\..\sndfile\AUD_SndFileFactory.h"
- >
- </File>
- <File
- RelativePath="..\..\sndfile\AUD_SndFileReader.cpp"
- >
- </File>
- <File
- RelativePath="..\..\sndfile\AUD_SndFileReader.h"
- >
- </File>
- </Filter>
<File
RelativePath="..\..\AUD_C-API.h"
>
diff --git a/intern/audaspace/sndfile/AUD_SndFileFactory.cpp b/intern/audaspace/sndfile/AUD_SndFileFactory.cpp deleted file mode 100644 index bac6dc321f4..00000000000 --- a/intern/audaspace/sndfile/AUD_SndFileFactory.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN LGPL LICENSE BLOCK ***** - * - * Copyright 2009 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * AudaSpace is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>. - * - * ***** END LGPL LICENSE BLOCK ***** - */ - -#include "AUD_SndFileFactory.h" -#include "AUD_SndFileReader.h" -#include "AUD_Buffer.h" - -#include <cstring> - -AUD_SndFileFactory::AUD_SndFileFactory(const char* filename) -{ - if(filename != NULL) - { - m_filename = new char[strlen(filename)+1]; AUD_NEW("string") - strcpy(m_filename, filename); - } - else - m_filename = NULL; -} - -AUD_SndFileFactory::AUD_SndFileFactory(unsigned char* buffer, int size) -{ - m_filename = NULL; - m_buffer = AUD_Reference<AUD_Buffer>(new AUD_Buffer(size)); - memcpy(m_buffer.get()->getBuffer(), buffer, size); -} - -AUD_SndFileFactory::~AUD_SndFileFactory() -{ - if(m_filename) - { - delete[] m_filename; AUD_DELETE("string") - } -} - -AUD_IReader* AUD_SndFileFactory::createReader() -{ - AUD_IReader* reader; - if(m_filename) - reader = new AUD_SndFileReader(m_filename); - else - reader = new AUD_SndFileReader(m_buffer); - AUD_NEW("reader") - return reader; -} diff --git a/intern/audaspace/sndfile/AUD_SndFileFactory.h b/intern/audaspace/sndfile/AUD_SndFileFactory.h deleted file mode 100644 index 98187ff1590..00000000000 --- a/intern/audaspace/sndfile/AUD_SndFileFactory.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN LGPL LICENSE BLOCK ***** - * - * Copyright 2009 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * AudaSpace is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>. - * - * ***** END LGPL LICENSE BLOCK ***** - */ - -#ifndef AUD_SNDFILEFACTORY -#define AUD_SNDFILEFACTORY - -#include "AUD_IFactory.h" -#include "AUD_Reference.h" -class AUD_Buffer; - -/** - * This factory reads a sound file via libsndfile. - */ -class AUD_SndFileFactory : public AUD_IFactory -{ -private: - /** - * The filename of the sound source file. - */ - char* m_filename; - - /** - * The buffer to read from. - */ - AUD_Reference<AUD_Buffer> m_buffer; - -public: - /** - * Creates a new factory. - * \param filename The sound file path. - */ - AUD_SndFileFactory(const char* filename); - - /** - * Creates a new factory. - * \param buffer The buffer to read from. - * \param size The size of the buffer. - */ - AUD_SndFileFactory(unsigned char* buffer, int size); - - /** - * Destroys the factory. - */ - ~AUD_SndFileFactory(); - - virtual AUD_IReader* createReader(); -}; - -#endif //AUD_SNDFILEFACTORY diff --git a/intern/audaspace/sndfile/AUD_SndFileReader.cpp b/intern/audaspace/sndfile/AUD_SndFileReader.cpp deleted file mode 100644 index 485818552bb..00000000000 --- a/intern/audaspace/sndfile/AUD_SndFileReader.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN LGPL LICENSE BLOCK ***** - * - * Copyright 2009 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * AudaSpace is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>. - * - * ***** END LGPL LICENSE BLOCK ***** - */ - -#include "AUD_SndFileReader.h" -#include "AUD_Buffer.h" - -#include <cstring> - -// This function transforms a SampleFormat to our own sample format -static inline AUD_SampleFormat SNDFILE_TO_AUD(int fmt) -{ - switch(fmt & SF_FORMAT_SUBMASK) - { - // only read s16, s32 and double as they are - case SF_FORMAT_PCM_16: - return AUD_FORMAT_S16; - case SF_FORMAT_PCM_32: - return AUD_FORMAT_S32; - case SF_FORMAT_DOUBLE: - return AUD_FORMAT_FLOAT64; - // read all other formats as floats - default: - return AUD_FORMAT_FLOAT32; - } -} - -sf_count_t AUD_SndFileReader::vio_get_filelen(void *user_data) -{ - AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data; - return reader->m_membuffer.get()->getSize(); -} - -sf_count_t AUD_SndFileReader::vio_seek(sf_count_t offset, int whence, void *user_data) -{ - AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data; - - switch(whence) - { - case SEEK_SET: - reader->m_memoffset = offset; - break; - case SEEK_CUR: - reader->m_memoffset = reader->m_memoffset + offset; - break; - case SEEK_END: - reader->m_memoffset = reader->m_membuffer.get()->getSize() + offset; - break; - } - - return reader->m_memoffset; -} - -sf_count_t AUD_SndFileReader::vio_read(void *ptr, sf_count_t count, void *user_data) -{ - AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data; - - if(reader->m_memoffset + count > reader->m_membuffer.get()->getSize()) - count = reader->m_membuffer.get()->getSize() - reader->m_memoffset; - - memcpy(ptr, reader->m_membuffer.get()->getBuffer() + reader->m_memoffset, count); - reader->m_memoffset += count; - - return count; -} - -sf_count_t AUD_SndFileReader::vio_tell(void *user_data) -{ - AUD_SndFileReader* reader = (AUD_SndFileReader*)user_data; - - return reader->m_memoffset; -} - -AUD_SndFileReader::AUD_SndFileReader(const char* filename) -{ - SF_INFO sfinfo; - - sfinfo.format = 0; - m_sndfile = sf_open(filename, SFM_READ, &sfinfo); - - if(!m_sndfile) - AUD_THROW(AUD_ERROR_FILE); - - m_specs.channels = (AUD_Channels) sfinfo.channels; - m_specs.format = SNDFILE_TO_AUD(sfinfo.format); - m_specs.rate = (AUD_SampleRate) sfinfo.samplerate; - m_length = sfinfo.frames; - m_seekable = sfinfo.seekable; - m_position = 0; - - switch(m_specs.format) - { - case AUD_FORMAT_S16: - m_read = (sf_read_f) sf_readf_short; - break; - case AUD_FORMAT_S32: - m_read = (sf_read_f) sf_readf_int; - break; - case AUD_FORMAT_FLOAT64: - m_read = (sf_read_f) sf_readf_double; - break; - default: - m_read = (sf_read_f) sf_readf_float; - } - - m_buffer = new AUD_Buffer(); AUD_NEW("buffer") -} - -AUD_SndFileReader::AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer) -{ - m_membuffer = buffer; - m_memoffset = 0; - - m_vio.get_filelen = vio_get_filelen; - m_vio.read = vio_read; - m_vio.seek = vio_seek; - m_vio.tell = vio_tell; - m_vio.write = NULL; - - SF_INFO sfinfo; - - sfinfo.format = 0; - m_sndfile = sf_open_virtual(&m_vio, SFM_READ, &sfinfo, this); - - if(!m_sndfile) - AUD_THROW(AUD_ERROR_FILE); - - m_specs.channels = (AUD_Channels) sfinfo.channels; - m_specs.format = SNDFILE_TO_AUD(sfinfo.format); - m_specs.rate = (AUD_SampleRate) sfinfo.samplerate; - m_length = sfinfo.frames; - m_seekable = sfinfo.seekable; - m_position = 0; - - switch(m_specs.format) - { - case AUD_FORMAT_S16: - m_read = (sf_read_f) sf_readf_short; - break; - case AUD_FORMAT_S32: - m_read = (sf_read_f) sf_readf_int; - break; - case AUD_FORMAT_FLOAT64: - m_read = (sf_read_f) sf_readf_double; - break; - default: - m_read = (sf_read_f) sf_readf_float; - } - - m_buffer = new AUD_Buffer(); AUD_NEW("buffer") -} - -AUD_SndFileReader::~AUD_SndFileReader() -{ - sf_close(m_sndfile); - - delete m_buffer; AUD_DELETE("buffer") -} - -bool AUD_SndFileReader::isSeekable() -{ - return m_seekable; -} - -void AUD_SndFileReader::seek(int position) -{ - if(m_seekable) - { - position = sf_seek(m_sndfile, position, SEEK_SET); - m_position = position; - } -} - -int AUD_SndFileReader::getLength() -{ - return m_length; -} - -int AUD_SndFileReader::getPosition() -{ - return m_position; -} - -AUD_Specs AUD_SndFileReader::getSpecs() -{ - return m_specs; -} - -AUD_ReaderType AUD_SndFileReader::getType() -{ - return AUD_TYPE_STREAM; -} - -bool AUD_SndFileReader::notify(AUD_Message &message) -{ - return false; -} - -void AUD_SndFileReader::read(int & length, sample_t* & buffer) -{ - int sample_size = AUD_SAMPLE_SIZE(m_specs); - - // resize output buffer if necessary - if(m_buffer->getSize() < length*sample_size) - m_buffer->resize(length*sample_size); - - buffer = m_buffer->getBuffer(); - - length = m_read(m_sndfile, buffer, length); - - m_position += length; -} diff --git a/intern/audaspace/sndfile/AUD_SndFileReader.h b/intern/audaspace/sndfile/AUD_SndFileReader.h deleted file mode 100644 index da890ef53ca..00000000000 --- a/intern/audaspace/sndfile/AUD_SndFileReader.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN LGPL LICENSE BLOCK ***** - * - * Copyright 2009 Jörg Hermann Müller - * - * This file is part of AudaSpace. - * - * AudaSpace is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * AudaSpace 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with AudaSpace. If not, see <http://www.gnu.org/licenses/>. - * - * ***** END LGPL LICENSE BLOCK ***** - */ - -#ifndef AUD_SNDFILEREADER -#define AUD_SNDFILEREADER - -#include "AUD_IReader.h" -#include "AUD_Reference.h" -class AUD_Buffer; - -#include <sndfile.h> - -typedef sf_count_t (*sf_read_f)(SNDFILE *sndfile, void *ptr, sf_count_t frames); - -/** - * This class reads a sound file via libsndfile. - */ -class AUD_SndFileReader : public AUD_IReader -{ -private: - /** - * The current position in samples. - */ - int m_position; - - /** - * The sample count in the file. - */ - int m_length; - - /** - * Whether the file is seekable. - */ - bool m_seekable; - - /** - * The specification of the audio data. - */ - AUD_Specs m_specs; - - /** - * The playback buffer. - */ - AUD_Buffer* m_buffer; - - /** - * The sndfile. - */ - SNDFILE* m_sndfile; - - /** - * The reading function. - */ - sf_read_f m_read; - - /** - * The virtual IO structure for memory file reading. - */ - SF_VIRTUAL_IO m_vio; - - /** - * The pointer to the memory file. - */ - AUD_Reference<AUD_Buffer> m_membuffer; - - /** - * The current reading pointer of the memory file. - */ - int m_memoffset; - - // Functions for libsndfile virtual IO functionality - static sf_count_t vio_get_filelen(void *user_data); - static sf_count_t vio_seek(sf_count_t offset, int whence, void *user_data); - static sf_count_t vio_read(void *ptr, sf_count_t count, void *user_data); - static sf_count_t vio_tell(void *user_data); - -public: - /** - * Creates a new reader. - * \param filename The path to the file to be read. - * \exception AUD_Exception Thrown if the file specified does not exist or - * cannot be read with libsndfile. - */ - AUD_SndFileReader(const char* filename); - - /** - * Creates a new reader. - * \param buffer The buffer to read from. - * \exception AUD_Exception Thrown if the buffer specified cannot be read - * with libsndfile. - */ - AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer); - - /** - * Destroys the reader and closes the file. - */ - virtual ~AUD_SndFileReader(); - - virtual bool isSeekable(); - virtual void seek(int position); - virtual int getLength(); - virtual int getPosition(); - virtual AUD_Specs getSpecs(); - virtual AUD_ReaderType getType(); - virtual bool notify(AUD_Message &message); - virtual void read(int & length, sample_t* & buffer); -}; - -#endif //AUD_SNDFILEREADER diff --git a/intern/audaspace/sndfile/Makefile b/intern/audaspace/sndfile/Makefile deleted file mode 100644 index 1cf0b2683fb..00000000000 --- a/intern/audaspace/sndfile/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): -# -# ***** END GPL LICENSE BLOCK ***** -# -# - -LIBNAME = aud_sndfile -DIR = $(OCGDIR)/intern/audaspace - -include nan_compile.mk - -CCFLAGS += $(LEVEL_1_CPP_WARNINGS) - -CPPFLAGS += -I../intern -CPPFLAGS += -I.. -CPPFLAGS += -I. |