From 6c5c58e05799f2b593cd81fcff57e6ef72ad57fb Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 9 Aug 2009 21:16:39 +0000 Subject: 2.5: Sound branch merge! See mailing list for additional information. --- intern/audaspace/SDL/AUD_SDLDevice.cpp | 97 ++++++++++++ intern/audaspace/SDL/AUD_SDLDevice.h | 63 ++++++++ intern/audaspace/SDL/AUD_SDLMixer.cpp | 83 +++++++++++ intern/audaspace/SDL/AUD_SDLMixer.h | 76 ++++++++++ intern/audaspace/SDL/AUD_SDLMixerFactory.cpp | 63 ++++++++ intern/audaspace/SDL/AUD_SDLMixerFactory.h | 45 ++++++ intern/audaspace/SDL/AUD_SDLMixerReader.cpp | 214 +++++++++++++++++++++++++++ intern/audaspace/SDL/AUD_SDLMixerReader.h | 128 ++++++++++++++++ intern/audaspace/SDL/Makefile | 41 +++++ 9 files changed, 810 insertions(+) create mode 100644 intern/audaspace/SDL/AUD_SDLDevice.cpp create mode 100644 intern/audaspace/SDL/AUD_SDLDevice.h create mode 100644 intern/audaspace/SDL/AUD_SDLMixer.cpp create mode 100644 intern/audaspace/SDL/AUD_SDLMixer.h create mode 100644 intern/audaspace/SDL/AUD_SDLMixerFactory.cpp create mode 100644 intern/audaspace/SDL/AUD_SDLMixerFactory.h create mode 100644 intern/audaspace/SDL/AUD_SDLMixerReader.cpp create mode 100644 intern/audaspace/SDL/AUD_SDLMixerReader.h create mode 100644 intern/audaspace/SDL/Makefile (limited to 'intern/audaspace/SDL') diff --git a/intern/audaspace/SDL/AUD_SDLDevice.cpp b/intern/audaspace/SDL/AUD_SDLDevice.cpp new file mode 100644 index 00000000000..9ea5f1a74ee --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLDevice.cpp @@ -0,0 +1,97 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixer.h" +#include "AUD_SDLDevice.h" +#include "AUD_IReader.h" + +#include + +// this is the callback function for SDL, it only calls the class +void mixAudio(void *data, Uint8* buffer, int length) +{ + AUD_SDLDevice* device = (AUD_SDLDevice*)data; + device->SDLmix((sample_t *)buffer, length); +} + +AUD_SDLDevice::AUD_SDLDevice(AUD_Specs specs, int buffersize) +{ + if(specs.channels == AUD_CHANNELS_INVALID) + specs.channels = AUD_CHANNELS_STEREO; + if(specs.format == AUD_FORMAT_INVALID) + specs.format = AUD_FORMAT_S16; + if(specs.rate == AUD_RATE_INVALID) + specs.rate = AUD_RATE_44100; + + m_specs = specs; + + SDL_AudioSpec format, obtained; + + format.freq = m_specs.rate; + if(m_specs.format == AUD_FORMAT_U8) + format.format = AUDIO_U8; + else + format.format = AUDIO_S16SYS; + format.channels = m_specs.channels; + format.samples = buffersize; + format.callback = &mixAudio; + format.userdata = this; + + if(SDL_OpenAudio(&format, &obtained) != 0) + AUD_THROW(AUD_ERROR_SDL); + + m_specs.rate = (AUD_SampleRate)obtained.freq; + m_specs.channels = (AUD_Channels)obtained.channels; + if(obtained.format == AUDIO_U8) + m_specs.format = AUD_FORMAT_U8; + else if(obtained.format == AUDIO_S16LSB || obtained.format == AUDIO_S16MSB) + m_specs.format = AUD_FORMAT_S16; + else + AUD_THROW(AUD_ERROR_SDL); + + m_mixer = new AUD_SDLMixer(); AUD_NEW("mixer") + m_mixer->setSpecs(m_specs); + + create(); +} + +AUD_SDLDevice::~AUD_SDLDevice() +{ + lock(); + SDL_CloseAudio(); + unlock(); + + destroy(); +} + +void AUD_SDLDevice::SDLmix(sample_t* buffer, int length) +{ + mix(buffer, length/AUD_SAMPLE_SIZE(m_specs)); +} + +void AUD_SDLDevice::playing(bool playing) +{ + SDL_PauseAudio(playing ? 0 : 1); +} diff --git a/intern/audaspace/SDL/AUD_SDLDevice.h b/intern/audaspace/SDL/AUD_SDLDevice.h new file mode 100644 index 00000000000..3eb93d28762 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLDevice.h @@ -0,0 +1,63 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLDEVICE +#define AUD_SDLDEVICE + +#include "AUD_SoftwareDevice.h" + +/** + * This device plays back through SDL, the simple direct media layer. + */ +class AUD_SDLDevice : public AUD_SoftwareDevice +{ +protected: + virtual void playing(bool playing); + +public: + /** + * Opens the SDL audio device for playback. + * \param specs The wanted audio specification. + * \param buffersize The size of the internal buffer. + * \note The specification really used for opening the device may differ. + * \exception AUD_Exception Thrown if the audio device cannot be opened. + */ + AUD_SDLDevice(AUD_Specs specs, int buffersize = AUD_DEFAULT_BUFFER_SIZE); + + /** + * Closes the SDL audio device. + */ + virtual ~AUD_SDLDevice(); + + /** + * Mixes the next bytes into the buffer. + * \param buffer The target buffer. + * \param length The length in bytes to be filled. + * \warning This function shall not be called from outside! + */ + void SDLmix(sample_t* buffer, int length); +}; + +#endif //AUD_SDLDEVICE diff --git a/intern/audaspace/SDL/AUD_SDLMixer.cpp b/intern/audaspace/SDL/AUD_SDLMixer.cpp new file mode 100644 index 00000000000..cacc0c7063c --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixer.cpp @@ -0,0 +1,83 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixer.h" +#include "AUD_SDLMixerFactory.h" + +#include + +AUD_SDLMixer::AUD_SDLMixer() +{ + m_factory = NULL; +} + +AUD_SDLMixer::~AUD_SDLMixer() +{ + if(m_factory) + { + delete m_factory; AUD_DELETE("factory") + } +} + +AUD_IReader* AUD_SDLMixer::prepare(AUD_IReader* reader) +{ + m_factory->setReader(reader); + return m_factory->createReader(); +} + +void AUD_SDLMixer::setSpecs(AUD_Specs specs) +{ + m_samplesize = AUD_SAMPLE_SIZE(specs); + if(m_factory) + { + delete m_factory; AUD_DELETE("factory") + } + m_factory = new AUD_SDLMixerFactory(specs); AUD_NEW("factory") +} + +void AUD_SDLMixer::add(sample_t* buffer, AUD_Specs specs, int length, + float volume) +{ + AUD_SDLMixerBuffer buf; + buf.buffer = buffer; + buf.length = length; + buf.volume = volume; + m_buffers.push_back(buf); +} + +void AUD_SDLMixer::superpose(sample_t* buffer, int length, float volume) +{ + AUD_SDLMixerBuffer buf; + + while(!m_buffers.empty()) + { + buf = m_buffers.front(); + m_buffers.pop_front(); + SDL_MixAudio((Uint8*)buffer, + (Uint8*)buf.buffer, + buf.length * m_samplesize, + (int)(SDL_MIX_MAXVOLUME * volume * buf.volume)); + } +} diff --git a/intern/audaspace/SDL/AUD_SDLMixer.h b/intern/audaspace/SDL/AUD_SDLMixer.h new file mode 100644 index 00000000000..2cc4e51f66d --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixer.h @@ -0,0 +1,76 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLMIXER +#define AUD_SDLMIXER + +#include "AUD_IMixer.h" +class AUD_SDLMixerFactory; +#include + +struct AUD_SDLMixerBuffer +{ + sample_t* buffer; + int length; + float volume; +}; + +/** + * This class is able to mix audiosignals with the help of SDL. + */ +class AUD_SDLMixer : public AUD_IMixer +{ +private: + /** + * The mixer factory that prepares all readers for superposition. + */ + AUD_SDLMixerFactory* m_factory; + + /** + * The list of buffers to superpose. + */ + std::list m_buffers; + + /** + * The size of an output sample. + */ + int m_samplesize; + +public: + /** + * Creates the mixer. + */ + AUD_SDLMixer(); + + virtual ~AUD_SDLMixer(); + + virtual AUD_IReader* prepare(AUD_IReader* reader); + virtual void setSpecs(AUD_Specs specs); + virtual void add(sample_t* buffer, AUD_Specs specs, int length, + float volume); + virtual void superpose(sample_t* buffer, int length, float volume); +}; + +#endif //AUD_SDLMIXER diff --git a/intern/audaspace/SDL/AUD_SDLMixerFactory.cpp b/intern/audaspace/SDL/AUD_SDLMixerFactory.cpp new file mode 100644 index 00000000000..1633a1498fa --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerFactory.cpp @@ -0,0 +1,63 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixerFactory.h" +#include "AUD_SDLMixerReader.h" + +AUD_SDLMixerFactory::AUD_SDLMixerFactory(AUD_IReader* reader, AUD_Specs specs) : + AUD_MixerFactory(reader, specs) {} + +AUD_SDLMixerFactory::AUD_SDLMixerFactory(AUD_IFactory* factory, AUD_Specs specs) : + AUD_MixerFactory(factory, specs) {} + +AUD_SDLMixerFactory::AUD_SDLMixerFactory(AUD_Specs specs) : + AUD_MixerFactory(specs) {} + +AUD_IReader* AUD_SDLMixerFactory::createReader() +{ + AUD_IReader* reader = getReader(); + + if(reader != 0) + { + AUD_Specs specs = reader->getSpecs(); + if(memcmp(&m_specs, &specs, sizeof(AUD_Specs)) != 0) + { + try + { + reader = new AUD_SDLMixerReader(reader, m_specs); + AUD_NEW("reader") + } + catch(AUD_Exception e) + { + // return 0 in case SDL cannot mix the source + if(e.error != AUD_ERROR_SDL) + throw; + else + reader = NULL; + } + } + } + return reader; +} diff --git a/intern/audaspace/SDL/AUD_SDLMixerFactory.h b/intern/audaspace/SDL/AUD_SDLMixerFactory.h new file mode 100644 index 00000000000..44b36d06859 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerFactory.h @@ -0,0 +1,45 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLMIXERFACTORY +#define AUD_SDLMIXERFACTORY + +#include "AUD_MixerFactory.h" + +/** + * This factory creates a resampling reader that uses SDL's resampling + * functionality which unfortunately is very very very limited. + */ +class AUD_SDLMixerFactory : public AUD_MixerFactory +{ +public: + AUD_SDLMixerFactory(AUD_IReader* reader, AUD_Specs specs); + AUD_SDLMixerFactory(AUD_IFactory* factory, AUD_Specs specs); + AUD_SDLMixerFactory(AUD_Specs specs); + + virtual AUD_IReader* createReader(); +}; + +#endif //AUD_SDLMIXERFACTORY diff --git a/intern/audaspace/SDL/AUD_SDLMixerReader.cpp b/intern/audaspace/SDL/AUD_SDLMixerReader.cpp new file mode 100644 index 00000000000..1a0d990eaf2 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerReader.cpp @@ -0,0 +1,214 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#include "AUD_SDLMixerReader.h" +#include "AUD_Buffer.h" + +inline Uint16 AUD_TO_SDL(AUD_SampleFormat format) +{ + // SDL only supports 8 and 16 bit audio + switch(format) + { + case AUD_FORMAT_U8: + return AUDIO_U8; + case AUD_FORMAT_S16: + return AUDIO_S16SYS; + default: + AUD_THROW(AUD_ERROR_SDL); + } +} + +// greatest common divisor +inline int gcd(int a, int b) +{ + int c; + + // make sure a is the bigger + if(b > a) + { + c = b; + b = a; + a = c; + } + + // greetings from Euclides + while(b != 0) + { + c = a % b; + a = b; + b = c; + } + return a; +} + +AUD_SDLMixerReader::AUD_SDLMixerReader(AUD_IReader* reader, + AUD_Specs specs) +{ + if(reader == NULL) + AUD_THROW(AUD_ERROR_READER); + + m_reader = reader; + m_tspecs = specs; + m_sspecs = reader->getSpecs(); + + try + { + // SDL only supports 8 and 16 bit sample formats + if(SDL_BuildAudioCVT(&m_cvt, + AUD_TO_SDL(m_sspecs.format), + m_sspecs.channels, + m_sspecs.rate, + AUD_TO_SDL(specs.format), + specs.channels, + specs.rate) == -1) + AUD_THROW(AUD_ERROR_SDL); + } + catch(AUD_Exception e) + { + delete m_reader; AUD_DELETE("reader") + throw; + } + + m_eor = false; + m_rsposition = 0; + m_rssize = 0; + m_ssize = m_sspecs.rate / gcd(specs.rate, m_sspecs.rate); + m_tsize = m_tspecs.rate * m_ssize / m_sspecs.rate; + + m_buffer = new AUD_Buffer(); AUD_NEW("buffer") + m_rsbuffer = new AUD_Buffer(); AUD_NEW("buffer") +} + +AUD_SDLMixerReader::~AUD_SDLMixerReader() +{ + delete m_reader; AUD_DELETE("reader") + delete m_buffer; AUD_DELETE("buffer") + delete m_rsbuffer; AUD_DELETE("buffer") +} + +bool AUD_SDLMixerReader::isSeekable() +{ + return m_reader->isSeekable(); +} + +void AUD_SDLMixerReader::seek(int position) +{ + m_reader->seek(position * m_ssize / m_tsize); + m_eor = false; +} + +int AUD_SDLMixerReader::getLength() +{ + return m_reader->getLength() * m_tsize / m_ssize; +} + +int AUD_SDLMixerReader::getPosition() +{ + return m_reader->getPosition() * m_tsize / m_ssize; +} + +AUD_Specs AUD_SDLMixerReader::getSpecs() +{ + return m_tspecs; +} + +AUD_ReaderType AUD_SDLMixerReader::getType() +{ + return m_reader->getType(); +} + +bool AUD_SDLMixerReader::notify(AUD_Message &message) +{ + return m_reader->notify(message); +} + +void AUD_SDLMixerReader::read(int & length, sample_t* & buffer) +{ + // sample count for the target buffer without getting a shift + int tns = length + m_tsize - length % m_tsize; + // sample count for the source buffer without getting a shift + int sns = tns * m_ssize / m_tsize; + // target sample size + int tss = AUD_SAMPLE_SIZE(m_tspecs); + // source sample size + int sss = AUD_SAMPLE_SIZE(m_sspecs); + + // input is output buffer + int buf_size = AUD_MAX(tns*tss, sns*sss); + + // resize if necessary + if(m_rsbuffer->getSize() < buf_size) + m_rsbuffer->resize(buf_size, true); + + if(m_buffer->getSize() < length*tss) + m_buffer->resize(length*tss); + + buffer = m_buffer->getBuffer(); + int size; + int index = 0; + sample_t* buf; + + while(index < length) + { + if(m_rsposition == m_rssize) + { + // no more data + if(m_eor) + length = index; + // mix + else + { + // read from source + size = sns; + m_reader->read(size, buf); + + // prepare + m_cvt.buf = m_rsbuffer->getBuffer(); + m_cvt.len = size*sss; + memcpy(m_cvt.buf, buf, size*sss); + + // convert + SDL_ConvertAudio(&m_cvt); + + // end of reader + if(size < sns) + m_eor = true; + + m_rsposition = 0; + m_rssize = size * m_tsize / m_ssize; + } + } + + // size to copy + size = AUD_MIN(m_rssize-m_rsposition, length-index); + + // copy + memcpy(m_buffer->getBuffer() + index * tss, + m_rsbuffer->getBuffer() + m_rsposition * tss, + size*tss); + m_rsposition += size; + index += size; + } +} diff --git a/intern/audaspace/SDL/AUD_SDLMixerReader.h b/intern/audaspace/SDL/AUD_SDLMixerReader.h new file mode 100644 index 00000000000..56668d02171 --- /dev/null +++ b/intern/audaspace/SDL/AUD_SDLMixerReader.h @@ -0,0 +1,128 @@ +/* + * $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 . + * + * ***** END LGPL LICENSE BLOCK ***** + */ + +#ifndef AUD_SDLMIXERREADER +#define AUD_SDLMIXERREADER + +#include "AUD_IReader.h" +class AUD_Buffer; + +#include + +/** + * This class mixes a sound source with help of the SDL library. + * Unfortunately SDL is only capable of 8 and 16 bit audio, mono and stereo, as + * well as resampling only 2^n sample rate relationships where n is a natural + * number. + * \warning Although SDL can only resample 2^n sample rate relationships, this + * class doesn't check for compliance, so in case of other factors, + * the behaviour is undefined. + */ +class AUD_SDLMixerReader : public AUD_IReader +{ +private: + /** + * The reader that is being mixed. + */ + AUD_IReader* m_reader; + + /** + * The current reading position in the resampling buffer. + */ + int m_rsposition; + + /** + * The count of mixed samples in the resampling buffer. + */ + int m_rssize; + + /** + * The smallest count of source samples to get a fractionless resampling + * factor. + */ + int m_ssize; + + /** + * The smallest count of target samples to get a fractionless resampling + * factor. + */ + int m_tsize; + + /** + * The sound output buffer. + */ + AUD_Buffer *m_buffer; + + /** + * The resampling buffer. + */ + AUD_Buffer *m_rsbuffer; + + /** + * The target specification. + */ + AUD_Specs m_tspecs; + + /** + * The sample specification of the source. + */ + AUD_Specs m_sspecs; + + /** + * Saves whether the end of the source has been reached. + */ + bool m_eor; + + /** + * The SDL_AudioCVT structure used for resampling. + */ + SDL_AudioCVT m_cvt; + +public: + /** + * Creates a resampling reader. + * \param reader The reader to mix. + * \param specs The target specification. + * \exception AUD_Exception Thrown if the source specification cannot be + * mixed to the target specification or if the reader is + * NULL. + */ + AUD_SDLMixerReader(AUD_IReader* reader, AUD_Specs specs); + /** + * Destroys the reader. + */ + ~AUD_SDLMixerReader(); + + 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_SDLMIXERREADER diff --git a/intern/audaspace/SDL/Makefile b/intern/audaspace/SDL/Makefile new file mode 100644 index 00000000000..aa21091f7a2 --- /dev/null +++ b/intern/audaspace/SDL/Makefile @@ -0,0 +1,41 @@ +# +# $Id: Makefile 13161 2008-01-07 19:13:47Z hos $ +# +# ***** 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): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = SDLaudaspace +DIR = $(OCGDIR)/intern/$(LIBNAME) + +include nan_compile.mk + +CCFLAGS += $(LEVEL_1_CPP_WARNINGS) + +CPPFLAGS += $(NAN_SDLCFLAGS) +CPPFLAGS += -I../intern +CPPFLAGS += -I.. +CPPFLAGS += -I. -- cgit v1.2.3