Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
openal_sound_driver.h
1 #pragma once
2 
3 #if defined(__APPLE__)
4 #include <OpenAL/al.h>
5 #include <OpenAL/alc.h>
6 #else
7 #include <AL/al.h>
8 #include <AL/alc.h>
9 #endif
10 
11 #include "../../sound_driver.h"
12 
13 namespace smlt {
14 
16 public:
17  OpenALSoundDriver(Window* window):
18  SoundDriver(window) {}
19 
20  std::vector<AudioSourceID> generate_sources(uint32_t count) override;
21  std::vector<AudioBufferID> generate_buffers(uint32_t count) override;
22 
23  void destroy_buffers(const std::vector<AudioBufferID>& buffers) override;
24  void destroy_sources(const std::vector<AudioSourceID>& sources) override;
25 
26  void play_source(AudioSourceID source_id) override;
27  void stop_source(AudioSourceID source_id) override;
28 
29  void queue_buffers_to_source(AudioSourceID source, uint32_t count, const std::vector<AudioBufferID>& buffers) override;
30  std::vector<AudioBufferID> unqueue_buffers_from_source(AudioSourceID source, uint32_t count) override;
31  void upload_buffer_data(AudioBufferID buffer, AudioDataFormat format, const uint8_t* data, std::size_t bytes, uint32_t frequency) override;
32 
33  AudioSourceState source_state(AudioSourceID source) override;
34  int32_t source_buffers_processed_count(AudioSourceID source) const override;
35 
36  void set_source_as_ambient(AudioSourceID id) override;
37  void set_listener_properties(const Vec3& position, const Quaternion& orientation, const Vec3& velocity) override;
38  void set_source_properties(AudioSourceID id, const Vec3& position, const Vec3& velocity) override;
39 
40  void set_source_reference_distance(AudioSourceID id, float dist) override;
41  void set_source_gain(AudioSourceID id, RangeValue<0, 1> value) override;
42  void set_source_pitch(AudioSourceID id, RangeValue<0, 1> value) override;
43 
44 private:
45  bool _startup() override;
46  void _shutdown() override;
47 
48  ALCdevice* dev = nullptr;
49  ALCcontext* ctx = nullptr;
50  DistanceModel model_ = DISTANCE_MODEL_POSITIONAL;
51 };
52 
53 }
smlt::OpenALSoundDriver
Definition: openal_sound_driver.h:15
smlt::Vec3
Definition: vec3.h:23
smlt::Quaternion
Definition: quaternion.h:24
smlt
Definition: animation.cpp:25
smlt::Window
Definition: window.h:65
smlt::RangeValue
Definition: range_value.h:24
smlt::SoundDriver
Definition: sound_driver.h:74