diff options
Diffstat (limited to 'intern/audaspace/OpenAL/AUD_OpenALDevice.h')
-rw-r--r-- | intern/audaspace/OpenAL/AUD_OpenALDevice.h | 154 |
1 files changed, 101 insertions, 53 deletions
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h index d5db5989fe7..6bf04a36329 100644 --- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h +++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h @@ -33,10 +33,11 @@ #define AUD_OPENALDEVICE #include "AUD_IDevice.h" +#include "AUD_IHandle.h" #include "AUD_I3DDevice.h" +#include "AUD_I3DHandle.h" #include "AUD_Buffer.h" -struct AUD_OpenALHandle; -struct AUD_OpenALBufferedFactory; +//struct AUD_OpenALBufferedFactory; #include <AL/al.h> #include <AL/alc.h> @@ -49,6 +50,99 @@ struct AUD_OpenALBufferedFactory; class AUD_OpenALDevice : public AUD_IDevice, public AUD_I3DDevice { private: + /// Saves the data for playback. + class AUD_OpenALHandle : public AUD_IHandle, public AUD_I3DHandle + { + public: + static const int CYCLE_BUFFERS = 3; + + /// Whether it's a buffered or a streamed source. + bool m_isBuffered; + + /// The reader source. + AUD_Reference<AUD_IReader> m_reader; + + /// Whether to keep the source if end of it is reached. + bool m_keep; + + /// OpenAL sample format. + ALenum m_format; + + /// OpenAL source. + ALuint m_source; + + /// OpenAL buffers. + ALuint m_buffers[CYCLE_BUFFERS]; + + /// The first buffer to be read next. + int m_current; + + /// Whether the stream doesn't return any more data. + bool m_eos; + + /// The loop count of the source. + int m_loopcount; + + /// The stop callback. + stopCallback m_stop; + + /// Stop callback data. + void* m_stop_data; + + /// Current status of the handle + AUD_Status m_status; + + /// Own device. + AUD_OpenALDevice* m_device; + + public: + + AUD_OpenALHandle(AUD_OpenALDevice* device, ALenum format, AUD_Reference<AUD_IReader> reader, bool keep); + + virtual ~AUD_OpenALHandle() {} + virtual bool pause(); + virtual bool resume(); + virtual bool stop(); + virtual bool getKeep(); + virtual bool setKeep(bool keep); + virtual bool seek(float position); + virtual float getPosition(); + virtual AUD_Status getStatus(); + virtual float getVolume(); + virtual bool setVolume(float volume); + virtual float getPitch(); + virtual bool setPitch(float pitch); + virtual int getLoopCount(); + virtual bool setLoopCount(int count); + virtual bool setStopCallback(stopCallback callback = 0, void* data = 0); + + virtual AUD_Vector3 getSourceLocation(); + virtual bool setSourceLocation(const AUD_Vector3& location); + virtual AUD_Vector3 getSourceVelocity(); + virtual bool setSourceVelocity(const AUD_Vector3& velocity); + virtual AUD_Quaternion getSourceOrientation(); + virtual bool setSourceOrientation(const AUD_Quaternion& orientation); + virtual bool isRelative(); + virtual bool setRelative(bool relative); + virtual float getVolumeMaximum(); + virtual bool setVolumeMaximum(float volume); + virtual float getVolumeMinimum(); + virtual bool setVolumeMinimum(float volume); + virtual float getDistanceMaximum(); + virtual bool setDistanceMaximum(float distance); + virtual float getDistanceReference(); + virtual bool setDistanceReference(float distance); + virtual float getAttenuation(); + virtual bool setAttenuation(float factor); + virtual float getConeAngleOuter(); + virtual bool setConeAngleOuter(float angle); + virtual float getConeAngleInner(); + virtual bool setConeAngleInner(float angle); + virtual float getConeVolumeOuter(); + virtual bool setConeVolumeOuter(float volume); + }; + + /** * The OpenAL device handle. */ @@ -72,17 +166,17 @@ private: /** * The list of sounds that are currently playing. */ - std::list<AUD_OpenALHandle*>* m_playingSounds; + std::list<AUD_Reference<AUD_OpenALHandle> > m_playingSounds; /** * The list of sounds that are currently paused. */ - std::list<AUD_OpenALHandle*>* m_pausedSounds; + std::list<AUD_Reference<AUD_OpenALHandle> > m_pausedSounds; /** * The list of buffered factories. */ - std::list<AUD_OpenALBufferedFactory*>* m_bufferedFactories; + //std::list<AUD_OpenALBufferedFactory*>* m_bufferedFactories; /** * The mutex for locking. @@ -115,13 +209,6 @@ private: void start(); /** - * Checks if a handle is valid. - * \param handle The handle to check. - * \return Whether the handle is valid. - */ - bool isValid(AUD_Handle* handle); - - /** * Gets the format according to the specs. * \param format The variable to put the format into. * \param specs The specs to read the channel count from. @@ -153,27 +240,12 @@ public: virtual ~AUD_OpenALDevice(); virtual AUD_DeviceSpecs getSpecs() const; - virtual AUD_Handle* play(AUD_Reference<AUD_IReader> reader, bool keep = false); - virtual AUD_Handle* play(AUD_Reference<AUD_IFactory> factory, bool keep = false); - virtual bool pause(AUD_Handle* handle); - virtual bool resume(AUD_Handle* handle); - virtual bool stop(AUD_Handle* handle); - virtual bool getKeep(AUD_Handle* handle); - virtual bool setKeep(AUD_Handle* handle, bool keep); - virtual bool seek(AUD_Handle* handle, float position); - virtual float getPosition(AUD_Handle* handle); - virtual AUD_Status getStatus(AUD_Handle* handle); + 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 void lock(); virtual void unlock(); virtual float getVolume() const; virtual void setVolume(float volume); - virtual float getVolume(AUD_Handle* handle); - virtual bool setVolume(AUD_Handle* handle, float volume); - virtual float getPitch(AUD_Handle* handle); - virtual bool setPitch(AUD_Handle* handle, float pitch); - virtual int getLoopCount(AUD_Handle* handle); - virtual bool setLoopCount(AUD_Handle* handle, int count); - virtual bool setStopCallback(AUD_Handle* handle, stopCallback callback = NULL, void* data = NULL); virtual AUD_Vector3 getListenerLocation() const; virtual void setListenerLocation(const AUD_Vector3& location); @@ -187,30 +259,6 @@ public: virtual void setDopplerFactor(float factor); virtual AUD_DistanceModel getDistanceModel() const; virtual void setDistanceModel(AUD_DistanceModel model); - virtual AUD_Vector3 getSourceLocation(AUD_Handle* handle); - virtual bool setSourceLocation(AUD_Handle* handle, const AUD_Vector3& location); - virtual AUD_Vector3 getSourceVelocity(AUD_Handle* handle); - virtual bool setSourceVelocity(AUD_Handle* handle, const AUD_Vector3& velocity); - virtual AUD_Quaternion getSourceOrientation(AUD_Handle* handle); - virtual bool setSourceOrientation(AUD_Handle* handle, const AUD_Quaternion& orientation); - virtual bool isRelative(AUD_Handle* handle); - virtual bool setRelative(AUD_Handle* handle, bool relative); - virtual float getVolumeMaximum(AUD_Handle* handle); - virtual bool setVolumeMaximum(AUD_Handle* handle, float volume); - virtual float getVolumeMinimum(AUD_Handle* handle); - virtual bool setVolumeMinimum(AUD_Handle* handle, float volume); - virtual float getDistanceMaximum(AUD_Handle* handle); - virtual bool setDistanceMaximum(AUD_Handle* handle, float distance); - virtual float getDistanceReference(AUD_Handle* handle); - virtual bool setDistanceReference(AUD_Handle* handle, float distance); - virtual float getAttenuation(AUD_Handle* handle); - virtual bool setAttenuation(AUD_Handle* handle, float factor); - virtual float getConeAngleOuter(AUD_Handle* handle); - virtual bool setConeAngleOuter(AUD_Handle* handle, float angle); - virtual float getConeAngleInner(AUD_Handle* handle); - virtual bool setConeAngleInner(AUD_Handle* handle, float angle); - virtual float getConeVolumeOuter(AUD_Handle* handle); - virtual bool setConeVolumeOuter(AUD_Handle* handle, float volume); }; #endif //AUD_OPENALDEVICE |