Audaspace:
authorJoerg Mueller <nexyon@gmail.com>
Mon, 5 Nov 2012 14:24:35 +0000 (14:24 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Mon, 5 Nov 2012 14:24:35 +0000 (14:24 +0000)
Replacing AUD_Reference with boost::shared_ptr.

137 files changed:
intern/audaspace/CMakeLists.txt
intern/audaspace/FX/AUD_AccumulatorFactory.cpp
intern/audaspace/FX/AUD_AccumulatorFactory.h
intern/audaspace/FX/AUD_BaseIIRFilterReader.cpp
intern/audaspace/FX/AUD_BaseIIRFilterReader.h
intern/audaspace/FX/AUD_ButterworthFactory.cpp
intern/audaspace/FX/AUD_ButterworthFactory.h
intern/audaspace/FX/AUD_CallbackIIRFilterReader.cpp
intern/audaspace/FX/AUD_CallbackIIRFilterReader.h
intern/audaspace/FX/AUD_DelayFactory.cpp
intern/audaspace/FX/AUD_DelayFactory.h
intern/audaspace/FX/AUD_DelayReader.cpp
intern/audaspace/FX/AUD_DelayReader.h
intern/audaspace/FX/AUD_DoubleFactory.cpp
intern/audaspace/FX/AUD_DoubleFactory.h
intern/audaspace/FX/AUD_DoubleReader.cpp
intern/audaspace/FX/AUD_DoubleReader.h
intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h
intern/audaspace/FX/AUD_DynamicIIRFilterReader.cpp
intern/audaspace/FX/AUD_DynamicIIRFilterReader.h
intern/audaspace/FX/AUD_EffectFactory.cpp
intern/audaspace/FX/AUD_EffectFactory.h
intern/audaspace/FX/AUD_EffectReader.cpp
intern/audaspace/FX/AUD_EffectReader.h
intern/audaspace/FX/AUD_EnvelopeFactory.cpp
intern/audaspace/FX/AUD_EnvelopeFactory.h
intern/audaspace/FX/AUD_FaderFactory.cpp
intern/audaspace/FX/AUD_FaderFactory.h
intern/audaspace/FX/AUD_FaderReader.cpp
intern/audaspace/FX/AUD_FaderReader.h
intern/audaspace/FX/AUD_HighpassFactory.cpp
intern/audaspace/FX/AUD_HighpassFactory.h
intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h [moved from intern/audaspace/intern/AUD_ReferenceHandler.cpp with 54% similarity]
intern/audaspace/FX/AUD_IIRFilterFactory.cpp
intern/audaspace/FX/AUD_IIRFilterFactory.h
intern/audaspace/FX/AUD_IIRFilterReader.cpp
intern/audaspace/FX/AUD_IIRFilterReader.h
intern/audaspace/FX/AUD_LimiterFactory.cpp
intern/audaspace/FX/AUD_LimiterFactory.h
intern/audaspace/FX/AUD_LimiterReader.cpp
intern/audaspace/FX/AUD_LimiterReader.h
intern/audaspace/FX/AUD_LoopFactory.cpp
intern/audaspace/FX/AUD_LoopFactory.h
intern/audaspace/FX/AUD_LoopReader.cpp
intern/audaspace/FX/AUD_LoopReader.h
intern/audaspace/FX/AUD_LowpassFactory.cpp
intern/audaspace/FX/AUD_LowpassFactory.h
intern/audaspace/FX/AUD_PingPongFactory.cpp
intern/audaspace/FX/AUD_PingPongFactory.h
intern/audaspace/FX/AUD_PitchFactory.cpp
intern/audaspace/FX/AUD_PitchFactory.h
intern/audaspace/FX/AUD_PitchReader.cpp
intern/audaspace/FX/AUD_PitchReader.h
intern/audaspace/FX/AUD_RectifyFactory.cpp
intern/audaspace/FX/AUD_RectifyFactory.h
intern/audaspace/FX/AUD_ReverseFactory.cpp
intern/audaspace/FX/AUD_ReverseFactory.h
intern/audaspace/FX/AUD_ReverseReader.cpp
intern/audaspace/FX/AUD_ReverseReader.h
intern/audaspace/FX/AUD_SquareFactory.cpp
intern/audaspace/FX/AUD_SquareFactory.h
intern/audaspace/FX/AUD_SumFactory.cpp
intern/audaspace/FX/AUD_SumFactory.h
intern/audaspace/FX/AUD_SuperposeFactory.cpp
intern/audaspace/FX/AUD_SuperposeFactory.h
intern/audaspace/FX/AUD_SuperposeReader.cpp
intern/audaspace/FX/AUD_SuperposeReader.h
intern/audaspace/FX/AUD_VolumeFactory.cpp
intern/audaspace/FX/AUD_VolumeFactory.h
intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
intern/audaspace/OpenAL/AUD_OpenALDevice.h
intern/audaspace/Python/AUD_PyAPI.cpp
intern/audaspace/SConscript
intern/audaspace/ffmpeg/AUD_FFMPEGFactory.cpp
intern/audaspace/ffmpeg/AUD_FFMPEGFactory.h
intern/audaspace/ffmpeg/AUD_FFMPEGReader.cpp
intern/audaspace/ffmpeg/AUD_FFMPEGReader.h
intern/audaspace/intern/AUD_BufferReader.cpp
intern/audaspace/intern/AUD_BufferReader.h
intern/audaspace/intern/AUD_C-API.cpp
intern/audaspace/intern/AUD_C-API.h
intern/audaspace/intern/AUD_ChannelMapperFactory.cpp
intern/audaspace/intern/AUD_ChannelMapperFactory.h
intern/audaspace/intern/AUD_ChannelMapperReader.cpp
intern/audaspace/intern/AUD_ChannelMapperReader.h
intern/audaspace/intern/AUD_ConverterFactory.cpp
intern/audaspace/intern/AUD_ConverterFactory.h
intern/audaspace/intern/AUD_ConverterReader.cpp
intern/audaspace/intern/AUD_ConverterReader.h
intern/audaspace/intern/AUD_FileFactory.cpp
intern/audaspace/intern/AUD_FileFactory.h
intern/audaspace/intern/AUD_FileWriter.cpp
intern/audaspace/intern/AUD_FileWriter.h
intern/audaspace/intern/AUD_IDevice.h
intern/audaspace/intern/AUD_IFactory.h
intern/audaspace/intern/AUD_JOSResampleFactory.cpp
intern/audaspace/intern/AUD_JOSResampleFactory.h
intern/audaspace/intern/AUD_JOSResampleReader.cpp
intern/audaspace/intern/AUD_JOSResampleReader.h
intern/audaspace/intern/AUD_LinearResampleFactory.cpp
intern/audaspace/intern/AUD_LinearResampleFactory.h
intern/audaspace/intern/AUD_LinearResampleReader.cpp
intern/audaspace/intern/AUD_LinearResampleReader.h
intern/audaspace/intern/AUD_Mixer.h
intern/audaspace/intern/AUD_MixerFactory.cpp
intern/audaspace/intern/AUD_MixerFactory.h
intern/audaspace/intern/AUD_NULLDevice.cpp
intern/audaspace/intern/AUD_NULLDevice.h
intern/audaspace/intern/AUD_Reference.h [deleted file]
intern/audaspace/intern/AUD_ResampleReader.cpp
intern/audaspace/intern/AUD_ResampleReader.h
intern/audaspace/intern/AUD_Sequencer.cpp [new file with mode: 0644]
intern/audaspace/intern/AUD_Sequencer.h [new file with mode: 0644]
intern/audaspace/intern/AUD_SequencerEntry.cpp
intern/audaspace/intern/AUD_SequencerEntry.h
intern/audaspace/intern/AUD_SequencerFactory.cpp
intern/audaspace/intern/AUD_SequencerFactory.h
intern/audaspace/intern/AUD_SequencerHandle.cpp
intern/audaspace/intern/AUD_SequencerHandle.h
intern/audaspace/intern/AUD_SequencerReader.cpp
intern/audaspace/intern/AUD_SequencerReader.h
intern/audaspace/intern/AUD_SilenceFactory.cpp
intern/audaspace/intern/AUD_SilenceFactory.h
intern/audaspace/intern/AUD_SinusFactory.cpp
intern/audaspace/intern/AUD_SinusFactory.h
intern/audaspace/intern/AUD_SoftwareDevice.cpp
intern/audaspace/intern/AUD_SoftwareDevice.h
intern/audaspace/intern/AUD_StreamBufferFactory.cpp
intern/audaspace/intern/AUD_StreamBufferFactory.h
intern/audaspace/sndfile/AUD_SndFileFactory.cpp
intern/audaspace/sndfile/AUD_SndFileFactory.h
intern/audaspace/sndfile/AUD_SndFileReader.cpp
intern/audaspace/sndfile/AUD_SndFileReader.h
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/KX_SoundActuator.h

index 1671194653a22de0d11dd1bb0cfb4a9ee9965ba3..b0babc04479763843ae9f959fa1315fbc1a80392 100644 (file)
@@ -28,6 +28,7 @@ set(INC
 
 set(INC_SYS
        ${PTHREADS_INCLUDE_DIRS}
+       ${BOOST_INCLUDE_DIR}
 )
 
 set(SRC
@@ -120,6 +121,8 @@ set(SRC
        intern/AUD_ResampleFactory.h
        intern/AUD_ResampleReader.cpp
        intern/AUD_ResampleReader.h
+       intern/AUD_Sequencer.cpp
+       intern/AUD_Sequencer.h
        intern/AUD_SequencerEntry.cpp
        intern/AUD_SequencerEntry.h
        intern/AUD_SequencerFactory.cpp
@@ -150,6 +153,7 @@ set(SRC
        FX/AUD_DelayReader.h
        FX/AUD_DoubleFactory.h
        FX/AUD_DoubleReader.h
+       FX/AUD_IDynamicIIRFilterCalculator.h
        FX/AUD_DynamicIIRFilterFactory.h
        FX/AUD_DynamicIIRFilterReader.h
        FX/AUD_EffectFactory.h
index 1862b9ab79d94f1bfc9647825693571654c9e0d7..00d3a9f23956dd52fec194e148262a122212b6cd 100644 (file)
@@ -50,15 +50,15 @@ sample_t AUD_AccumulatorFactory::accumulatorFilter(AUD_CallbackIIRFilterReader*
        return out;
 }
 
-AUD_AccumulatorFactory::AUD_AccumulatorFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_AccumulatorFactory::AUD_AccumulatorFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                           bool additive) :
                AUD_EffectFactory(factory),
                m_additive(additive)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_AccumulatorFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_AccumulatorFactory::createReader()
 {
-       return new AUD_CallbackIIRFilterReader(getReader(), 2, 2,
-                                                       m_additive ? accumulatorFilterAdditive : accumulatorFilter);
+       return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 2, 2,
+                                                       m_additive ? accumulatorFilterAdditive : accumulatorFilter));
 }
index ac73c5aa6aec8966420154d771f8c97d74e3eceb..9087218a5f93349ae821df932b1c52fad185a3d3 100644 (file)
@@ -58,9 +58,9 @@ public:
         * \param factory The input factory.
         * \param additive Whether the accumulator is additive.
         */
-       AUD_AccumulatorFactory(AUD_Reference<AUD_IFactory> factory, bool additive = false);
+       AUD_AccumulatorFactory(boost::shared_ptr<AUD_IFactory> factory, bool additive = false);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 
        static sample_t accumulatorFilterAdditive(AUD_CallbackIIRFilterReader* reader, void* useless);
        static sample_t accumulatorFilter(AUD_CallbackIIRFilterReader* reader, void* useless);
index fa9e8746b2b260313fa944998b14d77f5fd8c0d2..eadfc525f9645463f06bbaf05371f9861daee8f1 100644 (file)
@@ -33,7 +33,7 @@
 
 #define CC m_specs.channels + m_channel
 
-AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in,
+AUD_BaseIIRFilterReader::AUD_BaseIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in,
                                                                                                 int out) :
                AUD_EffectReader(reader),
                m_specs(reader->getSpecs()),
index 43970c96a42acc8d739f11b6edec16fe70e63919..fe0a8efce643d6325f6d87b52872b360fce67c0e 100644 (file)
@@ -90,7 +90,7 @@ protected:
         * \param in The count of past input samples needed.
         * \param out The count of past output samples needed.
         */
-       AUD_BaseIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in, int out);
+       AUD_BaseIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in, int out);
 
        void setLengths(int in, int out);
 
index af1a5af97df17593f530caa3fc11318ccfa79b5e..97d85c8122fc026da682c68349927905906b6ada 100644 (file)
@@ -39,7 +39,7 @@
 #define BWPB41 0.76536686473
 #define BWPB42 1.84775906502
 
-AUD_ButterworthFactory::AUD_ButterworthFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                           float frequency) :
                AUD_DynamicIIRFilterFactory(factory),
                m_frequency(frequency)
index dc8b4d92775e5401708efa14cb1cfdb7a2ad54cf..e796f76aa29321bcd4efb4d20b189ee79ec44722 100644 (file)
@@ -53,7 +53,7 @@ public:
         * \param factory The input factory.
         * \param frequency The cutoff frequency.
         */
-       AUD_ButterworthFactory(AUD_Reference<AUD_IFactory> factory, float frequency);
+       AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency);
 
        virtual void recalculateCoefficients(AUD_SampleRate rate,
                                             std::vector<float>& b,
index 1a5c99adfb93a7f08042780a66d6c5c9ab10840a..b5157d476665c8eba90acf9c4fa5eb38277cb08f 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AUD_CallbackIIRFilterReader.h"
 
-AUD_CallbackIIRFilterReader::AUD_CallbackIIRFilterReader(AUD_Reference<AUD_IReader> reader,
+AUD_CallbackIIRFilterReader::AUD_CallbackIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
                                                                                                                 int in, int out,
                                                                                                                 doFilterIIR doFilter,
                                                                                                                 endFilterIIR endFilter,
index 7ced73844c95ed0c59463923f184126b207aa239..d9df65f03eb671f8be09f5ecb6bb9b34285d4eb6 100644 (file)
@@ -74,7 +74,7 @@ public:
         * \param endFilter The finishing callback.
         * \param data Data pointer for the callbacks.
         */
-       AUD_CallbackIIRFilterReader(AUD_Reference<AUD_IReader> reader, int in, int out,
+       AUD_CallbackIIRFilterReader(boost::shared_ptr<AUD_IReader> reader, int in, int out,
                                                                doFilterIIR doFilter,
                                                                endFilterIIR endFilter = 0,
                                                                void* data = 0);
index a4606597933506229c9d36d4361bfc9a1903750f..3e5a7cfd2f809deb52461b480c04c2c5c295e99a 100644 (file)
@@ -31,7 +31,7 @@
 #include "AUD_DelayReader.h"
 #include "AUD_Space.h"
 
-AUD_DelayFactory::AUD_DelayFactory(AUD_Reference<AUD_IFactory> factory, float delay) :
+AUD_DelayFactory::AUD_DelayFactory(boost::shared_ptr<AUD_IFactory> factory, float delay) :
                AUD_EffectFactory(factory),
                m_delay(delay)
 {
@@ -42,7 +42,7 @@ float AUD_DelayFactory::getDelay() const
        return m_delay;
 }
 
-AUD_Reference<AUD_IReader> AUD_DelayFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_DelayFactory::createReader()
 {
-       return new AUD_DelayReader(getReader(), m_delay);
+       return boost::shared_ptr<AUD_IReader>(new AUD_DelayReader(getReader(), m_delay));
 }
index 26855a05d704edf2788143d63c052e18b471ddbe..8cfb2be9ac8f2749332bb6102fbf4df41349b726 100644 (file)
@@ -53,14 +53,14 @@ public:
         * \param factory The input factory.
         * \param delay The desired delay in seconds.
         */
-       AUD_DelayFactory(AUD_Reference<AUD_IFactory> factory, float delay = 0);
+       AUD_DelayFactory(boost::shared_ptr<AUD_IFactory> factory, float delay = 0);
 
        /**
         * Returns the delay in seconds.
         */
        float getDelay() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_DELAYFACTORY_H__
index 0e9833cd07f74f0c05491dc94dd8650ab2c3460e..050508f28da3432cd642289d6899fbf8d8090627 100644 (file)
@@ -31,7 +31,7 @@
 
 #include <cstring>
 
-AUD_DelayReader::AUD_DelayReader(AUD_Reference<AUD_IReader> reader, float delay) :
+AUD_DelayReader::AUD_DelayReader(boost::shared_ptr<AUD_IReader> reader, float delay) :
                AUD_EffectReader(reader),
                m_delay(int((AUD_SampleRate)delay * reader->getSpecs().rate)),
                m_remdelay(int((AUD_SampleRate)delay * reader->getSpecs().rate))
index 9d9b6619470ed653bed6b4d2c208e852eb2da971..d4388e3befcd571bc56dc7d0501b47edd88e9f57 100644 (file)
@@ -59,7 +59,7 @@ public:
         * \param reader The reader to read from.
         * \param delay The delay in seconds.
         */
-       AUD_DelayReader(AUD_Reference<AUD_IReader> reader, float delay);
+       AUD_DelayReader(boost::shared_ptr<AUD_IReader> reader, float delay);
 
        virtual void seek(int position);
        virtual int getLength() const;
index ab0111f8955bcf2e9b02e37e25274767cb2253fe..21bcbc2f6495bb6c2541e7610aefe3c139a95714 100644 (file)
 #include "AUD_DoubleFactory.h"
 #include "AUD_DoubleReader.h"
 
-AUD_DoubleFactory::AUD_DoubleFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2) :
+AUD_DoubleFactory::AUD_DoubleFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2) :
                m_factory1(factory1), m_factory2(factory2)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_DoubleFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_DoubleFactory::createReader()
 {
-       AUD_Reference<AUD_IReader> reader1 = m_factory1->createReader();
-       AUD_Reference<AUD_IReader> reader2 = m_factory2->createReader();
+       boost::shared_ptr<AUD_IReader> reader1 = m_factory1->createReader();
+       boost::shared_ptr<AUD_IReader> reader2 = m_factory2->createReader();
 
-       return new AUD_DoubleReader(reader1, reader2);
+       return boost::shared_ptr<AUD_IReader>(new AUD_DoubleReader(reader1, reader2));
 }
index e4d8fbfde8fada9c6268cf52f8b3c5bb43894e6a..4a02cc7bcdb3f67d21135404735761ff97aff451 100644 (file)
@@ -41,12 +41,12 @@ private:
        /**
         * First played factory.
         */
-       AUD_Reference<AUD_IFactory> m_factory1;
+       boost::shared_ptr<AUD_IFactory> m_factory1;
 
        /**
         * Second played factory.
         */
-       AUD_Reference<AUD_IFactory> m_factory2;
+       boost::shared_ptr<AUD_IFactory> m_factory2;
 
        // hide copy constructor and operator=
        AUD_DoubleFactory(const AUD_DoubleFactory&);
@@ -58,9 +58,9 @@ public:
         * \param factory1 The first input factory.
         * \param factory2 The second input factory.
         */
-       AUD_DoubleFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2);
+       AUD_DoubleFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_DOUBLEFACTORY_H__
index 2b28bc7d6791edad0f6b2f75bb68fa4d67e052d5..ee18914e93fe6ba023fc74111b486b13dc84d173 100644 (file)
@@ -31,8 +31,8 @@
 
 #include <cstring>
 
-AUD_DoubleReader::AUD_DoubleReader(AUD_Reference<AUD_IReader> reader1,
-                                                                  AUD_Reference<AUD_IReader> reader2) :
+AUD_DoubleReader::AUD_DoubleReader(boost::shared_ptr<AUD_IReader> reader1,
+                                                                  boost::shared_ptr<AUD_IReader> reader2) :
                m_reader1(reader1), m_reader2(reader2), m_finished1(false)
 {
        AUD_Specs s1, s2;
index 1489f4eb1841ba1c09591079081f726dfdc3a2ba..5d2f65f1a9004fb157bf10230e766fdb512f5c01 100644 (file)
@@ -32,7 +32,8 @@
 
 #include "AUD_IReader.h"
 #include "AUD_Buffer.h"
-#include "AUD_Reference.h"
+
+#include <boost/shared_ptr.hpp>
 
 /**
  * This reader plays two readers sequently.
@@ -43,12 +44,12 @@ private:
        /**
         * The first reader.
         */
-       AUD_Reference<AUD_IReader> m_reader1;
+       boost::shared_ptr<AUD_IReader> m_reader1;
 
        /**
         * The second reader.
         */
-       AUD_Reference<AUD_IReader> m_reader2;
+       boost::shared_ptr<AUD_IReader> m_reader2;
 
        /**
         * Whether we've reached the end of the first reader.
@@ -65,7 +66,7 @@ public:
         * \param reader1 The first reader to read from.
         * \param reader2 The second reader to read from.
         */
-       AUD_DoubleReader(AUD_Reference<AUD_IReader> reader1, AUD_Reference<AUD_IReader> reader2);
+       AUD_DoubleReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2);
 
        /**
         * Destroys the reader.
index 3d6beb6c554394f65f6f4b74d2731894fdd5be22..e8ea4323b2e8948f302f86e574ea979b38f842e2 100644 (file)
 #include "AUD_DynamicIIRFilterFactory.h"
 #include "AUD_DynamicIIRFilterReader.h"
 
-AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(AUD_Reference<AUD_IFactory> factory) :
+
+AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory) :
        AUD_EffectFactory(factory)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_DynamicIIRFilterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_DynamicIIRFilterFactory::createReader()
 {
-       return new AUD_DynamicIIRFilterReader(getReader(), this);
+       return boost::shared_ptr<AUD_IReader>(new AUD_DynamicIIRFilterReader(getReader(), m_calculator));
 }
+
index 5b297db2d5603e57a3c69d10730d7a904ef1004c..f36a37f44b45ef0495d3873d3bc224d9819431d2 100644 (file)
@@ -30,6 +30,7 @@
 #define __AUD_DYNAMICIIRFILTERFACTORY_H__
 
 #include "AUD_EffectFactory.h"
+#include "AUD_IDynamicIIRFilterCalculator.h"
 #include <vector>
 
 /**
  */
 class AUD_DynamicIIRFilterFactory : public AUD_EffectFactory
 {
+protected:
+       boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> m_calculator;
+
 public:
        /**
         * Creates a new Dynmic IIR filter factory.
         * \param factory The input factory.
         */
-       AUD_DynamicIIRFilterFactory(AUD_Reference<AUD_IFactory> factory);
-
-       virtual AUD_Reference<AUD_IReader> createReader();
+       AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory);
 
-       /**
-        * Recalculates the filter coefficients.
-        * \param rate The sample rate of the audio data.
-        * \param[out] b The input filter coefficients.
-        * \param[out] a The output filter coefficients.
-        */
-       virtual void recalculateCoefficients(AUD_SampleRate rate,
-                                            std::vector<float>& b,
-                                            std::vector<float>& a)=0;
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif // __AUD_DYNAMICIIRFILTERFACTORY_H__
index 24332ebfc1a98a4f23dd52896a9721492c5d30b6..52aaf2311c0704798a78dd5c8c41b7bcbe443d72 100644 (file)
 
 #include "AUD_DynamicIIRFilterReader.h"
 
-AUD_DynamicIIRFilterReader::AUD_DynamicIIRFilterReader(AUD_Reference<AUD_IReader> reader,
-                                                                                                          AUD_Reference<AUD_DynamicIIRFilterFactory> factory) :
+AUD_DynamicIIRFilterReader::AUD_DynamicIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
+                                                                                                          boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator) :
        AUD_IIRFilterReader(reader, std::vector<float>(), std::vector<float>()),
-       m_factory(factory)
+       m_calculator(calculator)
 {
        sampleRateChanged(reader->getSpecs().rate);
 }
@@ -39,6 +39,6 @@ AUD_DynamicIIRFilterReader::AUD_DynamicIIRFilterReader(AUD_Reference<AUD_IReader
 void AUD_DynamicIIRFilterReader::sampleRateChanged(AUD_SampleRate rate)
 {
        std::vector<float> a, b;
-       m_factory->recalculateCoefficients(rate, b, a);
+       m_calculator->recalculateCoefficients(rate, b, a);
        setCoefficients(b, a);
 }
index 8a53c15b18f1662edb493cf26aaeca20aaa58499..0b68578bc535a41903ebe13b382e12e24eca4a70 100644 (file)
@@ -30,7 +30,7 @@
 #define __AUD_DYNAMICIIRFILTERREADER_H__
 
 #include "AUD_IIRFilterReader.h"
-#include "AUD_DynamicIIRFilterFactory.h"
+#include "AUD_IDynamicIIRFilterCalculator.h"
 
 /**
  * This class is for dynamic infinite impulse response filters with simple
@@ -42,11 +42,11 @@ private:
        /**
         * The factory for dynamically recalculating filter coefficients.
         */
-       AUD_Reference<AUD_DynamicIIRFilterFactory> m_factory;
+       boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> m_calculator;
 
 public:
-       AUD_DynamicIIRFilterReader(AUD_Reference<AUD_IReader> reader,
-                                                          AUD_Reference<AUD_DynamicIIRFilterFactory> factory);
+       AUD_DynamicIIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
+                                                          boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator);
 
        virtual void sampleRateChanged(AUD_SampleRate rate);
 };
index d35f8affec8fec589362598d0751247f6d5ac9c3..6018ed561ca10fcbbb86ed80063ea6d9b595b50d 100644 (file)
@@ -30,7 +30,7 @@
 #include "AUD_EffectFactory.h"
 #include "AUD_IReader.h"
 
-AUD_EffectFactory::AUD_EffectFactory(AUD_Reference<AUD_IFactory> factory)
+AUD_EffectFactory::AUD_EffectFactory(boost::shared_ptr<AUD_IFactory> factory)
 {
        m_factory = factory;
 }
@@ -39,7 +39,7 @@ AUD_EffectFactory::~AUD_EffectFactory()
 {
 }
 
-AUD_Reference<AUD_IFactory> AUD_EffectFactory::getFactory() const
+boost::shared_ptr<AUD_IFactory> AUD_EffectFactory::getFactory() const
 {
        return m_factory;
 }
index c8d26a1daa71ac605b217dc182a6bec98c1e1c2c..d09872638be5470df0adde272273c3ad2e92c4d8 100644 (file)
@@ -47,7 +47,7 @@ protected:
        /**
         * If there is no reader it is created out of this factory.
         */
-       AUD_Reference<AUD_IFactory> m_factory;
+       boost::shared_ptr<AUD_IFactory> m_factory;
 
        /**
         * Returns the reader created out of the factory.
@@ -55,7 +55,7 @@ protected:
         * classes.
         * \return The reader created out of the factory.
         */
-       inline AUD_Reference<AUD_IReader> getReader() const
+       inline boost::shared_ptr<AUD_IReader> getReader() const
        {
                return m_factory->createReader();
        }
@@ -65,7 +65,7 @@ public:
         * Creates a new factory.
         * \param factory The input factory.
         */
-       AUD_EffectFactory(AUD_Reference<AUD_IFactory> factory);
+       AUD_EffectFactory(boost::shared_ptr<AUD_IFactory> factory);
 
        /**
         * Destroys the factory.
@@ -76,7 +76,7 @@ public:
         * Returns the saved factory.
         * \return The factory or NULL if there has no factory been saved.
         */
-       AUD_Reference<AUD_IFactory> getFactory() const;
+       boost::shared_ptr<AUD_IFactory> getFactory() const;
 };
 
 #endif //__AUD_EFFECTFACTORY_H__
index 6c08549e744199da6bb67eba5ab69c990099c070..b3e80bef03bedfe2475f9ab0a2b60eb58639c99d 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AUD_EffectReader.h"
 
-AUD_EffectReader::AUD_EffectReader(AUD_Reference<AUD_IReader> reader)
+AUD_EffectReader::AUD_EffectReader(boost::shared_ptr<AUD_IReader> reader)
 {
        m_reader = reader;
 }
index b089ec9a318d6675cca9d7cccec89dd654b3f840..2745c12afafb972e61bc2d614c5d57eed656b23c 100644 (file)
@@ -31,7 +31,8 @@
 #define __AUD_EFFECTREADER_H__
 
 #include "AUD_IReader.h"
-#include "AUD_Reference.h"
+
+#include <boost/shared_ptr.hpp>
 
 /**
  * This reader is a base class for all effect readers that take one other reader
@@ -48,14 +49,14 @@ protected:
        /**
         * The reader to read from.
         */
-       AUD_Reference<AUD_IReader> m_reader;
+       boost::shared_ptr<AUD_IReader> m_reader;
 
 public:
        /**
         * Creates a new effect reader.
         * \param reader The reader to read from.
         */
-       AUD_EffectReader(AUD_Reference<AUD_IReader> reader);
+       AUD_EffectReader(boost::shared_ptr<AUD_IReader> reader);
 
        /**
         * Destroys the reader.
index c71766626595fc74ca5a8c761d814063beeb5cb0..1e5737557c180cf963c35250c0e1acc98c2bb3e9 100644 (file)
@@ -54,7 +54,7 @@ void AUD_EnvelopeFactory::endEnvelopeFilter(EnvelopeParameters* param)
        delete param;
 }
 
-AUD_EnvelopeFactory::AUD_EnvelopeFactory(AUD_Reference<AUD_IFactory> factory, float attack,
+AUD_EnvelopeFactory::AUD_EnvelopeFactory(boost::shared_ptr<AUD_IFactory> factory, float attack,
                                                                                 float release, float threshold,
                                                                                 float arthreshold) :
                AUD_EffectFactory(factory),
@@ -65,9 +65,9 @@ AUD_EnvelopeFactory::AUD_EnvelopeFactory(AUD_Reference<AUD_IFactory> factory, fl
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_EnvelopeFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_EnvelopeFactory::createReader()
 {
-       AUD_Reference<AUD_IReader> reader = getReader();
+       boost::shared_ptr<AUD_IReader> reader = getReader();
 
        EnvelopeParameters* param = new EnvelopeParameters();
        param->arthreshold = m_arthreshold;
@@ -75,8 +75,8 @@ AUD_Reference<AUD_IReader> AUD_EnvelopeFactory::createReader()
        param->release = pow(m_arthreshold, 1.0f/(static_cast<float>(reader->getSpecs().rate) * m_release));
        param->threshold = m_threshold;
 
-       return new AUD_CallbackIIRFilterReader(reader, 1, 2,
+       return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(reader, 1, 2,
                                                                                   (doFilterIIR) envelopeFilter,
                                                                                   (endFilterIIR) endEnvelopeFilter,
-                                                                                  param);
+                                                                                  param));
 }
index c8f3dc37cd26c2717f974c14f2b9e15c2c00f1ab..656212c8cac7f5506fa51f0515356140275186eb 100644 (file)
@@ -73,10 +73,10 @@ public:
         * \param threshold The threshold value.
         * \param arthreshold The attack/release threshold value.
         */
-       AUD_EnvelopeFactory(AUD_Reference<AUD_IFactory> factory, float attack, float release,
+       AUD_EnvelopeFactory(boost::shared_ptr<AUD_IFactory> factory, float attack, float release,
                                                float threshold, float arthreshold);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 
        static sample_t envelopeFilter(AUD_CallbackIIRFilterReader* reader, EnvelopeParameters* param);
        static void endEnvelopeFilter(EnvelopeParameters* param);
index ec119ef93882f0a97fa9e5e022eeb167d55bb0d7..b34d2134385ad418d57accc408ef21de0f927ab1 100644 (file)
@@ -30,7 +30,7 @@
 #include "AUD_FaderFactory.h"
 #include "AUD_FaderReader.h"
 
-AUD_FaderFactory::AUD_FaderFactory(AUD_Reference<AUD_IFactory> factory, AUD_FadeType type,
+AUD_FaderFactory::AUD_FaderFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_FadeType type,
                                                                   float start, float length) :
                AUD_EffectFactory(factory),
                m_type(type),
@@ -54,7 +54,7 @@ float AUD_FaderFactory::getLength() const
        return m_length;
 }
 
-AUD_Reference<AUD_IReader> AUD_FaderFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_FaderFactory::createReader()
 {
-       return new AUD_FaderReader(getReader(), m_type, m_start, m_length);
+       return boost::shared_ptr<AUD_IReader>(new AUD_FaderReader(getReader(), m_type, m_start, m_length));
 }
index 82eaf2fae9f36e1eff19b4a8d7179ad818b8bafb..f9ad88a751d9bd2442dd8efeb45661acd9e79a26 100644 (file)
@@ -67,7 +67,7 @@ public:
         * \param start The time where fading should start in seconds.
         * \param length How long fading should last in seconds.
         */
-       AUD_FaderFactory(AUD_Reference<AUD_IFactory> factory,
+       AUD_FaderFactory(boost::shared_ptr<AUD_IFactory> factory,
                         AUD_FadeType type = AUD_FADE_IN,
                         float start = 0.0f, float length = 1.0f);
 
@@ -86,7 +86,7 @@ public:
         */
        float getLength() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_FADERFACTORY_H__
index 4ece91ca899695ade900bf0add69174e4f31f110..e09072054cb818093dfc5e3a39387c5ccd9fd4c5 100644 (file)
@@ -31,7 +31,7 @@
 
 #include <cstring>
 
-AUD_FaderReader::AUD_FaderReader(AUD_Reference<AUD_IReader> reader, AUD_FadeType type,
+AUD_FaderReader::AUD_FaderReader(boost::shared_ptr<AUD_IReader> reader, AUD_FadeType type,
                                                                 float start,float length) :
                AUD_EffectReader(reader),
                m_type(type),
index 788e8539228b6fac74353624e4b21e4df21a4a20..a49960b30fb1e66d052775be40c3a810497c9cd0 100644 (file)
@@ -67,7 +67,7 @@ public:
         * \param start The time where fading should start in seconds.
         * \param length How long fading should last in seconds.
         */
-       AUD_FaderReader(AUD_Reference<AUD_IReader> reader, AUD_FadeType type,
+       AUD_FaderReader(boost::shared_ptr<AUD_IReader> reader, AUD_FadeType type,
                                        float start,float length);
 
        virtual void read(int& length, bool& eos, sample_t* buffer);
index b56be8942ff34565fb067ed374c9e70e23ace2b9..ba5297d21edcdc8db10210b76c0d3de376f0a8c3 100644 (file)
@@ -36,7 +36,7 @@
 #define M_PI 3.14159265358979323846
 #endif
 
-AUD_HighpassFactory::AUD_HighpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency,
+AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
                                                                                 float Q) :
                AUD_DynamicIIRFilterFactory(factory),
                m_frequency(frequency),
index 66aa809123450822afb435cd8d9626b145db5a2f..ed7e9db44a41be2347a3f3e73141cbb4dd18a74b 100644 (file)
@@ -59,7 +59,7 @@ public:
         * \param frequency The cutoff frequency.
         * \param Q The Q factor.
         */
-       AUD_HighpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency, float Q = 1.0f);
+       AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
 
        virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
 };
similarity index 54%
rename from intern/audaspace/intern/AUD_ReferenceHandler.cpp
rename to intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
index 6aa4f87ea9683dd5f3bd7a029543014bced24bde..77d83360255dc4f6ba5d5c18c36af39295405934 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file audaspace/intern/AUD_ReferenceHandler.cpp
- *  \ingroup audaspaceintern
+/** \file audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
+ *  \ingroup audfx
  */
 
-#include "AUD_Reference.h"
+#ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H
+#define AUD_IDYNAMICIIRFILTERCALCULATOR_H
 
-std::map<void*, unsigned int> AUD_ReferenceHandler::m_references;
-pthread_mutex_t AUD_ReferenceHandler::m_mutex;
-bool AUD_ReferenceHandler::m_mutex_initialised = false;
+#include <vector>
 
-pthread_mutex_t *AUD_ReferenceHandler::getMutex()
+/**
+ * This interface calculates dynamic filter coefficients which depend on the
+ * sampling rate for AUD_DynamicIIRFilterReaders.
+ */
+class AUD_IDynamicIIRFilterCalculator
 {
-       if(!m_mutex_initialised)
-       {
-               pthread_mutexattr_t attr;
-               pthread_mutexattr_init(&attr);
-               pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-
-               pthread_mutex_init(&m_mutex, &attr);
-
-               pthread_mutexattr_destroy(&attr);
-
-               m_mutex_initialised = true;
-       }
-
-       return &m_mutex;
-}
-
+public:
+       /**
+        * Recalculates the filter coefficients.
+        * \param rate The sample rate of the audio data.
+        * \param[out] b The input filter coefficients.
+        * \param[out] a The output filter coefficients.
+        */
+       virtual void recalculateCoefficients(AUD_SampleRate rate,
+                                                                                std::vector<float>& b,
+                                                                                std::vector<float>& a)=0;
+};
+
+#endif // AUD_IDYNAMICIIRFILTERCALCULATOR_H
index 807b0ef48994e6dcd920bd9d13d0d71d3031c212..c4f94a2dc277b3066475cb6071a5f9ec9c8ead3c 100644 (file)
 #include "AUD_IIRFilterFactory.h"
 #include "AUD_IIRFilterReader.h"
 
-AUD_IIRFilterFactory::AUD_IIRFilterFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_IIRFilterFactory::AUD_IIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                   std::vector<float> b,
                                                                                   std::vector<float> a) :
                AUD_EffectFactory(factory), m_a(a), m_b(b)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_IIRFilterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_IIRFilterFactory::createReader()
 {
-       return new AUD_IIRFilterReader(getReader(), m_b, m_a);
+       return boost::shared_ptr<AUD_IReader>(new AUD_IIRFilterReader(getReader(), m_b, m_a));
 }
index 43256a166aaa18a1b684020549722f0a3d4f2d3e..0b55c12038493bfc60d5105e35d21583bafcc515 100644 (file)
@@ -31,6 +31,7 @@
 #define __AUD_IIRFILTERFACTORY_H__
 
 #include "AUD_EffectFactory.h"
+#include "AUD_IDynamicIIRFilterCalculator.h"
 
 #include <vector>
 
@@ -61,10 +62,10 @@ public:
         * \param b The input filter coefficients.
         * \param a The output filter coefficients.
         */
-       AUD_IIRFilterFactory(AUD_Reference<AUD_IFactory> factory, std::vector<float> b,
+       AUD_IIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory, std::vector<float> b,
                                                 std::vector<float> a);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_IIRFILTERFACTORY_H__
index 8f78c110d1fc6c97214a8437a3f6c5da0d805200..6716e6b9ddcf8839c4061795ca42727ca6a5d73a 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AUD_IIRFilterReader.h"
 
-AUD_IIRFilterReader::AUD_IIRFilterReader(AUD_Reference<AUD_IReader> reader,
+AUD_IIRFilterReader::AUD_IIRFilterReader(boost::shared_ptr<AUD_IReader> reader,
                                                                                 const std::vector<float>& b,
                                                                                 const std::vector<float>& a) :
        AUD_BaseIIRFilterReader(reader, b.size(), a.size()), m_a(a), m_b(b)
index d9be52f29195baa46bc989da1715b4702ffc3ec0..d663805b50f18a3061980c93513b4b935dfcc44e 100644 (file)
@@ -61,7 +61,7 @@ public:
         * \param b The input filter coefficients.
         * \param a The output filter coefficients.
         */
-       AUD_IIRFilterReader(AUD_Reference<AUD_IReader> reader, const std::vector<float>& b,
+       AUD_IIRFilterReader(boost::shared_ptr<AUD_IReader> reader, const std::vector<float>& b,
                                                const std::vector<float>& a);
 
        virtual sample_t filter();
index e58657d8d704658c856d56fe487b77c8cf89451e..679ed3a6b8b87b33743776938687d2b89385fa3e 100644 (file)
@@ -31,7 +31,7 @@
 #include "AUD_LimiterReader.h"
 #include "AUD_Space.h"
 
-AUD_LimiterFactory::AUD_LimiterFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_LimiterFactory::AUD_LimiterFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                           float start, float end) :
                AUD_EffectFactory(factory),
                m_start(start),
@@ -49,7 +49,7 @@ float AUD_LimiterFactory::getEnd() const
        return m_end;
 }
 
-AUD_Reference<AUD_IReader> AUD_LimiterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_LimiterFactory::createReader()
 {
-       return new AUD_LimiterReader(getReader(), m_start, m_end);
+       return boost::shared_ptr<AUD_IReader>(new AUD_LimiterReader(getReader(), m_start, m_end));
 }
index ddc8183ce7a89e378ca6bdbb158d4d6dc790ce14..0376952b4bdd49a85c09c79d7ff039c23c4f7131 100644 (file)
@@ -60,7 +60,7 @@ public:
         * \param end The desired end time, a negative value signals that it should
         *            play to the end.
         */
-       AUD_LimiterFactory(AUD_Reference<AUD_IFactory> factory,
+       AUD_LimiterFactory(boost::shared_ptr<AUD_IFactory> factory,
                                           float start = 0, float end = -1);
 
        /**
@@ -73,7 +73,7 @@ public:
         */
        float getEnd() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_LIMITERFACTORY_H__
index 0abf496c7f9aab302c250d500bf2473a943e972a..9c1d4443b06489eaf4f680a976d4ca149c8aa3a3 100644 (file)
@@ -30,7 +30,7 @@
 #include "AUD_LimiterReader.h"
 #include "AUD_Buffer.h"
 
-AUD_LimiterReader::AUD_LimiterReader(AUD_Reference<AUD_IReader> reader,
+AUD_LimiterReader::AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader,
                                                                         float start, float end) :
                AUD_EffectReader(reader),
                m_start(start),
index 34c4ea7c20ec30c1f61a4b5087e1d2cbb906892b..607eb9e5bec0ebce4920da2860f294545e2083ab 100644 (file)
@@ -60,7 +60,7 @@ public:
         * \param end The desired end time (sample exklusive), a negative value
         *            signals that it should play to the end.
         */
-       AUD_LimiterReader(AUD_Reference<AUD_IReader> reader, float start = 0, float end = -1);
+       AUD_LimiterReader(boost::shared_ptr<AUD_IReader> reader, float start = 0, float end = -1);
 
        virtual void seek(int position);
        virtual int getLength() const;
index 32c9e6bad7f2b6eb100a05802ef51e5179c018a5..a9e83e349a0c00cc4ea101b75752ef9537f3b877 100644 (file)
@@ -30,7 +30,7 @@
 #include "AUD_LoopFactory.h"
 #include "AUD_LoopReader.h"
 
-AUD_LoopFactory::AUD_LoopFactory(AUD_Reference<AUD_IFactory> factory, int loop) :
+AUD_LoopFactory::AUD_LoopFactory(boost::shared_ptr<AUD_IFactory> factory, int loop) :
                AUD_EffectFactory(factory),
                m_loop(loop)
 {
@@ -41,7 +41,7 @@ int AUD_LoopFactory::getLoop() const
        return m_loop;
 }
 
-AUD_Reference<AUD_IReader> AUD_LoopFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_LoopFactory::createReader()
 {
-       return new AUD_LoopReader(getReader(), m_loop);
+       return boost::shared_ptr<AUD_IReader>(new AUD_LoopReader(getReader(), m_loop));
 }
index 754b780bd99ceb6d5523a67d2470abd289df9b74..570536bee9ae6960b5df4a5331eaed00f7b7ab14 100644 (file)
@@ -55,14 +55,14 @@ public:
         * \param loop The desired loop count, negative values result in endless
         *        looping.
         */
-       AUD_LoopFactory(AUD_Reference<AUD_IFactory> factory, int loop = -1);
+       AUD_LoopFactory(boost::shared_ptr<AUD_IFactory> factory, int loop = -1);
 
        /**
         * Returns the loop count.
         */
        int getLoop() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_LOOPFACTORY_H__
index 863f66f9f460e1ba1738a14fce5d459cebc241c3..6fbcaa5af37dbd689a5fe17ffa782ab51c643bf8 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <cstring>
 
-AUD_LoopReader::AUD_LoopReader(AUD_Reference<AUD_IReader> reader, int loop) :
+AUD_LoopReader::AUD_LoopReader(boost::shared_ptr<AUD_IReader> reader, int loop) :
                AUD_EffectReader(reader), m_count(loop), m_left(loop)
 {
 }
index fd2dd71d78f0aa836807d9c27ceffa7b80e09b7f..12b8078b12d513cc30ae54f4d8c8d88d05dfc73e 100644 (file)
@@ -61,7 +61,7 @@ public:
         * \param loop The desired loop count, negative values result in endless
         *        looping.
         */
-       AUD_LoopReader(AUD_Reference<AUD_IReader> reader, int loop);
+       AUD_LoopReader(boost::shared_ptr<AUD_IReader> reader, int loop);
 
        virtual void seek(int position);
        virtual int getLength() const;
index 14dbc951c7fbd2ab2e8dd2f13fd5d61f0a60b3ce..e2faa241ac9ae0b176088e07e1bdda452b09586c 100644 (file)
@@ -36,7 +36,7 @@
 #define M_PI 3.14159265358979323846
 #endif
 
-AUD_LowpassFactory::AUD_LowpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency,
+AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
                                                                           float Q) :
                AUD_DynamicIIRFilterFactory(factory),
                m_frequency(frequency),
index 7e98720a2dbdd24ec00bdb0b98ccbe88fc224033..fdbc6e5d91d73682eada0cb8a5c7867b280f83ad 100644 (file)
@@ -59,7 +59,7 @@ public:
         * \param frequency The cutoff frequency.
         * \param Q The Q factor.
         */
-       AUD_LowpassFactory(AUD_Reference<AUD_IFactory> factory, float frequency, float Q = 1.0f);
+       AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
 
        virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
 };
index 3d5011cf47b316be1ba4813ad8b4b05280c52049..84e4b29415e3c6f1642c133f9d63cfaa53769297 100644 (file)
 #include "AUD_DoubleReader.h"
 #include "AUD_ReverseFactory.h"
 
-AUD_PingPongFactory::AUD_PingPongFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_PingPongFactory::AUD_PingPongFactory(boost::shared_ptr<AUD_IFactory> factory) :
                AUD_EffectFactory(factory)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_PingPongFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_PingPongFactory::createReader()
 {
-       AUD_Reference<AUD_IReader> reader = getReader();
+       boost::shared_ptr<AUD_IReader> reader = getReader();
        AUD_ReverseFactory factory(m_factory);
-       AUD_Reference<AUD_IReader> reader2 = factory.createReader();
+       boost::shared_ptr<AUD_IReader> reader2 = factory.createReader();
 
-       return new AUD_DoubleReader(reader, reader2);
+       return boost::shared_ptr<AUD_IReader>(new AUD_DoubleReader(reader, reader2));
 }
index f25624a7c5e41e96c95ebd517d0ffc9cf9102a98..e8ee5c9e389c147a993880bce5fe5c09e46b7ff6 100644 (file)
@@ -48,9 +48,9 @@ public:
         * Creates a new ping pong factory.
         * \param factory The input factory.
         */
-       AUD_PingPongFactory(AUD_Reference<AUD_IFactory> factory);
+       AUD_PingPongFactory(boost::shared_ptr<AUD_IFactory> factory);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_PINGPONGFACTORY_H__
index c6e9ae0b457deb9e28ea3d30439cae989c6eb550..9dc27a581623f859cb51f1dad712d93ed7f947f6 100644 (file)
 #include "AUD_PitchReader.h"
 #include "AUD_Space.h"
 
-AUD_PitchFactory::AUD_PitchFactory(AUD_Reference<AUD_IFactory> factory, float pitch) :
+AUD_PitchFactory::AUD_PitchFactory(boost::shared_ptr<AUD_IFactory> factory, float pitch) :
                AUD_EffectFactory(factory),
                m_pitch(pitch)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_PitchFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_PitchFactory::createReader()
 {
-       return new AUD_PitchReader(getReader(), m_pitch);
+       return boost::shared_ptr<AUD_IReader>(new AUD_PitchReader(getReader(), m_pitch));
 }
index 5ad37ad1a6cd8b31fe4025753e3d89fc69b3553c..159388b28ddb53aed5af4f116e873b1db2f642ab 100644 (file)
@@ -53,9 +53,9 @@ public:
         * \param factory The input factory.
         * \param pitch The desired pitch.
         */
-       AUD_PitchFactory(AUD_Reference<AUD_IFactory> factory, float pitch);
+       AUD_PitchFactory(boost::shared_ptr<AUD_IFactory> factory, float pitch);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_PITCHFACTORY_H__
index 0d1ff012e73ba8421b339e71c129537e9bb0e1f2..218af4fc0900d54a4c02bec7d7d18258f7aec5f8 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AUD_PitchReader.h"
 
-AUD_PitchReader::AUD_PitchReader(AUD_Reference<AUD_IReader> reader, float pitch) :
+AUD_PitchReader::AUD_PitchReader(boost::shared_ptr<AUD_IReader> reader, float pitch) :
                AUD_EffectReader(reader), m_pitch(pitch)
 {
 }
index 3185bfdf30b0a0261eb2a416f1ca463c0d29a375..d22e589b05dab73466f90c672dc13e8e3a8bbfb3 100644 (file)
@@ -53,7 +53,7 @@ public:
         * \param reader The reader to read from.
         * \param pitch The pitch value.
         */
-       AUD_PitchReader(AUD_Reference<AUD_IReader> reader, float pitch);
+       AUD_PitchReader(boost::shared_ptr<AUD_IReader> reader, float pitch);
 
        virtual AUD_Specs getSpecs() const;
 
index ad01f40469885b93cc7cd0dd56ad54f770b324bc..26bb5615dad39ae182943cfcaffece06b72243b3 100644 (file)
@@ -37,12 +37,12 @@ sample_t AUD_RectifyFactory::rectifyFilter(AUD_CallbackIIRFilterReader* reader,
        return fabs(reader->x(0));
 }
 
-AUD_RectifyFactory::AUD_RectifyFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_RectifyFactory::AUD_RectifyFactory(boost::shared_ptr<AUD_IFactory> factory) :
                AUD_EffectFactory(factory)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_RectifyFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_RectifyFactory::createReader()
 {
-       return new AUD_CallbackIIRFilterReader(getReader(), 1, 1, rectifyFilter);
+       return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 1, 1, rectifyFilter));
 }
index 5ad41d424d95f3ba8eec2b7bd03bbd7b8034768c..eb595e43e4f91035beaa62121998717349c18330 100644 (file)
@@ -48,9 +48,9 @@ public:
         * Creates a new rectify factory.
         * \param factory The input factory.
         */
-       AUD_RectifyFactory(AUD_Reference<AUD_IFactory> factory);
+       AUD_RectifyFactory(boost::shared_ptr<AUD_IFactory> factory);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 
        static sample_t rectifyFilter(AUD_CallbackIIRFilterReader* reader, void* useless);
 };
index 063cbc8818035b65332a0a0650b2d24b2b72bbe6..afb4ad2bec906e32956a1170ca8c75019a2bc41c 100644 (file)
 #include "AUD_ReverseReader.h"
 #include "AUD_Space.h"
 
-AUD_ReverseFactory::AUD_ReverseFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_ReverseFactory::AUD_ReverseFactory(boost::shared_ptr<AUD_IFactory> factory) :
                AUD_EffectFactory(factory)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_ReverseFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_ReverseFactory::createReader()
 {
-       return new AUD_ReverseReader(getReader());
+       return boost::shared_ptr<AUD_IReader>(new AUD_ReverseReader(getReader()));
 }
index e2d75dc560a7c90c959da9929698606d1c5ed090..5b0c9e3c29a55b9373bd4b57123724c3f62024fe 100644 (file)
@@ -48,9 +48,9 @@ public:
         * Creates a new reverse factory.
         * \param factory The input factory.
         */
-       AUD_ReverseFactory(AUD_Reference<AUD_IFactory> factory);
+       AUD_ReverseFactory(boost::shared_ptr<AUD_IFactory> factory);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_REVERSEFACTORY_H__
index 6b454c66d25518f7ab47829b17339915ce9950e5..c0a5962a299b7d98438530c2da4e2e0851716f70 100644 (file)
@@ -34,7 +34,7 @@
 static const char* props_error = "AUD_ReverseReader: The reader has to be "
                                                                 "seekable and a finite length.";
 
-AUD_ReverseReader::AUD_ReverseReader(AUD_Reference<AUD_IReader> reader) :
+AUD_ReverseReader::AUD_ReverseReader(boost::shared_ptr<AUD_IReader> reader) :
                AUD_EffectReader(reader),
                m_length(reader->getLength()),
                m_position(0)
index d1e5179b8ecd2f669c6b7d0d00d6a5080d5c56fd..219047915bd3d6d32f8ef82048d98080cd95fdbf 100644 (file)
@@ -61,7 +61,7 @@ public:
         * \exception AUD_Exception Thrown if the reader specified has an
         *            undeterminable/infinite length or is not seekable.
         */
-       AUD_ReverseReader(AUD_Reference<AUD_IReader> reader);
+       AUD_ReverseReader(boost::shared_ptr<AUD_IReader> reader);
 
        virtual void seek(int position);
        virtual int getLength() const;
index 7aabdb775f6ccf2090187846e3d47a04de16d3d5..4b4dccb6e6bbf7e1688e26a1515cdd1098e77b6c 100644 (file)
@@ -46,7 +46,7 @@ void AUD_SquareFactory::endSquareFilter(float* threshold)
        delete threshold;
 }
 
-AUD_SquareFactory::AUD_SquareFactory(AUD_Reference<AUD_IFactory> factory, float threshold) :
+AUD_SquareFactory::AUD_SquareFactory(boost::shared_ptr<AUD_IFactory> factory, float threshold) :
                AUD_EffectFactory(factory),
                m_threshold(threshold)
 {
@@ -57,10 +57,10 @@ float AUD_SquareFactory::getThreshold() const
        return m_threshold;
 }
 
-AUD_Reference<AUD_IReader> AUD_SquareFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SquareFactory::createReader()
 {
-       return new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
+       return boost::shared_ptr<AUD_IReader>(new AUD_CallbackIIRFilterReader(getReader(), 1, 1,
                                                                                   (doFilterIIR) squareFilter,
                                                                                   (endFilterIIR) endSquareFilter,
-                                                                                  new float(m_threshold));
+                                                                                  new float(m_threshold)));
 }
index 9c0dea25d2b02e7cf8f2f151acf8a337893c5fdd..27e62b6f4ccaaac88eaef224b1be7b2162bc4353 100644 (file)
@@ -54,14 +54,14 @@ public:
         * \param factory The input factory.
         * \param threshold The threshold.
         */
-       AUD_SquareFactory(AUD_Reference<AUD_IFactory> factory, float threshold = 0.0f);
+       AUD_SquareFactory(boost::shared_ptr<AUD_IFactory> factory, float threshold = 0.0f);
 
        /**
         * Returns the threshold.
         */
        float getThreshold() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 
        static sample_t squareFilter(AUD_CallbackIIRFilterReader* reader, float* threshold);
        static void endSquareFilter(float* threshold);
index b58c44b01718f4f404607782bf2bdbf59b243473..7f82233a0b7b0717e65e4effdd88173b9ffe8f2c 100644 (file)
 #include "AUD_SumFactory.h"
 #include "AUD_IIRFilterReader.h"
 
-AUD_SumFactory::AUD_SumFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_SumFactory::AUD_SumFactory(boost::shared_ptr<AUD_IFactory> factory) :
                AUD_EffectFactory(factory)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_SumFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SumFactory::createReader()
 {
        std::vector<float> a, b;
        a.push_back(1);
        a.push_back(-1);
        b.push_back(1);
-       return new AUD_IIRFilterReader(getReader(), b, a);
+       return boost::shared_ptr<AUD_IReader>(new AUD_IIRFilterReader(getReader(), b, a));
 }
index ec17faf3fb29efa65874f6ce3d291178ea9ec792..a916f3509cb420c8b697baf6823a62c5bd3dc99a 100644 (file)
@@ -47,9 +47,9 @@ public:
         * Creates a new sum factory.
         * \param factory The input factory.
         */
-       AUD_SumFactory(AUD_Reference<AUD_IFactory> factory);
+       AUD_SumFactory(boost::shared_ptr<AUD_IFactory> factory);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_SUMFACTORY_H__
index 30c57198c73d6bad3293afcab90022ac3576f88a..3efad37a5b34dfa4f542d28fa339915b262f0ec6 100644 (file)
 #include "AUD_SuperposeFactory.h"
 #include "AUD_SuperposeReader.h"
 
-AUD_SuperposeFactory::AUD_SuperposeFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2) :
+AUD_SuperposeFactory::AUD_SuperposeFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2) :
                m_factory1(factory1), m_factory2(factory2)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_SuperposeFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SuperposeFactory::createReader()
 {
-       AUD_Reference<AUD_IReader> reader1 = m_factory1->createReader();
-       AUD_Reference<AUD_IReader> reader2 = m_factory2->createReader();
+       boost::shared_ptr<AUD_IReader> reader1 = m_factory1->createReader();
+       boost::shared_ptr<AUD_IReader> reader2 = m_factory2->createReader();
 
-       return new AUD_SuperposeReader(reader1, reader2);
+       return boost::shared_ptr<AUD_IReader>(new AUD_SuperposeReader(reader1, reader2));
 }
index 2da8e34496db0b572ceea450181195568658d883..caa0dfb752f4d55e514101299a718dae7335b9c9 100644 (file)
@@ -43,12 +43,12 @@ private:
        /**
         * First played factory.
         */
-       AUD_Reference<AUD_IFactory> m_factory1;
+       boost::shared_ptr<AUD_IFactory> m_factory1;
 
        /**
         * Second played factory.
         */
-       AUD_Reference<AUD_IFactory> m_factory2;
+       boost::shared_ptr<AUD_IFactory> m_factory2;
 
        // hide copy constructor and operator=
        AUD_SuperposeFactory(const AUD_SuperposeFactory&);
@@ -60,9 +60,9 @@ public:
         * \param factory1 The first input factory.
         * \param factory2 The second input factory.
         */
-       AUD_SuperposeFactory(AUD_Reference<AUD_IFactory> factory1, AUD_Reference<AUD_IFactory> factory2);
+       AUD_SuperposeFactory(boost::shared_ptr<AUD_IFactory> factory1, boost::shared_ptr<AUD_IFactory> factory2);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_SUPERPOSEFACTORY_H__
index 535d3590a8f2bfa690a1765415d7e8537de47c4f..294a48b3e7ad170d9da787c4f905620923bac117 100644 (file)
@@ -34,7 +34,7 @@
 static const char* specs_error = "AUD_SuperposeReader: Both readers have to "
                                                                 "have the same specs.";
 
-AUD_SuperposeReader::AUD_SuperposeReader(AUD_Reference<AUD_IReader> reader1, AUD_Reference<AUD_IReader> reader2) :
+AUD_SuperposeReader::AUD_SuperposeReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2) :
        m_reader1(reader1), m_reader2(reader2)
 {
 }
index d0fde13a26771a65a425a70bdbbfb16729f2aa62..a04ab90fe43f2046d81f15f794ad0287c07f9a5a 100644 (file)
@@ -32,7 +32,8 @@
 
 #include "AUD_IReader.h"
 #include "AUD_Buffer.h"
-#include "AUD_Reference.h"
+
+#include <boost/shared_ptr.hpp>
 
 /**
  * This reader plays two readers with the same specs in parallel.
@@ -43,12 +44,12 @@ private:
        /**
         * The first reader.
         */
-       AUD_Reference<AUD_IReader> m_reader1;
+       boost::shared_ptr<AUD_IReader> m_reader1;
 
        /**
         * The second reader.
         */
-       AUD_Reference<AUD_IReader> m_reader2;
+       boost::shared_ptr<AUD_IReader> m_reader2;
 
        /**
         * Buffer used for mixing.
@@ -66,7 +67,7 @@ public:
         * \param reader2 The second reader to read from.
         * \exception AUD_Exception Thrown if the specs from the readers differ.
         */
-       AUD_SuperposeReader(AUD_Reference<AUD_IReader> reader1, AUD_Reference<AUD_IReader> reader2);
+       AUD_SuperposeReader(boost::shared_ptr<AUD_IReader> reader1, boost::shared_ptr<AUD_IReader> reader2);
 
        /**
         * Destroys the reader.
index f5e635eec2d7e843b343240bb7bdf55bb479a92e..4f0e1e425e6991281cb6f92f6d29b751c1cd6443 100644 (file)
@@ -30,7 +30,7 @@
 #include "AUD_VolumeFactory.h"
 #include "AUD_IIRFilterReader.h"
 
-AUD_VolumeFactory::AUD_VolumeFactory(AUD_Reference<AUD_IFactory> factory, float volume) :
+AUD_VolumeFactory::AUD_VolumeFactory(boost::shared_ptr<AUD_IFactory> factory, float volume) :
                AUD_EffectFactory(factory),
                m_volume(volume)
 {
@@ -41,10 +41,10 @@ float AUD_VolumeFactory::getVolume() const
        return m_volume;
 }
 
-AUD_Reference<AUD_IReader> AUD_VolumeFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_VolumeFactory::createReader()
 {
        std::vector<float> a, b;
        a.push_back(1);
        b.push_back(m_volume);
-       return new AUD_IIRFilterReader(getReader(), b, a);
+       return boost::shared_ptr<AUD_IReader>(new AUD_IIRFilterReader(getReader(), b, a));
 }
index b12838373b302ec28f728bb10deebd9a48695a81..6fe779ffb88d7ddaef1ed8cbd6aa62d4c9b5a567 100644 (file)
@@ -55,7 +55,7 @@ public:
         * \param factory The input factory.
         * \param volume The desired volume.
         */
-       AUD_VolumeFactory(AUD_Reference<AUD_IFactory> factory, float volume);
+       AUD_VolumeFactory(boost::shared_ptr<AUD_IFactory> factory, float volume);
 
        /**
         * Returns the volume.
@@ -63,7 +63,7 @@ public:
         */
        float getVolume() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_VOLUMEFACTORY_H__
index a114d8b8a876f4433f4eeb0315892daaa461e92c..371e0007bd31303e1768768a34e29d429beb3b77 100644 (file)
@@ -67,7 +67,7 @@ static const char* queue_error = "AUD_OpenALDevice: Buffer couldn't be "
 static const char* bufferdata_error = "AUD_OpenALDevice: Buffer couldn't be "
                                                                          "filled with data.";
 
-AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, AUD_Reference<AUD_IReader> reader, bool keep) :
+AUD_OpenALDevice::AUD_OpenALHandle::AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, boost::shared_ptr<AUD_IReader> reader, bool keep) :
        m_isBuffered(false), m_reader(reader), m_keep(keep), m_format(format), m_current(0),
        m_eos(false), m_loopcount(0), m_stop(NULL), m_stop_data(NULL), m_status(AUD_STATUS_PLAYING),
        m_device(device)
@@ -130,14 +130,22 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::pause()
 
                if(m_status == AUD_STATUS_PLAYING)
                {
-                       m_device->m_playingSounds.remove(this);
-                       m_device->m_pausedSounds.push_back(this);
+                       for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+                       {
+                               if(it->get() == this)
+                               {
+                                       boost::shared_ptr<AUD_OpenALHandle> This = *it;
 
-                       alSourcePause(m_source);
+                                       m_device->m_playingSounds.erase(it);
+                                       m_device->m_pausedSounds.push_back(This);
 
-                       m_status = AUD_STATUS_PAUSED;
+                                       alSourcePause(m_source);
 
-                       return true;
+                                       m_status = AUD_STATUS_PAUSED;
+
+                                       return true;
+                               }
+                       }
                }
        }
 
@@ -152,12 +160,21 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::resume()
 
                if(m_status == AUD_STATUS_PAUSED)
                {
-                       m_device->m_pausedSounds.remove(this);
-                       m_device->m_playingSounds.push_back(this);
+                       for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+                       {
+                               if(it->get() == this)
+                               {
+                                       boost::shared_ptr<AUD_OpenALHandle> This = *it;
 
-                       m_device->start();
-                       m_status = AUD_STATUS_PLAYING;
-                       return true;
+                                       m_device->m_pausedSounds.erase(it);
+                                       m_device->m_playingSounds.push_back(This);
+
+                                       m_device->start();
+                                       m_status = AUD_STATUS_PLAYING;
+
+                                       return true;
+                               }
+                       }
                }
        }
 
@@ -184,7 +201,7 @@ bool AUD_OpenALDevice::AUD_OpenALHandle::stop()
        {
                if(it->get() == this)
                {
-                       AUD_Reference<AUD_OpenALHandle> This = *it;
+                       boost::shared_ptr<AUD_OpenALHandle> This = *it;
 
                        m_device->m_playingSounds.erase(it);
 
@@ -838,15 +855,15 @@ void AUD_OpenALDevice::start(bool join)
 
 void AUD_OpenALDevice::updateStreams()
 {
-       AUD_Reference<AUD_OpenALHandle> sound;
+       boost::shared_ptr<AUD_OpenALHandle> sound;
 
        int length;
 
        ALint info;
        AUD_DeviceSpecs specs = m_specs;
        ALCenum cerr;
-       std::list<AUD_Reference<AUD_OpenALHandle> > stopSounds;
-       std::list<AUD_Reference<AUD_OpenALHandle> > pauseSounds;
+       std::list<boost::shared_ptr<AUD_OpenALHandle> > stopSounds;
+       std::list<boost::shared_ptr<AUD_OpenALHandle> > pauseSounds;
        AUD_HandleIterator it;
 
        while(1)
@@ -1204,32 +1221,32 @@ bool AUD_OpenALDevice::getFormat(ALenum &format, AUD_Specs specs)
        return valid;
 }
 
-AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_OpenALDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
 {
        AUD_Specs specs = reader->getSpecs();
 
        // check format
        if(specs.channels == AUD_CHANNELS_INVALID)
-               return AUD_Reference<AUD_IHandle>();
+               return boost::shared_ptr<AUD_IHandle>();
 
        if(m_specs.format != AUD_FORMAT_FLOAT32)
-               reader = new AUD_ConverterReader(reader, m_specs);
+               reader = boost::shared_ptr<AUD_IReader>(new AUD_ConverterReader(reader, m_specs));
 
        ALenum format;
 
        if(!getFormat(format, specs))
-               return AUD_Reference<AUD_IHandle>();
+               return boost::shared_ptr<AUD_IHandle>();
 
        AUD_MutexLock lock(*this);
 
        alcSuspendContext(m_context);
 
-       AUD_Reference<AUD_OpenALDevice::AUD_OpenALHandle> sound;
+       boost::shared_ptr<AUD_OpenALDevice::AUD_OpenALHandle> sound;
 
        try
        {
                // create the handle
-               sound = new AUD_OpenALDevice::AUD_OpenALHandle(this, format, reader, keep);
+               sound = boost::shared_ptr<AUD_OpenALDevice::AUD_OpenALHandle>(new AUD_OpenALDevice::AUD_OpenALHandle(this, format, reader, keep));
        }
        catch(AUD_Exception&)
        {
@@ -1244,10 +1261,10 @@ AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IReader> rea
 
        start();
 
-       return AUD_Reference<AUD_IHandle>(sound);
+       return boost::shared_ptr<AUD_IHandle>(sound);
 }
 
-AUD_Reference<AUD_IHandle> AUD_OpenALDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_OpenALDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
 {
        /* AUD_XXX disabled
        AUD_OpenALHandle* sound = NULL;
index 0a409b42462830f3976fb6c194a6ac1f9d8b87a4..d2a4be227bafd5d365bb669f4082432a57bf1cb8 100644 (file)
@@ -58,7 +58,7 @@ private:
                bool m_isBuffered;
 
                /// The reader source.
-               AUD_Reference<AUD_IReader> m_reader;
+               boost::shared_ptr<AUD_IReader> m_reader;
 
                /// Whether to keep the source if end of it is reached.
                bool m_keep;
@@ -105,7 +105,7 @@ private:
                 * \param reader The reader this handle plays.
                 * \param keep Whether to keep the handle alive when the reader ends.
                 */
-               AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, AUD_Reference<AUD_IReader> reader, bool keep);
+               AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, boost::shared_ptr<AUD_IReader> reader, bool keep);
 
                virtual ~AUD_OpenALHandle() {}
                virtual bool pause();
@@ -150,7 +150,7 @@ private:
                virtual bool setConeVolumeOuter(float volume);
        };
 
-       typedef std::list<AUD_Reference<AUD_OpenALHandle> >::iterator AUD_HandleIterator;
+       typedef std::list<boost::shared_ptr<AUD_OpenALHandle> >::iterator AUD_HandleIterator;
 
        /**
         * The OpenAL device handle.
@@ -175,12 +175,12 @@ private:
        /**
         * The list of sounds that are currently playing.
         */
-       std::list<AUD_Reference<AUD_OpenALHandle> > m_playingSounds;
+       std::list<boost::shared_ptr<AUD_OpenALHandle> > m_playingSounds;
 
        /**
         * The list of sounds that are currently paused.
         */
-       std::list<AUD_Reference<AUD_OpenALHandle> > m_pausedSounds;
+       std::list<boost::shared_ptr<AUD_OpenALHandle> > m_pausedSounds;
 
        /**
         * The list of buffered factories.
@@ -255,8 +255,8 @@ public:
        virtual ~AUD_OpenALDevice();
 
        virtual AUD_DeviceSpecs getSpecs() const;
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false);
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false);
        virtual void stopAll();
        virtual void lock();
        virtual void unlock();
index dd58e5a739815d5d3b45a399fcddd1d698c6e937..9beba2eb0a0d6eea9085646496c25b34693e826e 100644 (file)
@@ -90,7 +90,7 @@ static void
 Factory_dealloc(Factory* self)
 {
        if(self->factory)
-               delete reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory);
+               delete reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory);
        Py_XDECREF(self->child_list);
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
@@ -114,7 +114,7 @@ Factory_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
                try
                {
-                       self->factory = new AUD_Reference<AUD_IFactory>(new AUD_FileFactory(filename));
+                       self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
                }
                catch(AUD_Exception& e)
                {
@@ -154,7 +154,7 @@ Factory_sine(PyTypeObject* type, PyObject *args)
        {
                try
                {
-                       self->factory = new AUD_Reference<AUD_IFactory>(new AUD_SinusFactory(frequency, (AUD_SampleRate)rate));
+                       self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SinusFactory(frequency, (AUD_SampleRate)rate));
                }
                catch(AUD_Exception& e)
                {
@@ -193,7 +193,7 @@ Factory_file(PyTypeObject* type, PyObject *args)
        {
                try
                {
-                       self->factory = new AUD_Reference<AUD_IFactory>(new AUD_FileFactory(filename));
+                       self->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
                }
                catch(AUD_Exception& e)
                {
@@ -236,7 +236,7 @@ Factory_lowpass(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LowpassFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), frequency, Q));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_LowpassFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), frequency, Q));
                }
                catch(AUD_Exception& e)
                {
@@ -277,7 +277,7 @@ Factory_delay(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_DelayFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), delay));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_DelayFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), delay));
                }
                catch(AUD_Exception& e)
                {
@@ -321,7 +321,7 @@ Factory_join(Factory* self, PyObject *object)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_DoubleFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(child->factory)));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_DoubleFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(child->factory)));
                }
                catch(AUD_Exception& e)
                {
@@ -364,7 +364,7 @@ Factory_highpass(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_HighpassFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), frequency, Q));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_HighpassFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), frequency, Q));
                }
                catch(AUD_Exception& e)
                {
@@ -405,7 +405,7 @@ Factory_limit(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LimiterFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), start, end));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_LimiterFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), start, end));
                }
                catch(AUD_Exception& e)
                {
@@ -449,7 +449,7 @@ Factory_pitch(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_PitchFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), factor));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_PitchFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), factor));
                }
                catch(AUD_Exception& e)
                {
@@ -491,7 +491,7 @@ Factory_volume(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_VolumeFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), volume));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_VolumeFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), volume));
                }
                catch(AUD_Exception& e)
                {
@@ -534,7 +534,7 @@ Factory_fadein(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), AUD_FADE_IN, start, length));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), AUD_FADE_IN, start, length));
                }
                catch(AUD_Exception& e)
                {
@@ -578,7 +578,7 @@ Factory_fadeout(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), AUD_FADE_OUT, start, length));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), AUD_FADE_OUT, start, length));
                }
                catch(AUD_Exception& e)
                {
@@ -620,7 +620,7 @@ Factory_loop(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LoopFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), loop));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_LoopFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), loop));
                }
                catch(AUD_Exception& e)
                {
@@ -663,7 +663,7 @@ Factory_mix(Factory* self, PyObject *object)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_SuperposeFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(child->factory)));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SuperposeFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(child->factory)));
                }
                catch(AUD_Exception& e)
                {
@@ -696,7 +696,7 @@ Factory_pingpong(Factory* self)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_PingPongFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory)));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_PingPongFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
                }
                catch(AUD_Exception& e)
                {
@@ -735,7 +735,7 @@ Factory_reverse(Factory* self)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_ReverseFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory)));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_ReverseFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
                }
                catch(AUD_Exception& e)
                {
@@ -770,7 +770,7 @@ Factory_buffer(Factory* self)
        {
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_StreamBufferFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory)));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_StreamBufferFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory)));
                }
                catch(AUD_Exception& e)
                {
@@ -812,7 +812,7 @@ Factory_square(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_SquareFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), threshold));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_SquareFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), threshold));
                }
                catch(AUD_Exception& e)
                {
@@ -915,7 +915,7 @@ Factory_filter(Factory* self, PyObject *args)
 
                try
                {
-                       parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_IIRFilterFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), b, a));
+                       parent->factory = new boost::shared_ptr<AUD_IFactory>(new AUD_IIRFilterFactory(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(self->factory), b, a));
                }
                catch(AUD_Exception& e)
                {
@@ -1039,7 +1039,7 @@ static void
 Handle_dealloc(Handle* self)
 {
        if(self->handle)
-               delete reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle);
+               delete reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle);
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
@@ -1054,7 +1054,7 @@ Handle_pause(Handle *self)
 {
        try
        {
-               return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->pause());
+               return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->pause());
        }
        catch(AUD_Exception& e)
        {
@@ -1074,7 +1074,7 @@ Handle_resume(Handle *self)
 {
        try
        {
-               return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->resume());
+               return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->resume());
        }
        catch(AUD_Exception& e)
        {
@@ -1095,7 +1095,7 @@ Handle_stop(Handle *self)
 {
        try
        {
-               return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->stop());
+               return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->stop());
        }
        catch(AUD_Exception& e)
        {
@@ -1125,7 +1125,7 @@ Handle_get_position(Handle *self, void* nothing)
 {
        try
        {
-               return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getPosition());
+               return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getPosition());
        }
        catch(AUD_Exception& e)
        {
@@ -1144,7 +1144,7 @@ Handle_set_position(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->seek(position))
+               if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->seek(position))
                        return 0;
                PyErr_SetString(AUDError, "Couldn't seek the sound!");
        }
@@ -1170,7 +1170,7 @@ Handle_get_keep(Handle *self, void* nothing)
 {
        try
        {
-               return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getKeep());
+               return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getKeep());
        }
        catch(AUD_Exception& e)
        {
@@ -1192,7 +1192,7 @@ Handle_set_keep(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setKeep(keep))
+               if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setKeep(keep))
                        return 0;
                PyErr_SetString(AUDError, "Couldn't set keep of the sound!");
        }
@@ -1212,7 +1212,7 @@ Handle_get_status(Handle *self, void* nothing)
 {
        try
        {
-               return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getStatus());
+               return PyBool_FromLong((long)(*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getStatus());
        }
        catch(AUD_Exception& e)
        {
@@ -1229,7 +1229,7 @@ Handle_get_volume(Handle *self, void* nothing)
 {
        try
        {
-               return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getVolume());
+               return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getVolume());
        }
        catch(AUD_Exception& e)
        {
@@ -1248,7 +1248,7 @@ Handle_set_volume(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setVolume(volume))
+               if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setVolume(volume))
                        return 0;
                PyErr_SetString(AUDError, "Couldn't set the sound volume!");
        }
@@ -1268,7 +1268,7 @@ Handle_get_pitch(Handle *self, void* nothing)
 {
        try
        {
-               return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getPitch());
+               return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getPitch());
        }
        catch(AUD_Exception& e)
        {
@@ -1287,7 +1287,7 @@ Handle_set_pitch(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setPitch(pitch))
+               if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setPitch(pitch))
                        return 0;
                PyErr_SetString(AUDError, "Couldn't set the sound pitch!");
        }
@@ -1307,7 +1307,7 @@ Handle_get_loop_count(Handle *self, void* nothing)
 {
        try
        {
-               return Py_BuildValue("i", (*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->getLoopCount());
+               return Py_BuildValue("i", (*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->getLoopCount());
        }
        catch(AUD_Exception& e)
        {
@@ -1326,7 +1326,7 @@ Handle_set_loop_count(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               if((*reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle))->setLoopCount(loops))
+               if((*reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle))->setLoopCount(loops))
                        return 0;
                PyErr_SetString(AUDError, "Couldn't set the loop count!");
        }
@@ -1346,7 +1346,7 @@ Handle_get_location(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        AUD_Vector3 v = handle->getSourceLocation();
@@ -1375,7 +1375,7 @@ Handle_set_location(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        AUD_Vector3 location(x, y, z);
@@ -1402,7 +1402,7 @@ Handle_get_velocity(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        AUD_Vector3 v = handle->getSourceVelocity();
@@ -1431,7 +1431,7 @@ Handle_set_velocity(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        AUD_Vector3 velocity(x, y, z);
@@ -1458,7 +1458,7 @@ Handle_get_orientation(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        AUD_Quaternion o = handle->getSourceOrientation();
@@ -1487,7 +1487,7 @@ Handle_set_orientation(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        AUD_Quaternion orientation(w, x, y, z);
@@ -1514,7 +1514,7 @@ Handle_get_relative(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return PyBool_FromLong((long)handle->isRelative());
@@ -1545,7 +1545,7 @@ Handle_set_relative(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setRelative(relative))
@@ -1572,7 +1572,7 @@ Handle_get_volume_minimum(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getVolumeMinimum());
@@ -1600,7 +1600,7 @@ Handle_set_volume_minimum(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setVolumeMinimum(volume))
@@ -1627,7 +1627,7 @@ Handle_get_volume_maximum(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getVolumeMaximum());
@@ -1655,7 +1655,7 @@ Handle_set_volume_maximum(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setVolumeMaximum(volume))
@@ -1683,7 +1683,7 @@ Handle_get_distance_reference(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getDistanceReference());
@@ -1711,7 +1711,7 @@ Handle_set_distance_reference(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setDistanceReference(distance))
@@ -1739,7 +1739,7 @@ Handle_get_distance_maximum(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getDistanceMaximum());
@@ -1767,7 +1767,7 @@ Handle_set_distance_maximum(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setDistanceMaximum(distance))
@@ -1795,7 +1795,7 @@ Handle_get_attenuation(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getAttenuation());
@@ -1823,7 +1823,7 @@ Handle_set_attenuation(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setAttenuation(factor))
@@ -1856,7 +1856,7 @@ Handle_get_cone_angle_inner(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getConeAngleInner());
@@ -1884,7 +1884,7 @@ Handle_set_cone_angle_inner(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setConeAngleInner(angle))
@@ -1911,7 +1911,7 @@ Handle_get_cone_angle_outer(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getConeAngleOuter());
@@ -1939,7 +1939,7 @@ Handle_set_cone_angle_outer(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setConeAngleOuter(angle))
@@ -1966,7 +1966,7 @@ Handle_get_cone_volume_outer(Handle *self, void* nothing)
 {
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        return Py_BuildValue("f", handle->getConeVolumeOuter());
@@ -1994,7 +1994,7 @@ Handle_set_cone_volume_outer(Handle *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<AUD_Reference<AUD_IHandle>*>(self->handle)->get());
+               AUD_I3DHandle* handle = dynamic_cast<AUD_I3DHandle*>(reinterpret_cast<boost::shared_ptr<AUD_IHandle>*>(self->handle)->get());
                if(handle)
                {
                        if(handle->setConeVolumeOuter(volume))
@@ -2104,7 +2104,7 @@ static void
 Device_dealloc(Device* self)
 {
        if(self->device)
-               delete reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device);
+               delete reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device);
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
@@ -2147,21 +2147,21 @@ Device_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                        {
                        case AUD_DEVICE_NULL:
                                (void)specs; /* quiet warning when others disabled */
-                               self->device = new AUD_Reference<AUD_IDevice>(new AUD_NULLDevice());
+                               self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
                                break;
                        case AUD_DEVICE_OPENAL:
 #ifdef WITH_OPENAL
-                               self->device = new AUD_Reference<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
+                               self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
 #endif
                                break;
                        case AUD_DEVICE_SDL:
 #ifdef WITH_SDL
-                               self->device = new AUD_Reference<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
+                               self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
 #endif
                                break;
                        case AUD_DEVICE_JACK:
 #ifdef WITH_JACK
-                               self->device = new AUD_Reference<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
+                               self->device = new boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize));
 #endif
                                break;
                        case AUD_DEVICE_READ:
@@ -2236,7 +2236,7 @@ Device_play(Device *self, PyObject *args, PyObject *kwds)
        {
                try
                {
-                       handle->handle = new AUD_Reference<AUD_IHandle>((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->play(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->factory), keep));
+                       handle->handle = new boost::shared_ptr<AUD_IHandle>((*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->play(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(sound->factory), keep));
                }
                catch(AUD_Exception& e)
                {
@@ -2258,7 +2258,7 @@ Device_stopAll(Device *self)
 {
        try
        {
-               (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->stopAll();
+               (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->stopAll();
                Py_RETURN_NONE;
        }
        catch(AUD_Exception& e)
@@ -2284,7 +2284,7 @@ Device_lock(Device *self)
 {
        try
        {
-               (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->lock();
+               (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->lock();
                Py_RETURN_NONE;
        }
        catch(AUD_Exception& e)
@@ -2304,7 +2304,7 @@ Device_unlock(Device *self)
 {
        try
        {
-               (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->unlock();
+               (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->unlock();
                Py_RETURN_NONE;
        }
        catch(AUD_Exception& e)
@@ -2338,7 +2338,7 @@ Device_get_rate(Device *self, void* nothing)
 {
        try
        {
-               AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs();
+               AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
                return Py_BuildValue("d", specs.rate);
        }
        catch(AUD_Exception& e)
@@ -2356,7 +2356,7 @@ Device_get_format(Device *self, void* nothing)
 {
        try
        {
-               AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs();
+               AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
                return Py_BuildValue("i", specs.format);
        }
        catch(AUD_Exception& e)
@@ -2374,7 +2374,7 @@ Device_get_channels(Device *self, void* nothing)
 {
        try
        {
-               AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs();
+               AUD_DeviceSpecs specs = (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getSpecs();
                return Py_BuildValue("i", specs.channels);
        }
        catch(AUD_Exception& e)
@@ -2392,7 +2392,7 @@ Device_get_volume(Device *self, void* nothing)
 {
        try
        {
-               return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getVolume());
+               return Py_BuildValue("f", (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->getVolume());
        }
        catch(AUD_Exception& e)
        {
@@ -2411,7 +2411,7 @@ Device_set_volume(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->setVolume(volume);
+               (*reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device))->setVolume(volume);
                return 0;
        }
        catch(AUD_Exception& e)
@@ -2429,7 +2429,7 @@ Device_get_listener_location(Device *self, void* nothing)
 {
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        AUD_Vector3 v = device->getListenerLocation();
@@ -2458,7 +2458,7 @@ Device_set_listener_location(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        AUD_Vector3 location(x, y, z);
@@ -2484,7 +2484,7 @@ Device_get_listener_velocity(Device *self, void* nothing)
 {
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        AUD_Vector3 v = device->getListenerVelocity();
@@ -2513,7 +2513,7 @@ Device_set_listener_velocity(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        AUD_Vector3 velocity(x, y, z);
@@ -2539,7 +2539,7 @@ Device_get_listener_orientation(Device *self, void* nothing)
 {
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        AUD_Quaternion o = device->getListenerOrientation();
@@ -2568,7 +2568,7 @@ Device_set_listener_orientation(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        AUD_Quaternion orientation(w, x, y, z);
@@ -2595,7 +2595,7 @@ Device_get_speed_of_sound(Device *self, void* nothing)
 {
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        return Py_BuildValue("f", device->getSpeedOfSound());
@@ -2623,7 +2623,7 @@ Device_set_speed_of_sound(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        device->setSpeedOfSound(speed);
@@ -2651,7 +2651,7 @@ Device_get_doppler_factor(Device *self, void* nothing)
 {
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        return Py_BuildValue("f", device->getDopplerFactor());
@@ -2679,7 +2679,7 @@ Device_set_doppler_factor(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        device->setDopplerFactor(factor);
@@ -2705,7 +2705,7 @@ Device_get_distance_model(Device *self, void* nothing)
 {
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        return Py_BuildValue("i", int(device->getDistanceModel()));
@@ -2733,7 +2733,7 @@ Device_set_distance_model(Device *self, PyObject *args, void* nothing)
 
        try
        {
-               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get());
+               AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<boost::shared_ptr<AUD_IDevice>*>(self->device)->get());
                if(device)
                {
                        device->setDistanceModel(AUD_DistanceModel(model));
index 50c81db46dd77f0f424ec45910d85bf487cc271f..e2b6efacc96567cf3cc2a1d1551750576aa22539 100644 (file)
@@ -3,7 +3,7 @@
 Import ('env')
 
 sources = env.Glob('intern/*.cpp') + env.Glob('FX/*.cpp')
-incs = '. intern FX ' + env['BF_PTHREADS_INC']
+incs = '. intern FX ' + env['BF_PTHREADS_INC'] + ' ' + env['BF_BOOST_INC']
 defs = []
 
 if env['WITH_BF_FFMPEG']:
index c4c384f054c3b8599990806ddc5158393c7825a9..403c367fccc634f6145c56b632696f6128635578 100644 (file)
@@ -46,10 +46,10 @@ AUD_FFMPEGFactory::AUD_FFMPEGFactory(const data_t* buffer, int size) :
        memcpy(m_buffer->getBuffer(), buffer, size);
 }
 
-AUD_Reference<AUD_IReader> AUD_FFMPEGFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_FFMPEGFactory::createReader()
 {
-       if(m_buffer.isNull())
-               return new AUD_FFMPEGReader(m_filename);
+       if(m_buffer.get())
+               return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_buffer));
        else
-               return new AUD_FFMPEGReader(m_buffer);
+               return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_filename));
 }
index 349f55dd7db307f5ce625e0dbf114fe400b48c14..23d0f07ed0b6fbbbe0be1ba08dd4ba0dd2f7a1dd 100644 (file)
 #define __AUD_FFMPEGFACTORY_H__
 
 #include "AUD_IFactory.h"
-#include "AUD_Reference.h"
 #include "AUD_Buffer.h"
 
 #include <string>
+#include <boost/shared_ptr.hpp>
 
 /**
  * This factory reads a sound file via ffmpeg.
@@ -52,7 +52,7 @@ private:
        /**
         * The buffer to read from.
         */
-       AUD_Reference<AUD_Buffer> m_buffer;
+       boost::shared_ptr<AUD_Buffer> m_buffer;
 
        // hide copy constructor and operator=
        AUD_FFMPEGFactory(const AUD_FFMPEGFactory&);
@@ -72,7 +72,7 @@ public:
         */
        AUD_FFMPEGFactory(const data_t* buffer, int size);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_FFMPEGFACTORY_H__
index 28a14a9cfc74a8ba3c60dbf3df3c2464c99dcf03..0a3d0f8e85ad8528bc4cf705b7d41131f4655f8e 100644 (file)
@@ -197,7 +197,7 @@ AUD_FFMPEGReader::AUD_FFMPEGReader(std::string filename) :
 static const char* streamopen_error = "AUD_FFMPEGReader: Stream couldn't be "
                                                                          "opened.";
 
-AUD_FFMPEGReader::AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer) :
+AUD_FFMPEGReader::AUD_FFMPEGReader(boost::shared_ptr<AUD_Buffer> buffer) :
                m_pkgbuf(AVCODEC_MAX_AUDIO_FRAME_SIZE<<1),
                m_membuffer(buffer),
                m_membufferpos(0)
index 2b354b0b2a1a1c124c86bda7ca557481178b2644..d5d9fb300ff2c07e31f157bd12b10ef961cd10ed 100644 (file)
 
 #include "AUD_ConverterFunctions.h"
 #include "AUD_IReader.h"
-#include "AUD_Reference.h"
 #include "AUD_Buffer.h"
 
 #include <string>
+#include <boost/shared_ptr.hpp>
 
 struct AVCodecContext;
 extern "C" {
@@ -99,7 +99,7 @@ private:
        /**
         * The memory file to read from.
         */
-       AUD_Reference<AUD_Buffer> m_membuffer;
+       boost::shared_ptr<AUD_Buffer> m_membuffer;
 
        /**
         * The buffer to read with.
@@ -143,7 +143,7 @@ public:
         * \exception AUD_Exception Thrown if the buffer specified cannot be read
         *                          with ffmpeg.
         */
-       AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer);
+       AUD_FFMPEGReader(boost::shared_ptr<AUD_Buffer> buffer);
 
        /**
         * Destroys the reader and closes the file.
index dbff70095ad0806ed32dfaea26d380a15b426084..b9d819ff774dc1d36ac4d43ac00175f9080f7df6 100644 (file)
@@ -33,7 +33,7 @@
 
 #include <cstring>
 
-AUD_BufferReader::AUD_BufferReader(AUD_Reference<AUD_Buffer> buffer,
+AUD_BufferReader::AUD_BufferReader(boost::shared_ptr<AUD_Buffer> buffer,
                                                                   AUD_Specs specs) :
        m_position(0), m_buffer(buffer), m_specs(specs)
 {
index 0e8c5de9a9de00e7a392a1f97c895d9bc331b8b1..d0c90ce7e61e509d0cc272e4f4faa7964587cfdd 100644 (file)
 #define __AUD_BUFFERREADER_H__
 
 #include "AUD_IReader.h"
-#include "AUD_Reference.h"
 class AUD_Buffer;
 
+#include <boost/shared_ptr.hpp>
+
 /**
  * This class represents a simple reader from a buffer that exists in memory.
  * \warning Notice that the buffer used for creating the reader must exist as
@@ -50,7 +51,7 @@ private:
        /**
         * The buffer that is read.
         */
-       AUD_Reference<AUD_Buffer> m_buffer;
+       boost::shared_ptr<AUD_Buffer> m_buffer;
 
        /**
         * The specification of the sample data in the buffer.
@@ -67,7 +68,7 @@ public:
         * \param buffer The buffer to read from.
         * \param specs The specification of the sample data in the buffer.
         */
-       AUD_BufferReader(AUD_Reference<AUD_Buffer> buffer, AUD_Specs specs);
+       AUD_BufferReader(boost::shared_ptr<AUD_Buffer> buffer, AUD_Specs specs);
 
        virtual bool isSeekable() const;
        virtual void seek(int position);
index a1da90b073ef195d9fdee696a53caab9023ada79..3150c1af01169cbde16479dd3dac7d5f1c3645fb 100644 (file)
@@ -91,10 +91,10 @@ extern "C" {
 
 #include <cassert>
 
-typedef AUD_Reference<AUD_IFactory> AUD_Sound;
-typedef AUD_Reference<AUD_ReadDevice> AUD_Device;
-typedef AUD_Reference<AUD_IHandle> AUD_Handle;
-typedef AUD_Reference<AUD_SequencerEntry> AUD_SEntry;
+typedef boost::shared_ptr<AUD_IFactory> AUD_Sound;
+typedef boost::shared_ptr<AUD_ReadDevice> AUD_Device;
+typedef boost::shared_ptr<AUD_IHandle> AUD_Handle;
+typedef boost::shared_ptr<AUD_SequencerEntry> AUD_SEntry;
 
 #define AUD_CAPI_IMPLEMENTATION
 #include "AUD_C-API.h"
@@ -103,7 +103,7 @@ typedef AUD_Reference<AUD_SequencerEntry> AUD_SEntry;
 #  define NULL (void *)0
 #endif
 
-static AUD_Reference<AUD_IDevice> AUD_device;
+static boost::shared_ptr<AUD_IDevice> AUD_device;
 static AUD_I3DDevice *AUD_3ddevice;
 
 void AUD_initOnce()
@@ -115,25 +115,25 @@ void AUD_initOnce()
 
 int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
 {
-       AUD_Reference<AUD_IDevice> dev;
+       boost::shared_ptr<AUD_IDevice> dev;
 
-       if (!AUD_device.isNull()) {
+       if (AUD_device.get()) {
                AUD_exit();
        }
 
        try {
                switch(device) {
                case AUD_NULL_DEVICE:
-                       dev = new AUD_NULLDevice();
+                       dev = boost::shared_ptr<AUD_IDevice>(new AUD_NULLDevice());
                        break;
 #ifdef WITH_SDL
                case AUD_SDL_DEVICE:
-                       dev = new AUD_SDLDevice(specs, buffersize);
+                       dev = boost::shared_ptr<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize));
                        break;
 #endif
 #ifdef WITH_OPENAL
                case AUD_OPENAL_DEVICE:
-                       dev = new AUD_OpenALDevice(specs, buffersize);
+                       dev = boost::shared_ptr<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize));
                        break;
 #endif
 #ifdef WITH_JACK
@@ -147,7 +147,7 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
                        else
                        {
 #endif
-                               dev = new AUD_JackDevice("Blender", specs, buffersize);
+                               dev = boost::shared_ptr<AUD_IDevice>(new AUD_JackDevice("Blender", specs, buffersize));
                                break;
 #ifdef __APPLE__
                        }
@@ -170,17 +170,17 @@ int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
 
 void AUD_exit()
 {
-       AUD_device = AUD_Reference<AUD_IDevice>();
+       AUD_device = boost::shared_ptr<AUD_IDevice>();
        AUD_3ddevice = NULL;
 }
 
 #ifdef WITH_PYTHON
 static PyObject *AUD_getCDevice(PyObject *self)
 {
-       if (!AUD_device.isNull()) {
+       if (AUD_device.get()) {
                Device *device = (Device *)Device_empty();
                if (device != NULL) {
-                       device->device = new AUD_Reference<AUD_IDevice>(AUD_device);
+                       device->device = new boost::shared_ptr<AUD_IDevice>(AUD_device);
                        return (PyObject *)device;
                }
        }
@@ -206,12 +206,12 @@ static PyObject *AUD_getSoundFromPointer(PyObject *self, PyObject *args)
 
        if (PyArg_Parse(args, "l:_sound_from_pointer", &lptr)) {
                if (lptr) {
-                       AUD_Reference<AUD_IFactory>* factory = (AUD_Reference<AUD_IFactory>*) sound_get_factory((void *) lptr);
+                       boost::shared_ptr<AUD_IFactory>* factory = (boost::shared_ptr<AUD_IFactory>*) sound_get_factory((void *) lptr);
 
                        if (factory) {
                                Factory *obj = (Factory *)Factory_empty();
                                if (obj) {
-                                       obj->factory = new AUD_Reference<AUD_IFactory>(*factory);
+                                       obj->factory = new boost::shared_ptr<AUD_IFactory>(*factory);
                                        return (PyObject *) obj;
                                }
                        }
@@ -246,7 +246,7 @@ void *AUD_getPythonFactory(AUD_Sound *sound)
        if (sound) {
                Factory *obj = (Factory *) Factory_empty();
                if (obj) {
-                       obj->factory = new AUD_Reference<AUD_IFactory>(*sound);
+                       obj->factory = new boost::shared_ptr<AUD_IFactory>(*sound);
                        return (PyObject *) obj;
                }
        }
@@ -261,7 +261,7 @@ AUD_Sound *AUD_getPythonSound(void *sound)
        if (!factory)
                return NULL;
 
-       return new AUD_Reference<AUD_IFactory>(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(factory->factory));
+       return new boost::shared_ptr<AUD_IFactory>(*reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(factory->factory));
 }
 
 #endif
@@ -286,9 +286,9 @@ AUD_SoundInfo AUD_getInfo(AUD_Sound *sound)
        info.length = 0.0f;
 
        try {
-               AUD_Reference<AUD_IReader> reader = (*sound)->createReader();
+               boost::shared_ptr<AUD_IReader> reader = (*sound)->createReader();
 
-               if (!reader.isNull()) {
+               if (reader.get()) {
                        info.specs = reader->getSpecs();
                        info.length = reader->getLength() / (float) info.specs.rate;
                }
@@ -432,7 +432,7 @@ AUD_Handle *AUD_play(AUD_Sound *sound, int keep)
        assert(sound);
        try {
                AUD_Handle handle = AUD_device->play(*sound, keep);
-               if (!handle.isNull()) {
+               if (handle.get()) {
                        return new AUD_Handle(handle);
                }
        }
@@ -552,9 +552,9 @@ int AUD_setDistanceModel(AUD_DistanceModel model)
 int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                AUD_Vector3 v(location[0], location[1], location[2]);
                return h->setSourceLocation(v);
        }
@@ -565,9 +565,9 @@ int AUD_setSourceLocation(AUD_Handle *handle, const float location[3])
 int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                AUD_Vector3 v(velocity[0], velocity[1], velocity[2]);
                return h->setSourceVelocity(v);
        }
@@ -578,9 +578,9 @@ int AUD_setSourceVelocity(AUD_Handle *handle, const float velocity[3])
 int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                AUD_Quaternion q(orientation[3], orientation[0], orientation[1], orientation[2]);
                return h->setSourceOrientation(q);
        }
@@ -591,9 +591,9 @@ int AUD_setSourceOrientation(AUD_Handle *handle, const float orientation[4])
 int AUD_setRelative(AUD_Handle *handle, int relative)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setRelative(relative);
        }
 
@@ -603,9 +603,9 @@ int AUD_setRelative(AUD_Handle *handle, int relative)
 int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setVolumeMaximum(volume);
        }
 
@@ -615,9 +615,9 @@ int AUD_setVolumeMaximum(AUD_Handle *handle, float volume)
 int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setVolumeMinimum(volume);
        }
 
@@ -627,9 +627,9 @@ int AUD_setVolumeMinimum(AUD_Handle *handle, float volume)
 int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setDistanceMaximum(distance);
        }
 
@@ -639,9 +639,9 @@ int AUD_setDistanceMaximum(AUD_Handle *handle, float distance)
 int AUD_setDistanceReference(AUD_Handle *handle, float distance)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setDistanceReference(distance);
        }
 
@@ -651,9 +651,9 @@ int AUD_setDistanceReference(AUD_Handle *handle, float distance)
 int AUD_setAttenuation(AUD_Handle *handle, float factor)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setAttenuation(factor);
        }
 
@@ -663,9 +663,9 @@ int AUD_setAttenuation(AUD_Handle *handle, float factor)
 int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setConeAngleOuter(angle);
        }
 
@@ -675,9 +675,9 @@ int AUD_setConeAngleOuter(AUD_Handle *handle, float angle)
 int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setConeAngleInner(angle);
        }
 
@@ -687,9 +687,9 @@ int AUD_setConeAngleInner(AUD_Handle *handle, float angle)
 int AUD_setConeVolumeOuter(AUD_Handle *handle, float volume)
 {
        assert(handle);
-       AUD_Reference<AUD_I3DHandle> h(*handle);
+       boost::shared_ptr<AUD_I3DHandle> h = boost::dynamic_pointer_cast<AUD_I3DHandle>(*handle);
 
-       if (!h.isNull()) {
+       if (h.get()) {
                return h->setConeVolumeOuter(volume);
        }
 
@@ -734,7 +734,7 @@ AUD_Handle *AUD_playDevice(AUD_Device *device, AUD_Sound *sound, float seek)
 
        try {
                AUD_Handle handle = (*device)->play(*sound);
-               if (!handle.isNull()) {
+               if (handle.get()) {
                        handle->seek(seek);
                        return new AUD_Handle(handle);
                }
@@ -793,38 +793,38 @@ float *AUD_readSoundBuffer(const char *filename, float low, float high,
        AUD_DeviceSpecs specs;
        specs.channels = AUD_CHANNELS_MONO;
        specs.rate = (AUD_SampleRate)samplerate;
-       AUD_Reference<AUD_IFactory> sound;
+       boost::shared_ptr<AUD_IFactory> sound;
 
-       AUD_Reference<AUD_IFactory> file = new AUD_FileFactory(filename);
+       boost::shared_ptr<AUD_IFactory> file = boost::shared_ptr<AUD_IFactory>(new AUD_FileFactory(filename));
 
        int position = 0;
 
        try {
-               AUD_Reference<AUD_IReader> reader = file->createReader();
+               boost::shared_ptr<AUD_IReader> reader = file->createReader();
 
                AUD_SampleRate rate = reader->getSpecs().rate;
 
-               sound = new AUD_ChannelMapperFactory(file, specs);
+               sound = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(file, specs));
 
                if (high < rate)
-                       sound = new AUD_LowpassFactory(sound, high);
+                       sound = boost::shared_ptr<AUD_IFactory>(new AUD_LowpassFactory(sound, high));
                if (low > 0)
-                       sound = new AUD_HighpassFactory(sound, low);
+                       sound = boost::shared_ptr<AUD_IFactory>(new AUD_HighpassFactory(sound, low));
 
-               sound = new AUD_EnvelopeFactory(sound, attack, release, threshold, 0.1f);
-               sound = new AUD_LinearResampleFactory(sound, specs);
+               sound = boost::shared_ptr<AUD_IFactory>(new AUD_EnvelopeFactory(sound, attack, release, threshold, 0.1f));
+               sound = boost::shared_ptr<AUD_IFactory>(new AUD_LinearResampleFactory(sound, specs));
 
                if (square)
-                       sound = new AUD_SquareFactory(sound, sthreshold);
+                       sound = boost::shared_ptr<AUD_IFactory>(new AUD_SquareFactory(sound, sthreshold));
 
                if (accumulate)
-                       sound = new AUD_AccumulatorFactory(sound, additive);
+                       sound = boost::shared_ptr<AUD_IFactory>(new AUD_AccumulatorFactory(sound, additive));
                else if (additive)
-                       sound = new AUD_SumFactory(sound);
+                       sound = boost::shared_ptr<AUD_IFactory>(new AUD_SumFactory(sound));
 
                reader = sound->createReader();
 
-               if (reader.isNull())
+               if (!reader.get())
                        return NULL;
 
                int len;
@@ -856,14 +856,14 @@ static void pauseSound(AUD_Handle *handle)
 
 AUD_Handle *AUD_pauseAfter(AUD_Handle *handle, float seconds)
 {
-       AUD_Reference<AUD_IFactory> silence = new AUD_SilenceFactory;
-       AUD_Reference<AUD_IFactory> limiter = new AUD_LimiterFactory(silence, 0, seconds);
+       boost::shared_ptr<AUD_IFactory> silence = boost::shared_ptr<AUD_IFactory>(new AUD_SilenceFactory);
+       boost::shared_ptr<AUD_IFactory> limiter = boost::shared_ptr<AUD_IFactory>(new AUD_LimiterFactory(silence, 0, seconds));
 
        AUD_MutexLock lock(*AUD_device);
 
        try {
                AUD_Handle handle2 = AUD_device->play(limiter);
-               if (!handle2.isNull()) {
+               if (handle2.get()) {
                        handle2->setStopCallback((stopCallback)pauseSound, handle);
                        return new AUD_Handle(handle2);
                }
@@ -881,7 +881,7 @@ AUD_Sound *AUD_createSequencer(float fps, int muted)
        AUD_Specs specs;
        specs.channels = AUD_CHANNELS_STEREO;
        specs.rate = AUD_RATE_44100;
-       AUD_Sound *sequencer = new AUD_Sound(AUD_Reference<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
+       AUD_Sound *sequencer = new AUD_Sound(boost::shared_ptr<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
        return sequencer;
 }
 
@@ -1070,7 +1070,7 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe
        specs.channels = AUD_CHANNELS_MONO;
        specs.format = AUD_FORMAT_INVALID;
 
-       AUD_Reference<AUD_IReader> reader = AUD_ChannelMapperFactory(*sound, specs).createReader();
+       boost::shared_ptr<AUD_IReader> reader = AUD_ChannelMapperFactory(*sound, specs).createReader();
 
        specs.specs = reader->getSpecs();
        int len;
@@ -1124,7 +1124,7 @@ int AUD_readSound(AUD_Sound *sound, sample_t *buffer, int length, int samples_pe
 
 AUD_Sound *AUD_copy(AUD_Sound *sound)
 {
-       return new AUD_Reference<AUD_IFactory>(*sound);
+       return new boost::shared_ptr<AUD_IFactory>(*sound);
 }
 
 void AUD_freeHandle(AUD_Handle *handle)
@@ -1176,9 +1176,9 @@ const char *AUD_mixdown(AUD_Sound *sound, unsigned int start, unsigned int lengt
                AUD_SequencerFactory *f = dynamic_cast<AUD_SequencerFactory *>(sound->get());
 
                f->setSpecs(specs.specs);
-               AUD_Reference<AUD_IReader> reader = f->createQualityReader();
+               boost::shared_ptr<AUD_IReader> reader = f->createQualityReader();
                reader->seek(start);
-               AUD_Reference<AUD_IWriter> writer = AUD_FileWriter::createWriter(filename, specs, format, codec, bitrate);
+               boost::shared_ptr<AUD_IWriter> writer = AUD_FileWriter::createWriter(filename, specs, format, codec, bitrate);
                AUD_FileWriter::writeReader(reader, writer, length, buffersize);
 
                return NULL;
@@ -1196,7 +1196,7 @@ const char *AUD_mixdown_per_channel(AUD_Sound *sound, unsigned int start, unsign
 
                f->setSpecs(specs.specs);
 
-               std::vector<AUD_Reference<AUD_IWriter> > writers;
+               std::vector<boost::shared_ptr<AUD_IWriter> > writers;
 
                int channels = specs.channels;
                specs.channels = AUD_CHANNELS_MONO;
@@ -1220,7 +1220,7 @@ const char *AUD_mixdown_per_channel(AUD_Sound *sound, unsigned int start, unsign
                        writers.push_back(AUD_FileWriter::createWriter(stream.str(), specs, format, codec, bitrate));
                }
 
-               AUD_Reference<AUD_IReader> reader = f->createQualityReader();
+               boost::shared_ptr<AUD_IReader> reader = f->createQualityReader();
                reader->seek(start);
                AUD_FileWriter::writeReader(reader, writers, length, buffersize);
 
@@ -1242,7 +1242,7 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f
                dynamic_cast<AUD_SequencerFactory *>(sequencer->get())->setSpecs(specs.specs);
 
                AUD_Handle handle = device->play(*sequencer);
-               if (!handle.isNull()) {
+               if (handle.get()) {
                        handle->seek(start);
                }
 
@@ -1254,7 +1254,7 @@ AUD_Device *AUD_openMixdownDevice(AUD_DeviceSpecs specs, AUD_Sound *sequencer, f
        }
 }
 
-AUD_Reference<AUD_IDevice> AUD_getDevice()
+boost::shared_ptr<AUD_IDevice> AUD_getDevice()
 {
        return AUD_device;
 }
index 75e3456de9a21d0b62a1b633c5ebf4c4b3983f4c..9c6611fe04a84a1fd626b9c8b6892325fb0e1c80 100644 (file)
@@ -755,7 +755,7 @@ extern AUD_Sound *AUD_getPythonSound(void *sound);
 #ifdef __cplusplus
 }
 
-#include "AUD_Reference.h"
+#include <boost/shared_ptr.hpp>
 class AUD_IDevice;
 class AUD_I3DDevice;
 
@@ -763,7 +763,7 @@ class AUD_I3DDevice;
  * Returns the current playback device.
  * \return The playback device.
  */
-AUD_Reference<AUD_IDevice> AUD_getDevice();
+boost::shared_ptr<AUD_IDevice> AUD_getDevice();
 
 /**
  * Returns the current playback 3D device.
index 7743ccf46da80043e7475c56d4c1b2ae2dc61d10..f4ba5d05ff0df2b4af46c81e0f989c4863869442 100644 (file)
 
 #include <cstring>
 
-AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_ChannelMapperFactory::AUD_ChannelMapperFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                                   AUD_DeviceSpecs specs) :
                AUD_MixerFactory(factory, specs)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_ChannelMapperFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_ChannelMapperFactory::createReader()
 {
-       AUD_Reference<AUD_IReader> reader = getReader();
-       return new AUD_ChannelMapperReader(reader, m_specs.channels);
+       boost::shared_ptr<AUD_IReader> reader = getReader();
+       return boost::shared_ptr<AUD_IReader>(new AUD_ChannelMapperReader(reader, m_specs.channels));
 }
index b60a32d55105cffb4873a5e87af8f3037aca72bd..611b5041c39129c503cbab047ef3486adebceddf 100644 (file)
@@ -49,9 +49,9 @@ public:
         * \param factory The input factory.
         * \param specs The target specifications.
         */
-       AUD_ChannelMapperFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+       AUD_ChannelMapperFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_CHANNELMAPPERFACTORY_H__
index 7a179c6f94aad9dd4447aef192b48048106bad8b..8b983d5c43dc5480093cc746f66bf70b8bc2ae14 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "AUD_ChannelMapperReader.h"
 
-AUD_ChannelMapperReader::AUD_ChannelMapperReader(AUD_Reference<AUD_IReader> reader,
+AUD_ChannelMapperReader::AUD_ChannelMapperReader(boost::shared_ptr<AUD_IReader> reader,
                                                                                                 AUD_Channels channels) :
                AUD_EffectReader(reader), m_target_channels(channels),
        m_source_channels(AUD_CHANNELS_INVALID), m_mapping(0), m_map_size(0), m_mono_angle(0)
index 32adb05811525dfd14eb3c9d6eda00c1552e92d4..b122b070d29e46ef6de82de732124eb7787f4c49 100644 (file)
@@ -110,7 +110,7 @@ public:
         * \param reader The reader to map.
         * \param mapping The mapping specification as two dimensional float array.
         */
-       AUD_ChannelMapperReader(AUD_Reference<AUD_IReader> reader, AUD_Channels channels);
+       AUD_ChannelMapperReader(boost::shared_ptr<AUD_IReader> reader, AUD_Channels channels);
 
        /**
         * Destroys the reader.
index b61f9bc194c8108a4526137e7b256a0fc0ab6fa0..7cbf64f169772eb5a0ad28eb2074f5c5d64ebdaf 100644 (file)
 #include "AUD_ConverterFactory.h"
 #include "AUD_ConverterReader.h"
 
-AUD_ConverterFactory::AUD_ConverterFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_ConverterFactory::AUD_ConverterFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                   AUD_DeviceSpecs specs) :
                AUD_MixerFactory(factory, specs)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_ConverterFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_ConverterFactory::createReader()
 {
-       AUD_Reference<AUD_IReader> reader = getReader();
+       boost::shared_ptr<AUD_IReader> reader = getReader();
 
        if(m_specs.format != AUD_FORMAT_FLOAT32)
-               reader = new AUD_ConverterReader(reader, m_specs);
+               reader = boost::shared_ptr<AUD_IReader>(new AUD_ConverterReader(reader, m_specs));
 
        return reader;
 }
index 3211b607517d4f02be82e51cb470b5079902f2f7..2c9c82d235b7761fd2780bd54e33fc5431db6f46 100644 (file)
@@ -49,9 +49,9 @@ public:
         * \param factory The input factory.
         * \param specs The target specifications.
         */
-       AUD_ConverterFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+       AUD_ConverterFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_CONVERTERFACTORY_H__
index 63178f316b2ffde3026f8ecc81cd4f20d95da485..a90a54670e8de52152596390d866b7fc3d282023 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AUD_ConverterReader.h"
 
-AUD_ConverterReader::AUD_ConverterReader(AUD_Reference<AUD_IReader> reader,
+AUD_ConverterReader::AUD_ConverterReader(boost::shared_ptr<AUD_IReader> reader,
                                                                                 AUD_DeviceSpecs specs) :
        AUD_EffectReader(reader),
        m_format(specs.format)
index 2dedbd8918067a2018a5dd8e144d41659203639a..987b7c70279b3358d57b126e00a54d52aa142d29 100644 (file)
@@ -65,7 +65,7 @@ public:
         * \param reader The reader to convert.
         * \param specs The target specification.
         */
-       AUD_ConverterReader(AUD_Reference<AUD_IReader> reader, AUD_DeviceSpecs specs);
+       AUD_ConverterReader(boost::shared_ptr<AUD_IReader> reader, AUD_DeviceSpecs specs);
 
        virtual void read(int& length, bool& eos, sample_t* buffer);
 };
index a27acff19cf63464b28223fbddee409583321b22..f9353db667717f86c95c51196648db6a0f85ed34 100644 (file)
@@ -56,15 +56,15 @@ AUD_FileFactory::AUD_FileFactory(const data_t* buffer, int size) :
 
 static const char* read_error = "AUD_FileFactory: File couldn't be read.";
 
-AUD_Reference<AUD_IReader> AUD_FileFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_FileFactory::createReader()
 {
 #ifdef WITH_SNDFILE
        try
        {
-               if(m_buffer.isNull())
-                       return new AUD_SndFileReader(m_filename);
+               if(m_buffer.get())
+                       return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_buffer));
                else
-                       return new AUD_SndFileReader(m_buffer);
+                       return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_filename));
        }
        catch(AUD_Exception&) {}
 #endif
@@ -72,10 +72,10 @@ AUD_Reference<AUD_IReader> AUD_FileFactory::createReader()
 #ifdef WITH_FFMPEG
        try
        {
-               if(m_buffer.isNull())
-                       return new AUD_FFMPEGReader(m_filename);
+               if(m_buffer.get())
+                       return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_buffer));
                else
-                       return new AUD_FFMPEGReader(m_buffer);
+                       return boost::shared_ptr<AUD_IReader>(new AUD_FFMPEGReader(m_filename));
        }
        catch(AUD_Exception&) {}
 #endif
index 4ea4a9392e9b2700daba823b7329d78e1b5b369a..35c8db731b482bce7a87d5a50c76c27f63fa1a83 100644 (file)
 #define __AUD_FILEFACTORY_H__
 
 #include "AUD_IFactory.h"
-#include "AUD_Reference.h"
 #include "AUD_Buffer.h"
 
 #include <string>
+#include <boost/shared_ptr.hpp>
 
 /**
  * This factory tries to read a sound file via all available file readers.
@@ -50,7 +50,7 @@ private:
        /**
         * The buffer to read from.
         */
-       AUD_Reference<AUD_Buffer> m_buffer;
+       boost::shared_ptr<AUD_Buffer> m_buffer;
 
        // hide copy constructor and operator=
        AUD_FileFactory(const AUD_FileFactory&);
@@ -70,7 +70,7 @@ public:
         */
        AUD_FileFactory(const data_t* buffer, int size);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_FILEFACTORY_H__
index f74021acad19a45d328c6f75f7071bcf1d449b92..e3072fa82e00146ab10dad4a6b33bc6614adbe0a 100644 (file)
 
 static const char* write_error = "AUD_FileWriter: File couldn't be written.";
 
-AUD_Reference<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD_DeviceSpecs specs,
+boost::shared_ptr<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD_DeviceSpecs specs,
                                                                                                                AUD_Container format, AUD_Codec codec, unsigned int bitrate)
 {
 #ifdef WITH_SNDFILE
        try
        {
-               return new AUD_SndFileWriter(filename, specs, format, codec, bitrate);
+               return boost::shared_ptr<AUD_IWriter>(new AUD_SndFileWriter(filename, specs, format, codec, bitrate));
        }
        catch(AUD_Exception&) {}
 #endif
@@ -57,7 +57,7 @@ AUD_Reference<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD
 #ifdef WITH_FFMPEG
        try
        {
-               return new AUD_FFMPEGWriter(filename, specs, format, codec, bitrate);
+               return boost::shared_ptr<AUD_IWriter>(new AUD_FFMPEGWriter(filename, specs, format, codec, bitrate));
        }
        catch(AUD_Exception&) {}
 #endif
@@ -65,7 +65,7 @@ AUD_Reference<AUD_IWriter> AUD_FileWriter::createWriter(std::string filename,AUD
        AUD_THROW(AUD_ERROR_SPECS, write_error);
 }
 
-void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_IWriter> writer, unsigned int length, unsigned int buffersize)
+void AUD_FileWriter::writeReader(boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_IWriter> writer, unsigned int length, unsigned int buffersize)
 {
        AUD_Buffer buffer(buffersize * AUD_SAMPLE_SIZE(writer->getSpecs()));
        sample_t* buf = buffer.getBuffer();
@@ -94,7 +94,7 @@ void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, AUD_Referenc
        }
 }
 
-void AUD_FileWriter::writeReader(AUD_Reference<AUD_IReader> reader, std::vector<AUD_Reference<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize)
+void AUD_FileWriter::writeReader(boost::shared_ptr<AUD_IReader> reader, std::vector<boost::shared_ptr<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize)
 {
        AUD_Buffer buffer(buffersize * AUD_SAMPLE_SIZE(reader->getSpecs()));
        AUD_Buffer buffer2(buffersize * sizeof(sample_t));
index 385aba5ef45867c15c405f3f79be129e2df41d72..da52c7e0fb2933923a5aa6ac815015a80f7860c9 100644 (file)
@@ -32,8 +32,7 @@
 
 #include <string>
 #include <vector>
-
-#include "AUD_Reference.h"
+#include <boost/shared_ptr.hpp>
 
 #include "AUD_IWriter.h"
 #include "AUD_IReader.h"
@@ -59,7 +58,7 @@ public:
         * \param bitrate The bitrate for encoding.
         * \return The writer to write data to.
         */
-       static AUD_Reference<AUD_IWriter> createWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
+       static boost::shared_ptr<AUD_IWriter> createWriter(std::string filename, AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate);
 
        /**
         * Writes a reader to a writer.
@@ -68,7 +67,7 @@ public:
         * \param length How many samples should be transfered.
         * \param buffersize How many samples should be transfered at once.
         */
-       static void writeReader(AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_IWriter> writer, unsigned int length, unsigned int buffersize);
+       static void writeReader(boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_IWriter> writer, unsigned int length, unsigned int buffersize);
 
        /**
         * Writes a reader to several writers.
@@ -77,7 +76,7 @@ public:
         * \param length How many samples should be transfered.
         * \param buffersize How many samples should be transfered at once.
         */
-       static void writeReader(AUD_Reference<AUD_IReader> reader, std::vector<AUD_Reference<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize);
+       static void writeReader(boost::shared_ptr<AUD_IReader> reader, std::vector<boost::shared_ptr<AUD_IWriter> >& writers, unsigned int length, unsigned int buffersize);
 };
 
 #endif //__AUD_FILEWRITER_H__
index f4d6635e79a164bd295f02f4f8d916f6766b0e5f..a7f9a985ce4f7ff851ca0ece707012e125101d3e 100644 (file)
 #define __AUD_IDEVICE_H__
 
 #include "AUD_Space.h"
-#include "AUD_Reference.h"
 #include "AUD_IFactory.h"
 #include "AUD_IReader.h"
 #include "AUD_IHandle.h"
 #include "AUD_ILockable.h"
 
+#include <boost/shared_ptr.hpp>
+
 /**
  * This class represents an output device for sound sources.
  * Output devices may be several backends such as plattform independand like
@@ -68,7 +69,7 @@ public:
         * \exception AUD_Exception Thrown if there's an unexpected (from the
         *            device side) error during creation of the reader.
         */
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false)=0;
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false)=0;
 
        /**
         * Plays a sound source.
@@ -80,7 +81,7 @@ public:
         * \exception AUD_Exception Thrown if there's an unexpected (from the
         *            device side) error during creation of the reader.
         */
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false)=0;
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false)=0;
 
        /**
         * Stops all playing sounds.
index 95b4643072e4096e9555cabab4891a5db0f3e33e..75103963c68fe538cc43744823f043ffdc08e786 100644 (file)
 #define __AUD_IFACTORY_H__
 
 #include "AUD_Space.h"
-#include "AUD_Reference.h"
 #include "AUD_IReader.h"
 
+#include <boost/shared_ptr.hpp>
+
 /**
  * This class represents a type of sound source and saves the necessary values
  * for it. It is able to create a reader that is actually usable for playback
@@ -54,7 +55,7 @@ public:
         * \exception AUD_Exception An exception may be thrown if there has been
         *            a more unexpected error during reader creation.
         */
-       virtual AUD_Reference<AUD_IReader> createReader()=0;
+       virtual boost::shared_ptr<AUD_IReader> createReader()=0;
 };
 
 #endif //__AUD_IFACTORY_H__
index 21aae6b0547d14e88ed92c3f9e089c62e316bea7..188960f986f4b8e4bafa553ef450ca51471f79b7 100644 (file)
 #include "AUD_JOSResampleFactory.h"
 #include "AUD_JOSResampleReader.h"
 
-AUD_JOSResampleFactory::AUD_JOSResampleFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_JOSResampleFactory::AUD_JOSResampleFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                                         AUD_DeviceSpecs specs) :
                AUD_MixerFactory(factory, specs)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_JOSResampleFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_JOSResampleFactory::createReader()
 {
-       return new AUD_JOSResampleReader(getReader(), m_specs.specs);
+       return boost::shared_ptr<AUD_IReader>(new AUD_JOSResampleReader(getReader(), m_specs.specs));
 }
index 6d18150d85267dbdae1b950e867ef6c95d90d9d8..b6c2961c88a5a1750f40006323da25de0108e9a1 100644 (file)
@@ -48,9 +48,9 @@ public:
         * \param factory The input factory.
         * \param specs The target specifications.
         */
-       AUD_JOSResampleFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+       AUD_JOSResampleFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_JOSRESAMPLEFACTORY_H__
index 0f7a038c88e43e6ec9dd7ea3b9abc28460dd0c06..62fab48272bf1fff4c0d5836b8cf402a5482870a 100644 (file)
@@ -68,7 +68,7 @@ static inline int lrint(double d)
 #define fp_rest(x) (x & ((1 << SHIFT_BITS) - 1))
 #define fp_rest_to_double(x) fp_to_double(fp_rest(x))
 
-AUD_JOSResampleReader::AUD_JOSResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs) :
+AUD_JOSResampleReader::AUD_JOSResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs) :
        AUD_ResampleReader(reader, specs.rate),
        m_channels(AUD_CHANNELS_INVALID),
        m_n(0),
index 94524c1db3e6f719076b2cb424e9d7472b6fb279..fb68e4dc9f5c9a503033abb1cd0141a5a92da7b3 100644 (file)
@@ -123,7 +123,7 @@ public:
         * \param reader The reader to mix.
         * \param specs The target specification.
         */
-       AUD_JOSResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs);
+       AUD_JOSResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs);
 
        virtual void seek(int position);
        virtual int getLength() const;
index 7f602599b7af5c5e192f88d8ec9f280b624e0446..cd573f1047cd49d85832cef13324b30ab321da37 100644 (file)
 #include "AUD_LinearResampleFactory.h"
 #include "AUD_LinearResampleReader.h"
 
-AUD_LinearResampleFactory::AUD_LinearResampleFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_LinearResampleFactory::AUD_LinearResampleFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                                         AUD_DeviceSpecs specs) :
                AUD_MixerFactory(factory, specs)
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_LinearResampleFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_LinearResampleFactory::createReader()
 {
-       return new AUD_LinearResampleReader(getReader(), m_specs.specs);
+       return boost::shared_ptr<AUD_IReader>(new AUD_LinearResampleReader(getReader(), m_specs.specs));
 }
index 7d9efa01d2ddcb5243a2df4ce5a7c1803c1a0c11..ceb29ef2edd390323e3a8cd9e0b7c71ec9dc049f 100644 (file)
@@ -48,9 +48,9 @@ public:
         * \param factory The input factory.
         * \param specs The target specifications.
         */
-       AUD_LinearResampleFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+       AUD_LinearResampleFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_LINEARRESAMPLEFACTORY_H__
index aff62d7c3aa53379a229e286116890cda83a2251..6aa0faed8638443cdda8d1769cc21810d6c4a01a 100644 (file)
@@ -34,7 +34,7 @@
 
 #define CC m_channels + channel
 
-AUD_LinearResampleReader::AUD_LinearResampleReader(AUD_Reference<AUD_IReader> reader,
+AUD_LinearResampleReader::AUD_LinearResampleReader(boost::shared_ptr<AUD_IReader> reader,
                                                                                                   AUD_Specs specs) :
        AUD_ResampleReader(reader, specs.rate),
        m_channels(reader->getSpecs().channels),
index 4f6d422f772f474142334ac726b1e5bf40cb57bd..9beea251c070226143544dbb1097ed3022e24190 100644 (file)
@@ -74,7 +74,7 @@ public:
         * \param reader The reader to mix.
         * \param specs The target specification.
         */
-       AUD_LinearResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs);
+       AUD_LinearResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_Specs specs);
 
        virtual void seek(int position);
        virtual int getLength() const;
index 0de9b7fc7dc5caf8f7e923d87709fdcb26e8c974..3dd03b0a3fe7525fa15d5c7ea733535879db998b 100644 (file)
 
 #include "AUD_ConverterFunctions.h"
 #include "AUD_Buffer.h"
-#include "AUD_Reference.h"
 class AUD_IReader;
 
+#include <boost/shared_ptr.hpp>
+
 /**
  * This abstract class is able to mix audiosignals with same channel count
  * and sample rate and convert it to a specific output format.
index 95a7291d3eba409c2b9c234bed71cb6a63249c16..f3f00ea2cb6c566cadaa77373fb2fec29179c880 100644 (file)
 #include "AUD_MixerFactory.h"
 #include "AUD_IReader.h"
 
-AUD_Reference<AUD_IReader> AUD_MixerFactory::getReader() const
+boost::shared_ptr<AUD_IReader> AUD_MixerFactory::getReader() const
 {
        return m_factory->createReader();
 }
 
-AUD_MixerFactory::AUD_MixerFactory(AUD_Reference<AUD_IFactory> factory,
+AUD_MixerFactory::AUD_MixerFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                   AUD_DeviceSpecs specs) :
        m_specs(specs), m_factory(factory)
 {
@@ -46,7 +46,7 @@ AUD_DeviceSpecs AUD_MixerFactory::getSpecs() const
        return m_specs;
 }
 
-AUD_Reference<AUD_IFactory> AUD_MixerFactory::getFactory() const
+boost::shared_ptr<AUD_IFactory> AUD_MixerFactory::getFactory() const
 {
        return m_factory;
 }
index d65eb8ef6ae1b91cce4137273a7d741da5bd45ff..1d2b6a4cc9113fb849a28612b907011e3f42e806 100644 (file)
@@ -46,7 +46,7 @@ protected:
        /**
         * If there is no reader it is created out of this factory.
         */
-       AUD_Reference<AUD_IFactory> m_factory;
+       boost::shared_ptr<AUD_IFactory> m_factory;
 
        /**
         * Returns the reader created out of the factory.
@@ -54,7 +54,7 @@ protected:
         * classes.
         * \return The reader to mix.
         */
-       AUD_Reference<AUD_IReader> getReader() const;
+       boost::shared_ptr<AUD_IReader> getReader() const;
 
 public:
        /**
@@ -62,7 +62,7 @@ public:
         * \param factory The factory to create the readers to mix out of.
         * \param specs The target specification.
         */
-       AUD_MixerFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
+       AUD_MixerFactory(boost::shared_ptr<AUD_IFactory> factory, AUD_DeviceSpecs specs);
 
        /**
         * Returns the target specification for resampling.
@@ -73,7 +73,7 @@ public:
         * Returns the saved factory.
         * \return The factory.
         */
-       AUD_Reference<AUD_IFactory> getFactory() const;
+       boost::shared_ptr<AUD_IFactory> getFactory() const;
 };
 
 #endif //__AUD_MIXERFACTORY_H__
index f390971c6867c16ce466767acc8990f3df530a27..98a0d324c61ac2350427373aeabe03603052f007 100644 (file)
@@ -127,14 +127,14 @@ AUD_DeviceSpecs AUD_NULLDevice::getSpecs() const
        return specs;
 }
 
-AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_NULLDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
 {
-       return new AUD_NULLHandle();
+       return boost::shared_ptr<AUD_IHandle>(new AUD_NULLHandle());
 }
 
-AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_NULLDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
 {
-       return new AUD_NULLHandle();
+       return boost::shared_ptr<AUD_IHandle>(new AUD_NULLHandle());
 }
 
 void AUD_NULLDevice::stopAll()
index ee97b151ebeb5939c11eeb796554b31e13aef9fe..ae1435bbeeaeb93b5ce9c0f5239d1e5a151d6d88 100644 (file)
@@ -72,8 +72,8 @@ public:
        virtual ~AUD_NULLDevice();
 
        virtual AUD_DeviceSpecs getSpecs() const;
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false);
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false);
        virtual void stopAll();
        virtual void lock();
        virtual void unlock();
diff --git a/intern/audaspace/intern/AUD_Reference.h b/intern/audaspace/intern/AUD_Reference.h
deleted file mode 100644 (file)
index 5a1aa94..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * Copyright 2009-2011 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 General Public License as published by
- * the Free Software Foundation; either version 2 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Audaspace; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file audaspace/intern/AUD_Reference.h
- *  \ingroup audaspaceintern
- */
-
-#ifndef __AUD_REFERENCE_H__
-#define __AUD_REFERENCE_H__
-
-#include <map>
-#include <cstddef>
-#include <pthread.h>
-
-// #define MEM_DEBUG
-
-#ifdef MEM_DEBUG
-#include <iostream>
-#include <typeinfo>
-#endif
-
-/**
- * This class handles the reference counting.
- */
-class AUD_ReferenceHandler
-{
-private:
-       /**
-        * Saves the reference counts.
-        */
-       static std::map<void*, unsigned int> m_references;
-       static pthread_mutex_t m_mutex;
-       static bool m_mutex_initialised;
-
-public:
-
-       static pthread_mutex_t* getMutex();
-
-       /**
-        * Reference increment.
-        * \param reference The reference.
-        */
-       static inline void incref(void* reference)
-       {
-               if(!reference)
-                       return;
-
-               std::map<void*, unsigned int>::iterator result = m_references.find(reference);
-               if(result != m_references.end())
-               {
-                       m_references[reference]++;
-               }
-               else
-               {
-                       m_references[reference] = 1;
-               }
-       }
-
-       /**
-        * Reference decrement.
-        * \param reference The reference.
-        * \return Whether the reference has to be deleted.
-        */
-       static inline bool decref(void* reference)
-       {
-               if(!reference)
-                       return false;
-
-               if(!--m_references[reference])
-               {
-                       m_references.erase(reference);
-                       return true;
-               }
-               return false;
-       }
-};
-
-template <class T>
-/**
- * This class provides reference counting functionality.
- */
-class AUD_Reference
-{
-private:
-       /// The reference.
-       T* m_reference;
-       void* m_original;
-public:
-       /**
-        * Creates a new reference counter.
-        * \param reference The reference.
-        */
-       template <class U>
-       AUD_Reference(U* reference)
-       {
-               pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-               m_original = reference;
-               m_reference = dynamic_cast<T*>(reference);
-               AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
-               if(m_reference != NULL)
-                       std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
-               pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-       }
-
-       AUD_Reference()
-       {
-               m_original = NULL;
-               m_reference = NULL;
-       }
-
-       /**
-        * Copies an AUD_Reference object.
-        * \param ref The AUD_Reference object to copy.
-        */
-       AUD_Reference(const AUD_Reference& ref)
-       {
-               pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-               m_original = ref.m_original;
-               m_reference = ref.m_reference;
-               AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
-               if(m_reference != NULL)
-                       std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
-               pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-       }
-
-       template <class U>
-       explicit AUD_Reference(const AUD_Reference<U>& ref)
-       {
-               pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-               m_original = ref.get();
-               m_reference = dynamic_cast<T*>(ref.get());
-               AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
-               if(m_reference != NULL)
-                       std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
-               pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-       }
-
-       /**
-        * Destroys a AUD_Reference object, if there's no furthere reference on the
-        * reference, it is destroyed as well.
-        */
-       ~AUD_Reference()
-       {
-               pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-#ifdef MEM_DEBUG
-               if(m_reference != NULL)
-                       std::cerr << "-" << typeid(*m_reference).name() << std::endl;
-#endif
-               if(AUD_ReferenceHandler::decref(m_original))
-               {
-                       pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-                       delete m_reference;
-               }
-               else
-               {
-                       pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-               }
-       }
-
-       /**
-        * Assigns an AUD_Reference to this object.
-        * \param ref The AUD_Reference object to assign.
-        */
-       AUD_Reference& operator=(const AUD_Reference& ref)
-       {
-               if(&ref == this)
-                       return *this;
-
-               pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-
-#ifdef MEM_DEBUG
-               if(m_reference != NULL)
-                       std::cerr << "-" << typeid(*m_reference).name() << std::endl;
-#endif
-               if(AUD_ReferenceHandler::decref(m_original))
-               {
-                       pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-                       delete m_reference;
-                       pthread_mutex_lock(AUD_ReferenceHandler::getMutex());
-               }
-
-               m_original = ref.m_original;
-               m_reference = ref.m_reference;
-               AUD_ReferenceHandler::incref(m_original);
-#ifdef MEM_DEBUG
-               if(m_reference != NULL)
-                       std::cerr << "+" << typeid(*m_reference).name() << std::endl;
-#endif
-
-               pthread_mutex_unlock(AUD_ReferenceHandler::getMutex());
-
-               return *this;
-       }
-
-       /**
-        * Returns whether the reference is NULL.
-        */
-       inline bool isNull() const
-       {
-               return m_reference == NULL;
-       }
-
-       /**
-        * Returns the reference.
-        */
-       inline T* get() const
-       {
-               return m_reference;
-       }
-
-       /**
-        * Returns the original pointer.
-        */
-       inline void* getOriginal() const
-       {
-               return m_original;
-       }
-
-       /**
-        * Returns the reference.
-        */
-       inline T& operator*() const
-       {
-               return *m_reference;
-       }
-
-       /**
-        * Returns the reference.
-        */
-       inline T* operator->() const
-       {
-               return m_reference;
-       }
-};
-
-template<class T, class U>
-inline bool operator==(const AUD_Reference<T>& a, const AUD_Reference<U>& b)
-{
-       return a.getOriginal() == b.getOriginal();
-}
-
-template<class T, class U>
-inline bool operator!=(const AUD_Reference<T>& a, const AUD_Reference<U>& b)
-{
-       return a.getOriginal() != b.getOriginal();
-}
-
-#endif // __AUD_REFERENCE_H__
index 514d790be0962016cabd54d4319e032f95a65dad..4b247ffd862f49f0c6534615c7709793572003bf 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "AUD_ResampleReader.h"
 
-AUD_ResampleReader::AUD_ResampleReader(AUD_Reference<AUD_IReader> reader, AUD_SampleRate rate) :
+AUD_ResampleReader::AUD_ResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_SampleRate rate) :
        AUD_EffectReader(reader), m_rate(rate)
 {
 }
index c423326489d6fe8eb21a867a4e00b4c6d72134bc..7e21989bfa8999da2ece2d9d777e9d55b315f383 100644 (file)
@@ -47,7 +47,7 @@ protected:
         * \param reader The reader to mix.
         * \param rate The target sampling rate.
         */
-       AUD_ResampleReader(AUD_Reference<AUD_IReader> reader, AUD_SampleRate rate);
+       AUD_ResampleReader(boost::shared_ptr<AUD_IReader> reader, AUD_SampleRate rate);
 
 public:
        /**
diff --git a/intern/audaspace/intern/AUD_Sequencer.cpp b/intern/audaspace/intern/AUD_Sequencer.cpp
new file mode 100644 (file)
index 0000000..58e8f68
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2009-2011 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 General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Audaspace; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file audaspace/intern/AUD_Sequencer.cpp
+ *  \ingroup audaspaceintern
+ */
+
+
+#include "AUD_Sequencer.h"
+#include "AUD_SequencerReader.h"
+#include "AUD_3DMath.h"
+#include "AUD_MutexLock.h"
+
+AUD_Sequencer::AUD_Sequencer(AUD_Specs specs, float fps, bool muted) :
+       m_specs(specs),
+       m_status(0),
+       m_entry_status(0),
+       m_id(0),
+       m_muted(muted),
+       m_fps(fps),
+       m_speed_of_sound(434),
+       m_doppler_factor(1),
+       m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
+       m_location(3),
+       m_orientation(4)
+{
+       AUD_Quaternion q;
+       m_orientation.write(q.get());
+       float f = 1;
+       m_volume.write(&f);
+
+       pthread_mutexattr_t attr;
+       pthread_mutexattr_init(&attr);
+       pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+       pthread_mutex_init(&m_mutex, &attr);
+
+       pthread_mutexattr_destroy(&attr);
+}
+
+AUD_Sequencer::~AUD_Sequencer()
+{
+       pthread_mutex_destroy(&m_mutex);
+}
+
+void AUD_Sequencer::lock()
+{
+       pthread_mutex_lock(&m_mutex);
+}
+
+void AUD_Sequencer::unlock()
+{
+       pthread_mutex_unlock(&m_mutex);
+}
+
+void AUD_Sequencer::setSpecs(AUD_Specs specs)
+{
+       AUD_MutexLock lock(*this);
+
+       m_specs = specs;
+       m_status++;
+}
+
+void AUD_Sequencer::setFPS(float fps)
+{
+       AUD_MutexLock lock(*this);
+
+       m_fps = fps;
+}
+
+void AUD_Sequencer::mute(bool muted)
+{
+       AUD_MutexLock lock(*this);
+
+       m_muted = muted;
+}
+
+bool AUD_Sequencer::getMute() const
+{
+       return m_muted;
+}
+
+float AUD_Sequencer::getSpeedOfSound() const
+{
+       return m_speed_of_sound;
+}
+
+void AUD_Sequencer::setSpeedOfSound(float speed)
+{
+       AUD_MutexLock lock(*this);
+
+       m_speed_of_sound = speed;
+       m_status++;
+}
+
+float AUD_Sequencer::getDopplerFactor() const
+{
+       return m_doppler_factor;
+}
+
+void AUD_Sequencer::setDopplerFactor(float factor)
+{
+       AUD_MutexLock lock(*this);
+
+       m_doppler_factor = factor;
+       m_status++;
+}
+
+AUD_DistanceModel AUD_Sequencer::getDistanceModel() const
+{
+       return m_distance_model;
+}
+
+void AUD_Sequencer::setDistanceModel(AUD_DistanceModel model)
+{
+       AUD_MutexLock lock(*this);
+
+       m_distance_model = model;
+       m_status++;
+}
+
+AUD_AnimateableProperty* AUD_Sequencer::getAnimProperty(AUD_AnimateablePropertyType type)
+{
+       switch(type)
+       {
+       case AUD_AP_VOLUME:
+               return &m_volume;
+       case AUD_AP_LOCATION:
+               return &m_location;
+       case AUD_AP_ORIENTATION:
+               return &m_orientation;
+       default:
+               return NULL;
+       }
+}
+
+boost::shared_ptr<AUD_SequencerEntry> AUD_Sequencer::add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip)
+{
+       AUD_MutexLock lock(*this);
+
+       boost::shared_ptr<AUD_SequencerEntry> entry = boost::shared_ptr<AUD_SequencerEntry>(new AUD_SequencerEntry(sound, begin, end, skip, m_id++));
+
+       m_entries.push_front(entry);
+       m_entry_status++;
+
+       return entry;
+}
+
+void AUD_Sequencer::remove(boost::shared_ptr<AUD_SequencerEntry> entry)
+{
+       AUD_MutexLock lock(*this);
+
+       m_entries.remove(entry);
+       m_entry_status++;
+}
diff --git a/intern/audaspace/intern/AUD_Sequencer.h b/intern/audaspace/intern/AUD_Sequencer.h
new file mode 100644 (file)
index 0000000..9fdf537
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2009-2011 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 General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Audaspace; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file audaspace/intern/AUD_Sequencer.h
+ *  \ingroup audaspaceintern
+ */
+
+
+#ifndef __AUD_SEQUENCER_H__
+#define __AUD_SEQUENCER_H__
+
+#include "AUD_AnimateableProperty.h"
+#include "AUD_IFactory.h"
+#include "AUD_ILockable.h"
+
+#include <list>
+#include <pthread.h>
+
+class AUD_SequencerEntry;
+
+/**
+ * This class represents sequenced entries to play a sound scene.
+ */
+class AUD_Sequencer : public AUD_ILockable
+{
+       friend class AUD_SequencerReader;
+private:
+       /// The target specification.
+       AUD_Specs m_specs;
+
+       /// The status of the sequence. Changes every time a non-animated parameter changes.
+       int m_status;
+
+       /// The entry status. Changes every time an entry is removed or added.
+       int m_entry_status;
+
+       /// The next unused ID for the entries.
+       int m_id;
+
+       /// The sequenced entries.
+       std::list<boost::shared_ptr<AUD_SequencerEntry> > m_entries;
+
+       /// Whether the whole scene is muted.
+       bool m_muted;
+
+       /// The FPS of the scene.
+       float m_fps;
+
+       /// Speed of Sound.
+       float m_speed_of_sound;
+
+       /// Doppler factor.
+       float m_doppler_factor;
+
+       /// Distance model.
+       AUD_DistanceModel m_distance_model;
+
+       /// The animated volume.
+       AUD_AnimateableProperty m_volume;
+
+       /// The animated listener location.
+       AUD_AnimateableProperty m_location;
+
+       /// The animated listener orientation.
+       AUD_AnimateableProperty m_orientation;
+
+       /// The mutex for locking.
+       pthread_mutex_t m_mutex;
+
+       // hide copy constructor and operator=
+       AUD_Sequencer(const AUD_Sequencer&);
+       AUD_Sequencer& operator=(const AUD_Sequencer&);
+
+public:
+       /**
+        * Creates a new sound scene.
+        * \param specs The output audio data specification.
+        * \param fps The FPS of the scene.
+        * \param muted Whether the whole scene is muted.
+        */
+       AUD_Sequencer(AUD_Specs specs, float fps, bool muted);
+       ~AUD_Sequencer();
+
+       /**
+        * Locks the sequence.
+        */
+       virtual void lock();
+
+       /**
+        * Unlocks the previously locked sequence.
+        */
+       virtual void unlock();
+
+       /**
+        * Sets the audio output specification.
+        * \param specs The new specification.
+        */
+       void setSpecs(AUD_Specs specs);
+
+       /**
+        * Sets the scene's FPS.
+        * \param fps The new FPS.
+        */
+       void setFPS(float fps);
+
+       /**
+        * Sets the muting state of the scene.
+        * \param muted Whether the scene is muted.
+        */
+       void mute(bool muted);
+
+       /**
+        * Retrieves the muting state of the scene.
+        * \return Whether the scene is muted.
+        */
+       bool getMute() const;
+
+       /**
+        * Retrieves the speed of sound.
+        * This value is needed for doppler effect calculation.
+        * \return The speed of sound.
+        */
+       float getSpeedOfSound() const;
+
+       /**
+        * Sets the speed of sound.
+        * This value is needed for doppler effect calculation.
+        * \param speed The new speed of sound.
+        */
+       void setSpeedOfSound(float speed);
+
+       /**
+        * Retrieves the doppler factor.
+        * This value is a scaling factor for the velocity vectors of sources and
+        * listener which is used while calculating the doppler effect.
+        * \return The doppler factor.
+        */
+       float getDopplerFactor() const;
+
+       /**
+        * Sets the doppler factor.
+        * This value is a scaling factor for the velocity vectors of sources and
+        * listener which is used while calculating the doppler effect.
+        * \param factor The new doppler factor.
+        */
+       void setDopplerFactor(float factor);
+
+       /**
+        * Retrieves the distance model.
+        * \return The distance model.
+        */
+       AUD_DistanceModel getDistanceModel() const;
+
+       /**
+        * Sets the distance model.
+        * \param model distance model.
+        */
+       void setDistanceModel(AUD_DistanceModel model);
+
+       /**
+        * Retrieves one of the animated properties of the sequence.
+        * \param type Which animated property to retrieve.
+        * \return A pointer to the animated property, valid as long as the
+        *         sequence is.
+        */
+       AUD_AnimateableProperty* getAnimProperty(AUD_AnimateablePropertyType type);
+
+       /**
+        * Adds a new entry to the scene.
+        * \param sound The sound this entry should play.
+        * \param begin The start time.
+        * \param end The end time or a negative value if determined by the sound.
+        * \param skip How much seconds should be skipped at the beginning.
+        * \return The entry added.
+        */
+       boost::shared_ptr<AUD_SequencerEntry> add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip);
+
+       /**
+        * Removes an entry from the scene.
+        * \param entry The entry to remove.
+        */
+       void remove(boost::shared_ptr<AUD_SequencerEntry> entry);
+};
+
+#endif //__AUD_SEQUENCER_H__
index 96fd15a0bf88b313a70b4d6457b669c9770990c2..005557bbed1218983cfdccfadc4ed8ef8d668685 100644 (file)
@@ -34,7 +34,7 @@
 #include <cmath>
 #include <limits>
 
-AUD_SequencerEntry::AUD_SequencerEntry(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip, int id) :
+AUD_SequencerEntry::AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip, int id) :
        m_status(0),
        m_pos_status(1),
        m_sound_status(0),
@@ -86,7 +86,7 @@ void AUD_SequencerEntry::unlock()
        pthread_mutex_unlock(&m_mutex);
 }
 
-void AUD_SequencerEntry::setSound(AUD_Reference<AUD_IFactory> sound)
+void AUD_SequencerEntry::setSound(boost::shared_ptr<AUD_IFactory> sound)
 {
        AUD_MutexLock lock(*this);
 
index 46efc52d66b2c508589fe4fb1a311a37ab7bfef6..aa1edebfc2f57c6ab5c60b2d959beb9a1e527fc9 100644 (file)
 #ifndef __AUD_SEQUENCERENTRY_H__
 #define __AUD_SEQUENCERENTRY_H__
 
-#include "AUD_Reference.h"
 #include "AUD_AnimateableProperty.h"
 #include "AUD_IFactory.h"
 #include "AUD_ILockable.h"
 
 #include <pthread.h>
+#include <boost/shared_ptr.hpp>
 
 /**
  * This class represents a sequenced entry in a sequencer factory.
@@ -57,7 +57,7 @@ private:
        int m_id;
 
        /// The sound this entry plays.
-       AUD_Reference<AUD_IFactory> m_sound;
+       boost::shared_ptr<AUD_IFactory> m_sound;
 
        /// The begin time.
        float m_begin;
@@ -125,7 +125,7 @@ public:
         * \param skip How much seconds should be skipped at the beginning.
         * \param id The ID of the entry.
         */
-       AUD_SequencerEntry(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip, int id);
+       AUD_SequencerEntry(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip, int id);
        virtual ~AUD_SequencerEntry();
 
        /**
@@ -142,7 +142,7 @@ public:
         * Sets the sound of the entry.
         * \param sound The new sound.
         */
-       void setSound(AUD_Reference<AUD_IFactory> sound);
+       void setSound(boost::shared_ptr<AUD_IFactory> sound);
 
        /**
         * Moves the entry.
index 2cc0a656cf15130796ddfd8f86b7323fffcaea1b..f6076603c2b7e416ade8c95f54f2fc86db0710f0 100644 (file)
 #include "AUD_3DMath.h"
 #include "AUD_MutexLock.h"
 
-AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted) :
-       m_specs(specs),
-       m_status(0),
-       m_entry_status(0),
-       m_id(0),
-       m_muted(muted),
-       m_fps(fps),
-       m_speed_of_sound(434),
-       m_doppler_factor(1),
-       m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED),
-       m_location(3),
-       m_orientation(4)
+AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted)
 {
-       AUD_Quaternion q;
-       m_orientation.write(q.get());
-       float f = 1;
-       m_volume.write(&f);
-
-       pthread_mutexattr_t attr;
-       pthread_mutexattr_init(&attr);
-       pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-
-       pthread_mutex_init(&m_mutex, &attr);
-
-       pthread_mutexattr_destroy(&attr);
+       m_sequence = boost::shared_ptr<AUD_Sequencer>(new AUD_Sequencer(specs, fps, muted));
 }
 
-AUD_SequencerFactory::~AUD_SequencerFactory()
-{
-       pthread_mutex_destroy(&m_mutex);
-}
-
-void AUD_SequencerFactory::lock()
+/*void AUD_SequencerFactory::lock()
 {
        pthread_mutex_lock(&m_mutex);
 }
@@ -72,115 +45,79 @@ void AUD_SequencerFactory::lock()
 void AUD_SequencerFactory::unlock()
 {
        pthread_mutex_unlock(&m_mutex);
-}
+}*/
 
 void AUD_SequencerFactory::setSpecs(AUD_Specs specs)
 {
-       AUD_MutexLock lock(*this);
-
-       m_specs = specs;
-       m_status++;
+       m_sequence->setSpecs(specs);
 }
 
 void AUD_SequencerFactory::setFPS(float fps)
 {
-       AUD_MutexLock lock(*this);
-
-       m_fps = fps;
+       m_sequence->setFPS(fps);
 }
 
 void AUD_SequencerFactory::mute(bool muted)
 {
-       AUD_MutexLock lock(*this);
-
-       m_muted = muted;
+       m_sequence->mute(muted);
 }
 
 bool AUD_SequencerFactory::getMute() const
 {
-       return m_muted;
+       return m_sequence->getMute();
 }
 
 float AUD_SequencerFactory::getSpeedOfSound() const
 {
-       return m_speed_of_sound;
+       return m_sequence->getSpeedOfSound();
 }
 
 void AUD_SequencerFactory::setSpeedOfSound(float speed)
 {
-       AUD_MutexLock lock(*this);
-
-       m_speed_of_sound = speed;
-       m_status++;
+       m_sequence->setSpeedOfSound(speed);
 }
 
 float AUD_SequencerFactory::getDopplerFactor() const
 {
-       return m_doppler_factor;
+       return m_sequence->getDopplerFactor();
 }
 
 void AUD_SequencerFactory::setDopplerFactor(float factor)
 {
-       AUD_MutexLock lock(*this);
-
-       m_doppler_factor = factor;
-       m_status++;
+       m_sequence->setDopplerFactor(factor);
 }
 
 AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const
 {
-       return m_distance_model;
+       return m_sequence->getDistanceModel();
 }
 
 void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model)
 {
-       AUD_MutexLock lock(*this);
-
-       m_distance_model = model;
-       m_status++;
+       m_sequence->setDistanceModel(model);
 }
 
 AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type)
 {
-       switch(type)
-       {
-       case AUD_AP_VOLUME:
-               return &m_volume;
-       case AUD_AP_LOCATION:
-               return &m_location;
-       case AUD_AP_ORIENTATION:
-               return &m_orientation;
-       default:
-               return NULL;
-       }
+       return m_sequence->getAnimProperty(type);
 }
 
-AUD_Reference<AUD_SequencerEntry> AUD_SequencerFactory::add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip)
+boost::shared_ptr<AUD_SequencerEntry> AUD_SequencerFactory::add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip)
 {
-       AUD_MutexLock lock(*this);
-
-       AUD_Reference<AUD_SequencerEntry> entry = new AUD_SequencerEntry(sound, begin, end, skip, m_id++);
-
-       m_entries.push_front(entry);
-       m_entry_status++;
-
-       return entry;
+       return m_sequence->add(sound, begin, end, skip);
 }
 
-void AUD_SequencerFactory::remove(AUD_Reference<AUD_SequencerEntry> entry)
+void AUD_SequencerFactory::remove(boost::shared_ptr<AUD_SequencerEntry> entry)
 {
-       AUD_MutexLock lock(*this);
-
-       m_entries.remove(entry);
-       m_entry_status++;
+       m_sequence->remove(entry);
 }
 
-AUD_Reference<AUD_IReader> AUD_SequencerFactory::createQualityReader()
+boost::shared_ptr<AUD_IReader> AUD_SequencerFactory::createQualityReader()
 {
-       return new AUD_SequencerReader(this, true);
+       return boost::shared_ptr<AUD_IReader>(new AUD_SequencerReader(m_sequence, true));
 }
 
-AUD_Reference<AUD_IReader> AUD_SequencerFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SequencerFactory::createReader()
 {
-       return new AUD_SequencerReader(this);
+       return boost::shared_ptr<AUD_IReader>(new AUD_SequencerReader(m_sequence));
 }
index 38cbc2d1867f38d40ffb0f2004353d3cafb95682..3ef847d4b34c37e0c4bba534bd2eecbd496d76dc 100644 (file)
@@ -32,7 +32,8 @@
 
 #include "AUD_IFactory.h"
 #include "AUD_AnimateableProperty.h"
-#include "AUD_ILockable.h"
+//#include "AUD_ILockable.h"
+#include "AUD_Sequencer.h"
 
 #include <list>
 #include <pthread.h>
@@ -42,51 +43,12 @@ class AUD_SequencerEntry;
 /**
  * This factory represents sequenced entries to play a sound scene.
  */
-class AUD_SequencerFactory : public AUD_IFactory, public AUD_ILockable
+class AUD_SequencerFactory : public AUD_IFactory//, public AUD_ILockable
 {
        friend class AUD_SequencerReader;
 private:
-       /// The target specification.
-       AUD_Specs m_specs;
-
-       /// The status of the factory. Changes every time a non-animated parameter changes.
-       int m_status;
-
-       /// The entry status. Changes every time an entry is removed or added.
-       int m_entry_status;
-
-       /// The next unused ID for the entries.
-       int m_id;
-
-       /// The sequenced entries.
-       std::list<AUD_Reference<AUD_SequencerEntry> > m_entries;
-
-       /// Whether the whole scene is muted.
-       bool m_muted;
-
-       /// The FPS of the scene.
-       float m_fps;
-
-       /// Speed of Sound.
-       float m_speed_of_sound;
-
-       /// Doppler factor.
-       float m_doppler_factor;
-
-       /// Distance model.
-       AUD_DistanceModel m_distance_model;
-
-       /// The animated volume.
-       AUD_AnimateableProperty m_volume;
-
-       /// The animated listener location.
-       AUD_AnimateableProperty m_location;
-
-       /// The animated listener orientation.
-       AUD_AnimateableProperty m_orientation;
-
-       /// The mutex for locking.
-       pthread_mutex_t m_mutex;
+       /// The sequence.
+       boost::shared_ptr<AUD_Sequencer> m_sequence;
 
        // hide copy constructor and operator=
        AUD_SequencerFactory(const AUD_SequencerFactory&);
@@ -100,8 +62,8 @@ public:
         * \param muted Whether the whole scene is muted.
         */
        AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted);
-       ~AUD_SequencerFactory();
 
+#if 0
        /**
         * Locks the factory.
         */
@@ -111,6 +73,7 @@ public:
         * Unlocks the previously locked factory.
         */
        virtual void unlock();
+#endif
 
        /**
         * Sets the audio output specification.
@@ -194,21 +157,21 @@ public:
         * \param skip How much seconds should be skipped at the beginning.
         * \return The entry added.
         */
-       AUD_Reference<AUD_SequencerEntry> add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip);
+       boost::shared_ptr<AUD_SequencerEntry> add(boost::shared_ptr<AUD_IFactory> sound, float begin, float end, float skip);
 
        /**
         * Removes an entry from the scene.
         * \param entry The entry to remove.
         */
-       void remove(AUD_Reference<AUD_SequencerEntry> entry);
+       void remove(boost::shared_ptr<AUD_SequencerEntry> entry);
 
        /**
         * Creates a new reader with high quality resampling.
         * \return The new reader.
         */
-       AUD_Reference<AUD_IReader> createQualityReader();
+       boost::shared_ptr<AUD_IReader> createQualityReader();
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_SEQUENCERFACTORY_H__
index 38d2ed38a7edaeb02cba9b02953cd723b39f3ed3..c9473cf274e7b09625d74733531221933ee18156 100644 (file)
 #include "AUD_ReadDevice.h"
 #include "AUD_MutexLock.h"
 
-AUD_SequencerHandle::AUD_SequencerHandle(AUD_Reference<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
+AUD_SequencerHandle::AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device) :
        m_entry(entry),
        m_status(0),
        m_pos_status(0),
        m_sound_status(0),
        m_device(device)
 {
-       if(!entry->m_sound.isNull())
+       if(entry->m_sound.get())
        {
                m_handle = device.play(entry->m_sound, true);
-               m_3dhandle = AUD_Reference<AUD_I3DHandle>(m_handle);
+               m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
        }
 }
 
@@ -50,7 +50,7 @@ AUD_SequencerHandle::~AUD_SequencerHandle()
        stop();
 }
 
-int AUD_SequencerHandle::compare(AUD_Reference<AUD_SequencerEntry> entry) const
+int AUD_SequencerHandle::compare(boost::shared_ptr<AUD_SequencerEntry> entry) const
 {
        if(m_entry->getID() < entry->getID())
                return -1;
@@ -61,13 +61,13 @@ int AUD_SequencerHandle::compare(AUD_Reference<AUD_SequencerEntry> entry) const
 
 void AUD_SequencerHandle::stop()
 {
-       if(!m_handle.isNull())
+       if(m_handle.get())
                m_handle->stop();
 }
 
 void AUD_SequencerHandle::update(float position, float frame, float fps)
 {
-       if(!m_handle.isNull())
+       if(m_handle.get())
        {
                AUD_MutexLock lock(*m_entry);
                if(position >= m_entry->m_end && m_entry->m_end >= 0)
@@ -77,13 +77,13 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
 
                if(m_sound_status != m_entry->m_sound_status)
                {
-                       if(!m_handle.isNull())
+                       if(m_handle.get())
                                m_handle->stop();
 
-                       if(!m_entry->m_sound.isNull())
+                       if(m_entry->m_sound.get())
                        {
                                m_handle = m_device.play(m_entry->m_sound, true);
-                               m_3dhandle = AUD_Reference<AUD_I3DHandle>(m_handle);
+                               m_3dhandle = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle);
                        }
 
                        m_sound_status = m_entry->m_sound_status;
@@ -140,7 +140,7 @@ void AUD_SequencerHandle::update(float position, float frame, float fps)
 
 void AUD_SequencerHandle::seek(float position)
 {
-       if(!m_handle.isNull())
+       if(m_handle.get())
        {
                AUD_MutexLock lock(*m_entry);
                if(position >= m_entry->m_end && m_entry->m_end >= 0)
index 72d3240a103cae099344672c15612f33947fdfd8..881bbdd43dc8656f028b98a422df145b38ed9839 100644 (file)
@@ -43,13 +43,13 @@ class AUD_SequencerHandle
 {
 private:
        /// The entry this handle belongs to.
-       AUD_Reference<AUD_SequencerEntry> m_entry;
+       boost::shared_ptr<AUD_SequencerEntry> m_entry;
 
        /// The handle in the read device.
-       AUD_Reference<AUD_IHandle> m_handle;
+       boost::shared_ptr<AUD_IHandle> m_handle;
 
        /// The 3D handle in the read device.
-       AUD_Reference<AUD_I3DHandle> m_3dhandle;
+       boost::shared_ptr<AUD_I3DHandle> m_3dhandle;
 
        /// The last read status from the entry.
        int m_status;
@@ -69,7 +69,7 @@ public:
         * \param entry The entry this handle plays.
         * \param device The read device to play on.
         */
-       AUD_SequencerHandle(AUD_Reference<AUD_SequencerEntry> entry, AUD_ReadDevice& device);
+       AUD_SequencerHandle(boost::shared_ptr<AUD_SequencerEntry> entry, AUD_ReadDevice& device);
 
        /**
         * Destroys the handle.
@@ -81,7 +81,7 @@ public:
         * \param entry The entry to compare to.
         * \return Whether the entries ID is smaller, equal or bigger.
         */
-       int compare(AUD_Reference<AUD_SequencerEntry> entry) const;
+       int compare(boost::shared_ptr<AUD_SequencerEntry> entry) const;
 
        /**
         * Stops playing back the handle.
index 39a4d29e6e4c39442d17451895789b9da2ea920b..d5e14590df594f1e9481689cd310a6ac8a608dba 100644 (file)
 #include "AUD_SequencerReader.h"
 #include "AUD_MutexLock.h"
 
-typedef std::list<AUD_Reference<AUD_SequencerHandle> >::iterator AUD_HandleIterator;
-typedef std::list<AUD_Reference<AUD_SequencerEntry> >::iterator AUD_EntryIterator;
+typedef std::list<boost::shared_ptr<AUD_SequencerHandle> >::iterator AUD_HandleIterator;
+typedef std::list<boost::shared_ptr<AUD_SequencerEntry> >::iterator AUD_EntryIterator;
 
-AUD_SequencerReader::AUD_SequencerReader(AUD_Reference<AUD_SequencerFactory> factory, bool quality) :
-       m_position(0), m_device(factory->m_specs), m_factory(factory), m_status(0), m_entry_status(0)
+AUD_SequencerReader::AUD_SequencerReader(boost::shared_ptr<AUD_Sequencer> sequence, bool quality) :
+       m_position(0), m_device(sequence->m_specs), m_sequence(sequence), m_status(0), m_entry_status(0)
 {
        m_device.setQuality(quality);
 }
@@ -57,7 +57,7 @@ void AUD_SequencerReader::seek(int position)
 
        for(AUD_HandleIterator it = m_handles.begin(); it != m_handles.end(); it++)
        {
-               (*it)->seek(position / m_factory->m_specs.rate);
+               (*it)->seek(position / m_sequence->m_specs.rate);
        }
 }
 
@@ -73,37 +73,37 @@ int AUD_SequencerReader::getPosition() const
 
 AUD_Specs AUD_SequencerReader::getSpecs() const
 {
-       return m_factory->m_specs;
+       return m_sequence->m_specs;
 }
 
 void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
 {
-       AUD_MutexLock lock(*m_factory);
+       AUD_MutexLock lock(*m_sequence);
 
-       if(m_factory->m_status != m_status)
+       if(m_sequence->m_status != m_status)
        {
-               m_device.changeSpecs(m_factory->m_specs);
-               m_device.setSpeedOfSound(m_factory->m_speed_of_sound);
-               m_device.setDistanceModel(m_factory->m_distance_model);
-               m_device.setDopplerFactor(m_factory->m_doppler_factor);
+               m_device.changeSpecs(m_sequence->m_specs);
+               m_device.setSpeedOfSound(m_sequence->m_speed_of_sound);
+               m_device.setDistanceModel(m_sequence->m_distance_model);
+               m_device.setDopplerFactor(m_sequence->m_doppler_factor);
 
-               m_status = m_factory->m_status;
+               m_status = m_sequence->m_status;
        }
 
-       if(m_factory->m_entry_status != m_entry_status)
+       if(m_sequence->m_entry_status != m_entry_status)
        {
-               std::list<AUD_Reference<AUD_SequencerHandle> > handles;
+               std::list<boost::shared_ptr<AUD_SequencerHandle> > handles;
 
                AUD_HandleIterator hit = m_handles.begin();
-               AUD_EntryIterator  eit = m_factory->m_entries.begin();
+               AUD_EntryIterator  eit = m_sequence->m_entries.begin();
 
                int result;
-               AUD_Reference<AUD_SequencerHandle> handle;
+               boost::shared_ptr<AUD_SequencerHandle> handle;
 
-               while(hit != m_handles.end() && eit != m_factory->m_entries.end())
+               while(hit != m_handles.end() && eit != m_sequence->m_entries.end())
                {
                        handle = *hit;
-                       AUD_Reference<AUD_SequencerEntry> entry = *eit;
+                       boost::shared_ptr<AUD_SequencerEntry> entry = *eit;
 
                        result = handle->compare(entry);
 
@@ -111,7 +111,7 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
                        {
                                try
                                {
-                                       handle = new AUD_SequencerHandle(entry, m_device);
+                                       handle = boost::shared_ptr<AUD_SequencerHandle>(new AUD_SequencerHandle(entry, m_device));
                                        handles.push_front(handle);
                                }
                                catch(AUD_Exception&)
@@ -138,11 +138,11 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
                        hit++;
                }
 
-               while(eit != m_factory->m_entries.end())
+               while(eit != m_sequence->m_entries.end())
                {
                        try
                        {
-                               handle = new AUD_SequencerHandle(*eit, m_device);
+                               handle = boost::shared_ptr<AUD_SequencerHandle>(new AUD_SequencerHandle(*eit, m_device));
                                handles.push_front(handle);
                        }
                        catch(AUD_Exception&)
@@ -153,10 +153,10 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
 
                m_handles = handles;
 
-               m_entry_status = m_factory->m_entry_status;
+               m_entry_status = m_sequence->m_entry_status;
        }
 
-       AUD_Specs specs = m_factory->m_specs;
+       AUD_Specs specs = m_sequence->m_specs;
        int pos = 0;
        float time = float(m_position) / float(specs.rate);
        float volume, frame;
@@ -167,30 +167,30 @@ void AUD_SequencerReader::read(int& length, bool& eos, sample_t* buffer)
 
        while(pos < length)
        {
-               frame = time * m_factory->m_fps;
+               frame = time * m_sequence->m_fps;
                cfra = int(floor(frame));
 
-               len = int(ceil((cfra + 1) / m_factory->m_fps * specs.rate)) - m_position;
+               len = int(ceil((cfra + 1) / m_sequence->m_fps * specs.rate)) - m_position;
                len = AUD_MIN(length - pos, len);
                len = AUD_MAX(len, 1);
 
                for(AUD_HandleIterator it = m_handles.begin(); it != m_handles.end(); it++)
                {
-                       (*it)->update(time, frame, m_factory->m_fps);
+                       (*it)->update(time, frame, m_sequence->m_fps);
                }
 
-               m_factory->m_volume.read(frame, &volume);
-               if(m_factory->m_muted)
+               m_sequence->m_volume.read(frame, &volume);
+               if(m_sequence->m_muted)
                        volume = 0.0f;
                m_device.setVolume(volume);
 
-               m_factory->m_orientation.read(frame, q.get());
+               m_sequence->m_orientation.read(frame, q.get());
                m_device.setListenerOrientation(q);
-               m_factory->m_location.read(frame, v.get());
+               m_sequence->m_location.read(frame, v.get());
                m_device.setListenerLocation(v);
-               m_factory->m_location.read(frame + 1, v2.get());
+               m_sequence->m_location.read(frame + 1, v2.get());
                v2 -= v;
-               m_device.setListenerVelocity(v2 * m_factory->m_fps);
+               m_device.setListenerVelocity(v2 * m_sequence->m_fps);
 
                m_device.read(reinterpret_cast<data_t*>(buffer + specs.channels * pos), len);
 
index b3c3a3ea7a67f78c5e8585ef19d4a0bee1888870..6b3dbc9313e2a5f0938ed5c5890e94810c40b939 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "AUD_IReader.h"
 #include "AUD_ReadDevice.h"
-#include "AUD_SequencerFactory.h"
+#include "AUD_Sequencer.h"
 #include "AUD_SequencerHandle.h"
 
 /**
@@ -52,22 +52,22 @@ private:
        AUD_ReadDevice m_device;
 
        /**
-        * Saves the SequencerFactory the reader belongs to.
+        * Saves the sequence the reader belongs to.
         */
-       AUD_Reference<AUD_SequencerFactory> m_factory;
+       boost::shared_ptr<AUD_Sequencer> m_sequence;
 
        /**
         * The list of playback handles for the entries.
         */
-       std::list<AUD_Reference<AUD_SequencerHandle> > m_handles;
+       std::list<boost::shared_ptr<AUD_SequencerHandle> > m_handles;
 
        /**
-        * Last status read from the factory.
+        * Last status read from the sequence.
         */
        int m_status;
 
        /**
-        * Last entry status read from the factory.
+        * Last entry status read from the sequence.
         */
        int m_entry_status;
 
@@ -81,7 +81,7 @@ public:
         * \param reader The reader to mix.
         * \param specs The target specification.
         */
-       AUD_SequencerReader(AUD_Reference<AUD_SequencerFactory> factory, bool quality = false);
+       AUD_SequencerReader(boost::shared_ptr<AUD_Sequencer> sequence, bool quality = false);
 
        /**
         * Destroys the reader.
index 0ba553f1c02a7f25543f1473279129401c322013..85034b316ca4d353de86a905c7d73d2db71b107d 100644 (file)
@@ -35,7 +35,7 @@ AUD_SilenceFactory::AUD_SilenceFactory()
 {
 }
 
-AUD_Reference<AUD_IReader> AUD_SilenceFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SilenceFactory::createReader()
 {
-       return new AUD_SilenceReader();
+       return boost::shared_ptr<AUD_IReader>(new AUD_SilenceReader());
 }
index 3bc7fc067ed0482c88ab0a2fca062d5c94a6ee64..de62a2f94fcff3f415ba76e9f18f46d937b85aaf 100644 (file)
@@ -48,7 +48,7 @@ public:
         */
        AUD_SilenceFactory();
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_SILENCEFACTORY_H__
index 3ef6a11de5bca57fdc7262e336f8287143cc3293..2b9742cc90cc89ca87f188456dd8e94413a8d7d5 100644 (file)
@@ -42,7 +42,7 @@ float AUD_SinusFactory::getFrequency() const
        return m_frequency;
 }
 
-AUD_Reference<AUD_IReader> AUD_SinusFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SinusFactory::createReader()
 {
-       return new AUD_SinusReader(m_frequency, m_sampleRate);
+       return boost::shared_ptr<AUD_IReader>(new AUD_SinusReader(m_frequency, m_sampleRate));
 }
index d83323c6635878ae757a1703705abea14eb95e59..d1909dedb6656c392d3fdf1467baf9cbc11ff8cc 100644 (file)
@@ -66,7 +66,7 @@ public:
         */
        float getFrequency() const;
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_SINUSFACTORY_H__
index 1fbd0ad82d2f8b24a36dec07fc868171bd7b21b7..a7e5b25664bfc4bc78f1d9a32a11cf60ed858874 100644 (file)
@@ -57,7 +57,7 @@ typedef enum
 /********************** AUD_SoftwareHandle Handle Code ************************/
 /******************************************************************************/
 
-AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, AUD_Reference<AUD_ResampleReader> resampler, AUD_Reference<AUD_ChannelMapperReader> mapper, bool keep) :
+AUD_SoftwareDevice::AUD_SoftwareHandle::AUD_SoftwareHandle(AUD_SoftwareDevice* device, boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_PitchReader> pitch, boost::shared_ptr<AUD_ResampleReader> resampler, boost::shared_ptr<AUD_ChannelMapperReader> mapper, bool keep) :
        m_reader(reader), m_pitch(pitch), m_resampler(resampler), m_mapper(mapper), m_keep(keep), m_user_pitch(1.0f), m_user_volume(1.0f), m_user_pan(0.0f), m_volume(1.0f), m_loopcount(0),
        m_relative(true), m_volume_max(1.0f), m_volume_min(0), m_distance_max(std::numeric_limits<float>::max()),
        m_distance_reference(1.0f), m_attenuation(1.0f), m_cone_angle_outer(M_PI), m_cone_angle_inner(M_PI), m_cone_volume_outer(0),
@@ -231,14 +231,23 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::pause()
 
                if(m_status == AUD_STATUS_PLAYING)
                {
-                       m_device->m_playingSounds.remove(this);
-                       m_device->m_pausedSounds.push_back(this);
+                       for(AUD_HandleIterator it = m_device->m_playingSounds.begin(); it != m_device->m_playingSounds.end(); it++)
+                       {
+                               if(it->get() == this)
+                               {
+                                       boost::shared_ptr<AUD_SoftwareHandle> This = *it;
 
-                       if(m_device->m_playingSounds.empty())
-                               m_device->playing(m_device->m_playback = false);
-                       m_status = AUD_STATUS_PAUSED;
+                                       m_device->m_playingSounds.erase(it);
+                                       m_device->m_pausedSounds.push_back(This);
 
-                       return true;
+                                       if(m_device->m_playingSounds.empty())
+                                               m_device->playing(m_device->m_playback = false);
+
+                                       m_status = AUD_STATUS_PAUSED;
+
+                                       return true;
+                               }
+                       }
                }
        }
 
@@ -253,13 +262,23 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::resume()
 
                if(m_status == AUD_STATUS_PAUSED)
                {
-                       m_device->m_pausedSounds.remove(this);
-                       m_device->m_playingSounds.push_back(this);
+                       for(AUD_HandleIterator it = m_device->m_pausedSounds.begin(); it != m_device->m_pausedSounds.end(); it++)
+                       {
+                               if(it->get() == this)
+                               {
+                                       boost::shared_ptr<AUD_SoftwareHandle> This = *it;
 
-                       if(!m_device->m_playback)
-                               m_device->playing(m_device->m_playback = true);
-                       m_status = AUD_STATUS_PLAYING;
-                       return true;
+                                       m_device->m_pausedSounds.erase(it);
+
+                                       m_device->m_playingSounds.push_back(This);
+
+                                       if(!m_device->m_playback)
+                                               m_device->playing(m_device->m_playback = true);
+                                       m_status = AUD_STATUS_PLAYING;
+
+                                       return true;
+                               }
+                       }
                }
 
        }
@@ -283,7 +302,7 @@ bool AUD_SoftwareDevice::AUD_SoftwareHandle::stop()
        {
                if(it->get() == this)
                {
-                       AUD_Reference<AUD_SoftwareHandle> This = *it;
+                       boost::shared_ptr<AUD_SoftwareHandle> This = *it;
 
                        m_device->m_playingSounds.erase(it);
 
@@ -670,7 +689,7 @@ void AUD_SoftwareDevice::create()
 {
        m_playback = false;
        m_volume = 1.0f;
-       m_mixer = new AUD_Mixer(m_specs);
+       m_mixer = boost::shared_ptr<AUD_Mixer>(new AUD_Mixer(m_specs));
        m_speed_of_sound = 343.0f;
        m_doppler_factor = 1.0f;
        m_distance_model = AUD_DISTANCE_MODEL_INVERSE_CLAMPED;
@@ -707,12 +726,12 @@ void AUD_SoftwareDevice::mix(data_t* buffer, int length)
        AUD_MutexLock lock(*this);
 
        {
-               AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
+               boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> sound;
                int len;
                int pos;
                bool eos;
-               std::list<AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> > stopSounds;
-               std::list<AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> > pauseSounds;
+               std::list<boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> > stopSounds;
+               std::list<boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> > pauseSounds;
                sample_t* buf = m_buffer.getBuffer();
 
                m_mixer->clear(length);
@@ -817,32 +836,32 @@ AUD_DeviceSpecs AUD_SoftwareDevice::getSpecs() const
        return m_specs;
 }
 
-AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> reader, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_SoftwareDevice::play(boost::shared_ptr<AUD_IReader> reader, bool keep)
 {
        // prepare the reader
        // pitch
 
-       AUD_Reference<AUD_PitchReader> pitch = new AUD_PitchReader(reader, 1);
-       reader = AUD_Reference<AUD_IReader>(pitch);
+       boost::shared_ptr<AUD_PitchReader> pitch = boost::shared_ptr<AUD_PitchReader>(new AUD_PitchReader(reader, 1));
+       reader = boost::shared_ptr<AUD_IReader>(pitch);
 
-       AUD_Reference<AUD_ResampleReader> resampler;
+       boost::shared_ptr<AUD_ResampleReader> resampler;
 
        // resample
        if(m_quality)
-               resampler = new AUD_JOSResampleReader(reader, m_specs.specs);
+               resampler = boost::shared_ptr<AUD_ResampleReader>(new AUD_JOSResampleReader(reader, m_specs.specs));
        else
-               resampler = new AUD_LinearResampleReader(reader, m_specs.specs);
-       reader = AUD_Reference<AUD_IReader>(resampler);
+               resampler = boost::shared_ptr<AUD_ResampleReader>(new AUD_LinearResampleReader(reader, m_specs.specs));
+       reader = boost::shared_ptr<AUD_IReader>(resampler);
 
        // rechannel
-       AUD_Reference<AUD_ChannelMapperReader> mapper = new AUD_ChannelMapperReader(reader, m_specs.channels);
-       reader = AUD_Reference<AUD_IReader>(mapper);
+       boost::shared_ptr<AUD_ChannelMapperReader> mapper = boost::shared_ptr<AUD_ChannelMapperReader>(new AUD_ChannelMapperReader(reader, m_specs.channels));
+       reader = boost::shared_ptr<AUD_IReader>(mapper);
 
-       if(reader.isNull())
-               return AUD_Reference<AUD_IHandle>();
+       if(!reader.get())
+               return boost::shared_ptr<AUD_IHandle>();
 
        // play sound
-       AUD_Reference<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, resampler, mapper, keep);
+       boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle> sound = boost::shared_ptr<AUD_SoftwareDevice::AUD_SoftwareHandle>(new AUD_SoftwareDevice::AUD_SoftwareHandle(this, reader, pitch, resampler, mapper, keep));
 
        AUD_MutexLock lock(*this);
 
@@ -851,10 +870,10 @@ AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IReader> r
        if(!m_playback)
                playing(m_playback = true);
 
-       return AUD_Reference<AUD_IHandle>(sound);
+       return boost::shared_ptr<AUD_IHandle>(sound);
 }
 
-AUD_Reference<AUD_IHandle> AUD_SoftwareDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep)
+boost::shared_ptr<AUD_IHandle> AUD_SoftwareDevice::play(boost::shared_ptr<AUD_IFactory> factory, bool keep)
 {
        return play(factory->createReader(), keep);
 }
index c429508b6224ef62d9a81bf9d33804731790f444..8675a5ce2b890eeb7705a22833889245bc09b833 100644 (file)
@@ -59,16 +59,16 @@ protected:
        {
        public:
                /// The reader source.
-               AUD_Reference<AUD_IReader> m_reader;
+               boost::shared_ptr<AUD_IReader> m_reader;
 
                /// The pitch reader in between.
-               AUD_Reference<AUD_PitchReader> m_pitch;
+               boost::shared_ptr<AUD_PitchReader> m_pitch;
 
                /// The resample reader in between.
-               AUD_Reference<AUD_ResampleReader> m_resampler;
+               boost::shared_ptr<AUD_ResampleReader> m_resampler;
 
                /// The channel mapper reader in between.
-               AUD_Reference<AUD_ChannelMapperReader> m_mapper;
+               boost::shared_ptr<AUD_ChannelMapperReader> m_mapper;
 
                /// Whether to keep the source if end of it is reached.
                bool m_keep;
@@ -150,7 +150,7 @@ protected:
                 * \param mapper The channel mapping reader.
                 * \param keep Whether to keep the handle when the sound ends.
                 */
-               AUD_SoftwareHandle(AUD_SoftwareDevice* device, AUD_Reference<AUD_IReader> reader, AUD_Reference<AUD_PitchReader> pitch, AUD_Reference<AUD_ResampleReader> resampler, AUD_Reference<AUD_ChannelMapperReader> mapper, bool keep);
+               AUD_SoftwareHandle(AUD_SoftwareDevice* device, boost::shared_ptr<AUD_IReader> reader, boost::shared_ptr<AUD_PitchReader> pitch, boost::shared_ptr<AUD_ResampleReader> resampler, boost::shared_ptr<AUD_ChannelMapperReader> mapper, bool keep);
 
                /**
                 * Updates the handle's playback parameters.
@@ -206,7 +206,7 @@ protected:
                virtual bool setConeVolumeOuter(float volume);
        };
 
-       typedef std::list<AUD_Reference<AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
+       typedef std::list<boost::shared_ptr<AUD_SoftwareHandle> >::iterator AUD_HandleIterator;
 
        /**
         * The specification of the device.
@@ -216,7 +216,7 @@ protected:
        /**
         * The mixer.
         */
-       AUD_Reference<AUD_Mixer> m_mixer;
+       boost::shared_ptr<AUD_Mixer> m_mixer;
 
        /**
         * Whether to do high or low quality resampling.
@@ -261,12 +261,12 @@ private:
        /**
         * The list of sounds that are currently playing.
         */
-       std::list<AUD_Reference<AUD_SoftwareHandle> > m_playingSounds;
+       std::list<boost::shared_ptr<AUD_SoftwareHandle> > m_playingSounds;
 
        /**
         * The list of sounds that are currently paused.
         */
-       std::list<AUD_Reference<AUD_SoftwareHandle> > m_pausedSounds;
+       std::list<boost::shared_ptr<AUD_SoftwareHandle> > m_pausedSounds;
 
        /**
         * Whether there is currently playback.
@@ -320,8 +320,8 @@ public:
        void setQuality(bool quality);
 
        virtual AUD_DeviceSpecs getSpecs() const;
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IReader> reader, bool keep = false);
-       virtual AUD_Reference<AUD_IHandle> play(AUD_Reference<AUD_IFactory> factory, bool keep = false);
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IReader> reader, bool keep = false);
+       virtual boost::shared_ptr<AUD_IHandle> play(boost::shared_ptr<AUD_IFactory> factory, bool keep = false);
        virtual void stopAll();
        virtual void lock();
        virtual void unlock();
index 1c8d2a993512f1ba0bb7f2118284690f2a696611..daa714aeec3d81cdaf9fea059a6d47cc626475ca 100644 (file)
 
 #include <cstring>
 
-AUD_StreamBufferFactory::AUD_StreamBufferFactory(AUD_Reference<AUD_IFactory> factory) :
+AUD_StreamBufferFactory::AUD_StreamBufferFactory(boost::shared_ptr<AUD_IFactory> factory) :
        m_buffer(new AUD_Buffer())
 {
-       AUD_Reference<AUD_IReader> reader = factory->createReader();
+       boost::shared_ptr<AUD_IReader> reader = factory->createReader();
 
        m_specs = reader->getSpecs();
 
@@ -70,7 +70,7 @@ AUD_StreamBufferFactory::AUD_StreamBufferFactory(AUD_Reference<AUD_IFactory> fac
        m_buffer->resize(index * sample_size, true);
 }
 
-AUD_Reference<AUD_IReader> AUD_StreamBufferFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_StreamBufferFactory::createReader()
 {
-       return new AUD_BufferReader(m_buffer, m_specs);
+       return boost::shared_ptr<AUD_IReader>(new AUD_BufferReader(m_buffer, m_specs));
 }
index 99795d95d33bb8455076dd69e940768247e66664..1bcd73d59b6bfd776e3f3029a63375934a4b56a5 100644 (file)
 #define __AUD_STREAMBUFFERFACTORY_H__
 
 #include "AUD_IFactory.h"
-#include "AUD_Reference.h"
 #include "AUD_Buffer.h"
 
+#include <boost/shared_ptr.hpp>
+
 /**
  * This factory creates a buffer out of a reader. This way normally streamed
  * sound sources can be loaded into memory for buffered playback.
@@ -44,7 +45,7 @@ private:
        /**
         * The buffer that holds the audio data.
         */
-       AUD_Reference<AUD_Buffer> m_buffer;
+       boost::shared_ptr<AUD_Buffer> m_buffer;
 
        /**
         * The specification of the samples.
@@ -62,9 +63,9 @@ public:
         * \param factory The factory that creates the reader for buffering.
         * \exception AUD_Exception Thrown if the reader cannot be created.
         */
-       AUD_StreamBufferFactory(AUD_Reference<AUD_IFactory> factory);
+       AUD_StreamBufferFactory(boost::shared_ptr<AUD_IFactory> factory);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_STREAMBUFFERFACTORY_H__
index 1fc77fbde66da9d31ba9bea1b456973c34d1a4ed..106b2937a06c9340d671ba1aa800e187444bfaa3 100644 (file)
@@ -43,10 +43,10 @@ AUD_SndFileFactory::AUD_SndFileFactory(const data_t* buffer, int size) :
        memcpy(m_buffer->getBuffer(), buffer, size);
 }
 
-AUD_Reference<AUD_IReader> AUD_SndFileFactory::createReader()
+boost::shared_ptr<AUD_IReader> AUD_SndFileFactory::createReader()
 {
-       if(m_buffer.isNull())
-               return new AUD_SndFileReader(m_filename);
+       if(m_buffer.get())
+               return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_buffer));
        else
-               return new AUD_SndFileReader(m_buffer);
+               return boost::shared_ptr<AUD_IReader>(new AUD_SndFileReader(m_filename));
 }
index 7039c7a2615cdd1c2b39dae8ed5ec0f2654f8e8a..bc96325d6eba6ea7461f4514463455248c36f6a4 100644 (file)
 #define __AUD_SNDFILEFACTORY_H__
 
 #include "AUD_IFactory.h"
-#include "AUD_Reference.h"
 #include "AUD_Buffer.h"
 
 #include <string>
+#include <boost/shared_ptr.hpp>
 
 /**
  * This factory reads a sound file via libsndfile.
@@ -50,7 +50,7 @@ private:
        /**
         * The buffer to read from.
         */
-       AUD_Reference<AUD_Buffer> m_buffer;
+       boost::shared_ptr<AUD_Buffer> m_buffer;
 
        // hide copy constructor and operator=
        AUD_SndFileFactory(const AUD_SndFileFactory&);
@@ -70,7 +70,7 @@ public:
         */
        AUD_SndFileFactory(const data_t* buffer, int size);
 
-       virtual AUD_Reference<AUD_IReader> createReader();
+       virtual boost::shared_ptr<AUD_IReader> createReader();
 };
 
 #endif //__AUD_SNDFILEFACTORY_H__
index 8dbb43cb17e422e3e32c240c3a96bb2266eae69d..aaee814f56bc96a8b9836421d4a1f19144624f03 100644 (file)
@@ -100,7 +100,7 @@ AUD_SndFileReader::AUD_SndFileReader(std::string filename) :
        m_seekable = sfinfo.seekable;
 }
 
-AUD_SndFileReader::AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer) :
+AUD_SndFileReader::AUD_SndFileReader(boost::shared_ptr<AUD_Buffer> buffer) :
        m_position(0),
        m_membuffer(buffer),
        m_memoffset(0)
index 81d8b45120c484185fadb649870bcc3e87b5b6a8..5cac5051ee2a4deff6be127e633266d26c9170b4 100644 (file)
 #define __AUD_SNDFILEREADER_H__
 
 #include "AUD_IReader.h"
-#include "AUD_Reference.h"
 #include "AUD_Buffer.h"
 
 #include <string>
 #include <sndfile.h>
+#include <boost/shared_ptr.hpp>
 
 typedef sf_count_t (*sf_read_f)(SNDFILE *sndfile, void *ptr, sf_count_t frames);
 
@@ -78,7 +78,7 @@ private:
        /**
         * The pointer to the memory file.
         */
-       AUD_Reference<AUD_Buffer> m_membuffer;
+       boost::shared_ptr<AUD_Buffer> m_membuffer;
 
        /**
         * The current reading pointer of the memory file.
@@ -110,7 +110,7 @@ public:
         * \exception AUD_Exception Thrown if the buffer specified cannot be read
         *                          with libsndfile.
         */
-       AUD_SndFileReader(AUD_Reference<AUD_Buffer> buffer);
+       AUD_SndFileReader(boost::shared_ptr<AUD_Buffer> buffer);
 
        /**
         * Destroys the reader and closes the file.
index 24d321730eb4e49c1cb6fbb2e34eb6fb4e618b29..06399642edd2929eb1d43c26d726ecd60611914e 100644 (file)
@@ -387,7 +387,7 @@ void BL_ConvertActuators(const char* maggiename,
                                {
                                        bSound* sound = soundact->sound;
                                        bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false;
-                                       AUD_Reference<AUD_IFactory> snd_sound;
+                                       boost::shared_ptr<AUD_IFactory> snd_sound;
                                        KX_3DSoundSettings settings;
                                        settings.cone_inner_angle = soundact->sound3D.cone_inner_angle;
                                        settings.cone_outer_angle = soundact->sound3D.cone_outer_angle;
@@ -406,21 +406,21 @@ void BL_ConvertActuators(const char* maggiename,
                                        }
                                        else
                                        {
-                                               snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle);
+                                               snd_sound = *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(sound->playback_handle);
 
                                                // if sound shall be 3D but isn't mono, we have to make it mono!
                                                if (is3d)
                                                {
                                                        try
                                                        {
-                                                               AUD_Reference<AUD_IReader> reader = snd_sound->createReader();
+                                                               boost::shared_ptr<AUD_IReader> reader = snd_sound->createReader();
                                                                if (reader->getSpecs().channels != AUD_CHANNELS_MONO)
                                                                {
                                                                        AUD_DeviceSpecs specs;
                                                                        specs.channels = AUD_CHANNELS_MONO;
                                                                        specs.rate = AUD_RATE_INVALID;
                                                                        specs.format = AUD_FORMAT_INVALID;
-                                                                       snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs);
+                                                                       snd_sound = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(snd_sound, specs));
                                                                }
                                                        }
                                                        catch(AUD_Exception&)
index f76f94aa81ded7e60a00e94e6ec56ecfa59548cb..2a4f2b3e7d9e67ff430dd1b402580342127c7c69 100644 (file)
@@ -53,7 +53,7 @@
 /* Native functions                                                          */
 /* ------------------------------------------------------------------------- */
 KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
-                                                                  AUD_Reference<AUD_IFactory> sound,
+                                                                  boost::shared_ptr<AUD_IFactory> sound,
                                                                   float volume,
                                                                   float pitch,
                                                                   bool is3d,
@@ -74,20 +74,20 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
 
 KX_SoundActuator::~KX_SoundActuator()
 {
-       if (!m_handle.isNull())
+       if (m_handle.get())
                m_handle->stop();
 }
 
 void KX_SoundActuator::play()
 {
-       if (!m_handle.isNull())
+       if (m_handle.get())
                m_handle->stop();
 
-       if (m_sound.isNull())
+       if (!m_sound.get())
                return;
 
        // this is the sound that will be played and not deleted afterwards
-       AUD_Reference<AUD_IFactory> sound = m_sound;
+       boost::shared_ptr<AUD_IFactory> sound = m_sound;
 
        bool loop = false;
 
@@ -95,7 +95,7 @@ void KX_SoundActuator::play()
        {
        case KX_SOUNDACT_LOOPBIDIRECTIONAL:
        case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
-               sound =  new AUD_PingPongFactory(sound);