|
Blender
V2.59
|
00001 /* 00002 * $Id: AUD_OpenALDevice.h 38631 2011-07-23 16:08:37Z nexyon $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * Copyright 2009-2011 Jörg Hermann Müller 00007 * 00008 * This file is part of AudaSpace. 00009 * 00010 * Audaspace is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * AudaSpace is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with Audaspace; if not, write to the Free Software Foundation, 00022 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #ifndef AUD_OPENALDEVICE 00033 #define AUD_OPENALDEVICE 00034 00035 #include "AUD_IDevice.h" 00036 #include "AUD_I3DDevice.h" 00037 struct AUD_OpenALHandle; 00038 struct AUD_OpenALBufferedFactory; 00039 00040 #include <AL/al.h> 00041 #include <AL/alc.h> 00042 #include <list> 00043 #include <pthread.h> 00044 00048 class AUD_OpenALDevice : public AUD_IDevice, public AUD_I3DDevice 00049 { 00050 private: 00054 ALCdevice* m_device; 00055 00059 ALCcontext* m_context; 00060 00064 AUD_DeviceSpecs m_specs; 00065 00069 bool m_useMC; 00070 00074 std::list<AUD_OpenALHandle*>* m_playingSounds; 00075 00079 std::list<AUD_OpenALHandle*>* m_pausedSounds; 00080 00084 std::list<AUD_OpenALBufferedFactory*>* m_bufferedFactories; 00085 00089 pthread_mutex_t m_mutex; 00090 00094 pthread_t m_thread; 00095 00099 bool m_playing; 00100 00104 int m_buffersize; 00105 00109 void start(bool join = true); 00110 00116 bool isValid(AUD_Handle* handle); 00117 00124 bool getFormat(ALenum &format, AUD_Specs specs); 00125 00126 // hide copy constructor and operator= 00127 AUD_OpenALDevice(const AUD_OpenALDevice&); 00128 AUD_OpenALDevice& operator=(const AUD_OpenALDevice&); 00129 00130 public: 00139 AUD_OpenALDevice(AUD_DeviceSpecs specs, 00140 int buffersize = AUD_DEFAULT_BUFFER_SIZE); 00141 00145 void updateStreams(); 00146 00147 virtual ~AUD_OpenALDevice(); 00148 00149 virtual AUD_DeviceSpecs getSpecs() const; 00150 virtual AUD_Handle* play(AUD_IReader* reader, bool keep = false); 00151 virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false); 00152 virtual bool pause(AUD_Handle* handle); 00153 virtual bool resume(AUD_Handle* handle); 00154 virtual bool stop(AUD_Handle* handle); 00155 virtual bool getKeep(AUD_Handle* handle); 00156 virtual bool setKeep(AUD_Handle* handle, bool keep); 00157 virtual bool seek(AUD_Handle* handle, float position); 00158 virtual float getPosition(AUD_Handle* handle); 00159 virtual AUD_Status getStatus(AUD_Handle* handle); 00160 virtual void lock(); 00161 virtual void unlock(); 00162 virtual float getVolume() const; 00163 virtual void setVolume(float volume); 00164 virtual float getVolume(AUD_Handle* handle); 00165 virtual bool setVolume(AUD_Handle* handle, float volume); 00166 virtual float getPitch(AUD_Handle* handle); 00167 virtual bool setPitch(AUD_Handle* handle, float pitch); 00168 virtual int getLoopCount(AUD_Handle* handle); 00169 virtual bool setLoopCount(AUD_Handle* handle, int count); 00170 virtual bool setStopCallback(AUD_Handle* handle, stopCallback callback = NULL, void* data = NULL); 00171 00172 virtual AUD_Vector3 getListenerLocation() const; 00173 virtual void setListenerLocation(const AUD_Vector3& location); 00174 virtual AUD_Vector3 getListenerVelocity() const; 00175 virtual void setListenerVelocity(const AUD_Vector3& velocity); 00176 virtual AUD_Quaternion getListenerOrientation() const; 00177 virtual void setListenerOrientation(const AUD_Quaternion& orientation); 00178 virtual float getSpeedOfSound() const; 00179 virtual void setSpeedOfSound(float speed); 00180 virtual float getDopplerFactor() const; 00181 virtual void setDopplerFactor(float factor); 00182 virtual AUD_DistanceModel getDistanceModel() const; 00183 virtual void setDistanceModel(AUD_DistanceModel model); 00184 virtual AUD_Vector3 getSourceLocation(AUD_Handle* handle); 00185 virtual bool setSourceLocation(AUD_Handle* handle, const AUD_Vector3& location); 00186 virtual AUD_Vector3 getSourceVelocity(AUD_Handle* handle); 00187 virtual bool setSourceVelocity(AUD_Handle* handle, const AUD_Vector3& velocity); 00188 virtual AUD_Quaternion getSourceOrientation(AUD_Handle* handle); 00189 virtual bool setSourceOrientation(AUD_Handle* handle, const AUD_Quaternion& orientation); 00190 virtual bool isRelative(AUD_Handle* handle); 00191 virtual bool setRelative(AUD_Handle* handle, bool relative); 00192 virtual float getVolumeMaximum(AUD_Handle* handle); 00193 virtual bool setVolumeMaximum(AUD_Handle* handle, float volume); 00194 virtual float getVolumeMinimum(AUD_Handle* handle); 00195 virtual bool setVolumeMinimum(AUD_Handle* handle, float volume); 00196 virtual float getDistanceMaximum(AUD_Handle* handle); 00197 virtual bool setDistanceMaximum(AUD_Handle* handle, float distance); 00198 virtual float getDistanceReference(AUD_Handle* handle); 00199 virtual bool setDistanceReference(AUD_Handle* handle, float distance); 00200 virtual float getAttenuation(AUD_Handle* handle); 00201 virtual bool setAttenuation(AUD_Handle* handle, float factor); 00202 virtual float getConeAngleOuter(AUD_Handle* handle); 00203 virtual bool setConeAngleOuter(AUD_Handle* handle, float angle); 00204 virtual float getConeAngleInner(AUD_Handle* handle); 00205 virtual bool setConeAngleInner(AUD_Handle* handle, float angle); 00206 virtual float getConeVolumeOuter(AUD_Handle* handle); 00207 virtual bool setConeVolumeOuter(AUD_Handle* handle, float volume); 00208 }; 00209 00210 #endif //AUD_OPENALDEVICE