Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
SDLWrapper.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_WRAPPER_SDL_H_
34#define DVD_WRAPPER_SDL_H_
35
37
38typedef struct _Mix_Music Mix_Music;
39struct Mix_Chunk;
40
41namespace Divide {
42
43class SDL_API final : public AudioAPIWrapper {
44public:
45 explicit SDL_API( PlatformContext& context );
46
47 ErrorCode initAudioAPI() override;
48 void closeAudioAPI() override;
49
50 void playSound(const Handle<AudioDescriptor> sound) override;
51 void playMusic(const Handle<AudioDescriptor> music) override;
52
53 void stopMusic() noexcept override;
54 void stopAllSounds() noexcept override {}
55 void pauseMusic() noexcept override {}
56
57 void setMusicVolume(I8) noexcept override {}
58 void setSoundVolume(I8) noexcept override {}
59
60protected:
61 void musicFinished() noexcept override;
62
63private:
65 using SoundMap = hashMap<U32, Mix_Chunk*>;
66
69};
70
71}; // namespace Divide
72
73#endif //DVD_WRAPPER_SDL_H_
struct _Mix_Music Mix_Music
Definition: SDLWrapper.h:38
Audio Programming Interface.
PlatformContext & context() noexcept
void playMusic(const Handle< AudioDescriptor > music) override
Definition: SDLWrapper.cpp:85
hashMap< U32, Mix_Music * > MusicMap
Definition: SDLWrapper.h:64
void stopAllSounds() noexcept override
Definition: SDLWrapper.h:54
SoundMap _soundMap
Definition: SDLWrapper.h:68
void closeAudioAPI() override
Definition: SDLWrapper.cpp:60
MusicMap _musicMap
Definition: SDLWrapper.h:67
ErrorCode initAudioAPI() override
Definition: SDLWrapper.cpp:32
void musicFinished() noexcept override
Definition: SDLWrapper.cpp:81
void playSound(const Handle< AudioDescriptor > sound) override
Definition: SDLWrapper.cpp:129
void setMusicVolume(I8) noexcept override
Definition: SDLWrapper.h:57
void stopMusic() noexcept override
Definition: SDLWrapper.cpp:76
hashMap< U32, Mix_Chunk * > SoundMap
Definition: SDLWrapper.h:65
void pauseMusic() noexcept override
Definition: SDLWrapper.h:55
void setSoundVolume(I8) noexcept override
Definition: SDLWrapper.h:58
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55
uint32_t U32