SuperTuxKart
Loading...
Searching...
No Matches
sfx_openal.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2006-2015 Patrick Ammann <pammann@aro.ch>
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_SFX_OPENAL_HPP
20#define HEADER_SFX_OPENAL_HPP
21
22#ifdef ENABLE_SOUND
23
24#include <assert.h>
25#include <atomic>
26#include <AL/al.h>
27#include "audio/sfx_base.hpp"
28#include "utils/leak_check.hpp"
29#include "utils/cpp2011.hpp"
30
35class SFXOpenAL : public SFXBase
36{
37private:
38 LEAK_CHECK()
39
40
41 SFXBuffer* m_sound_buffer;
42
44 ALuint m_sound_source;
45
47 std::atomic<SFXStatus> m_status;
48
50 bool m_positional;
51
53 float m_default_gain;
54
58 bool m_loop;
59
65 float m_gain;
66
68 float m_master_gain;
69
71 bool m_owns_buffer;
72
74 float m_play_time;
75
76public:
77 SFXOpenAL(SFXBuffer* buffer, bool positional, float volume,
78 bool owns_buffer = false);
79 virtual ~SFXOpenAL();
80
81 virtual void updatePlayingSFX(float dt) OVERRIDE;
82 virtual bool init() OVERRIDE;
83 virtual void play() OVERRIDE;
84 virtual void reallyPlayNow(SFXBuffer* buffer = NULL) OVERRIDE;
85 virtual void play(const Vec3 &xyz, SFXBuffer* buffer = NULL) OVERRIDE;
86 virtual void reallyPlayNow(const Vec3 &xyz, SFXBuffer* buffer = NULL) OVERRIDE;
87 virtual void setLoop(bool status) OVERRIDE;
88 virtual void reallySetLoop(bool status) OVERRIDE;
89 virtual void stop() OVERRIDE;
90 virtual void reallyStopNow() OVERRIDE;
91 virtual void pause() OVERRIDE;
92 virtual void reallyPauseNow() OVERRIDE;
93 virtual void resume() OVERRIDE;
94 virtual void reallyResumeNow() OVERRIDE;
95 virtual void deleteSFX() OVERRIDE;
96 virtual void setSpeed(float factor) OVERRIDE;
97 virtual void reallySetSpeed(float factor) OVERRIDE;
98 virtual void setPosition(const Vec3 &position) OVERRIDE;
99 virtual void reallySetPosition(const Vec3 &p) OVERRIDE;
100 virtual void setSpeedPosition(float factor, const Vec3 &p) OVERRIDE;
101 virtual void reallySetSpeedPosition(float f,const Vec3 &p) OVERRIDE;
102 virtual void setVolume(float volume) OVERRIDE;
103 virtual void reallySetVolume(float volume) OVERRIDE;
104 virtual void setMasterVolume(float volume) OVERRIDE;
105 virtual void reallySetMasterVolumeNow(float volue) OVERRIDE;
106 virtual void onSoundEnabledBack() OVERRIDE;
107 virtual void setRolloff(float rolloff) OVERRIDE;
108 // ------------------------------------------------------------------------
110 virtual bool isLooped() OVERRIDE { return m_loop; }
111 // ------------------------------------------------------------------------
113 virtual SFXStatus getStatus() OVERRIDE { return m_status; }
114
115 // ------------------------------------------------------------------------
117 virtual SFXBuffer* getBuffer() const OVERRIDE
118 { return m_sound_buffer; }
119
120}; // SFXOpenAL
121
122#endif
123#endif // HEADER_SFX_OPENAL_HPP
124
The base class for sound effects.
Definition: sfx_base.hpp:43
The buffer (data) for one kind of sound effects.
Definition: sfx_buffer.hpp:44
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35