13 #ifndef __OPENAL_AUDIO_MANAGER_H__ 14 #define __OPENAL_AUDIO_MANAGER_H__ 26 #ifdef HAVE_OPENAL_FRAMEWORK 27 #include <OpenAL/al.h> 28 #include <OpenAL/alc.h> 36 extern void al_audio_errcheck(
const char *context);
37 extern void alc_audio_errcheck(
const char *context,ALCdevice* device);
43 friend class OpenALSoundData;
52 virtual bool is_valid();
54 virtual PT(
AudioSound) get_sound(
const Filename &,
bool positional =
false,
int mode=SM_heuristic);
55 virtual PT(
AudioSound) get_sound(
MovieAudio *sound,
bool positional =
false,
int mode=SM_heuristic);
57 virtual void uncache_sound(
const Filename &);
58 virtual void clear_cache();
59 virtual void set_cache_limit(
unsigned int count);
60 virtual unsigned int get_cache_limit()
const;
62 virtual void set_volume(PN_stdfloat);
63 virtual PN_stdfloat get_volume()
const;
65 void set_play_rate(PN_stdfloat play_rate);
66 PN_stdfloat get_play_rate()
const;
68 virtual void set_active(
bool);
69 virtual bool get_active()
const;
77 virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz,
78 PN_stdfloat vx, PN_stdfloat xy, PN_stdfloat xz,
79 PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz,
80 PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz);
82 virtual void audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz,
83 PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz,
84 PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz,
85 PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz);
95 virtual void audio_3d_set_distance_factor(PN_stdfloat factor);
96 virtual PN_stdfloat audio_3d_get_distance_factor()
const;
100 virtual void audio_3d_set_doppler_factor(PN_stdfloat factor);
101 virtual PN_stdfloat audio_3d_get_doppler_factor()
const;
105 virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor);
106 virtual PN_stdfloat audio_3d_get_drop_off_factor()
const;
108 virtual void set_concurrent_sound_limit(
unsigned int limit = 0);
109 virtual unsigned int get_concurrent_sound_limit()
const;
110 virtual void reduce_sounds_playing_to(
unsigned int count);
112 virtual void stop_all_sounds();
117 std::string select_audio_device();
119 void make_current()
const;
124 SoundData *get_sound_data(
MovieAudio *source,
int mode);
128 void increment_client_count(SoundData *sd);
129 void decrement_client_count(SoundData *sd);
130 void discard_excess_cache(
int limit);
132 void delete_buffer(ALuint buffer);
174 ExpirationQueue::iterator _expire;
178 typedef phash_map<std::string, SoundData *> SampleCache;
179 SampleCache _sample_cache;
182 SoundsPlaying _sounds_playing;
184 typedef phash_set<OpenALAudioSound *> AllSounds;
185 AllSounds _all_sounds;
190 PN_stdfloat _play_rate;
192 bool _cleanup_required;
194 static int _active_managers;
195 static bool _openal_active;
196 unsigned int _concurrent_sound_limit;
203 static ALCdevice* _device;
204 static ALCcontext* _context;
210 PN_stdfloat _distance_factor;
211 PN_stdfloat _doppler_factor;
212 PN_stdfloat _drop_off_factor;
214 ALfloat _position[3];
215 ALfloat _velocity[3];
216 ALfloat _forward_up[6];
224 static void init_type() {
225 AudioManager::init_type();
226 register_type(_type_handle,
"OpenALAudioManager", AudioManager::get_class_type());
229 return get_class_type();
233 return get_class_type();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EXPCL_OPENAL_AUDIO AudioManager * Create_OpenALAudioManager()
Factory Function.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void update()
Must be called every frame.
The name of a file, such as a texture file or an Egg file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A MovieAudio is actually any source that provides a sequence of audio samples.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void shutdown()
Call this at exit time to shut down the audio system.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL set.
TypeHandle is the identifier used to differentiate C++ class types.
A MovieAudio is actually any source that provides a sequence of audio samples.