Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
PlaybackManager.h
Go to the documentation of this file.
1/*******************************************************************************
2* Copyright 2015-2016 Juan Francisco Crespo Galán
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15******************************************************************************/
16
17#pragma once
18
25#include "PlaybackCategory.h"
26#include "devices/IDevice.h"
27#include "ISound.h"
28
29#include <unordered_map>
30#include <memory>
31
33
39{
40private:
44 std::unordered_map<unsigned int, std::shared_ptr<PlaybackCategory>> m_categories;
45
49 std::shared_ptr<IDevice> m_device;
50
54 unsigned int m_currentKey;
55
56 // delete copy constructor and operator=
57 PlaybackManager(const PlaybackManager&) = delete;
58 PlaybackManager& operator=(const PlaybackManager&) = delete;
59
60public:
65 PlaybackManager(std::shared_ptr<IDevice> device);
66
72 unsigned int addCategory(std::shared_ptr<PlaybackCategory> category);
73
79 unsigned int addCategory(float volume);
80
87 std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound, unsigned int catKey);
88
96 bool resume(unsigned int catKey);
97
105 bool pause(unsigned int catKey);
106
112 float getVolume(unsigned int catKey);
113
122 bool setVolume(float volume, unsigned int catKey);
123
131 bool stop(unsigned int catKey);
132
137 void clean();
138
147 bool clean(unsigned int catKey);
148
153 std::shared_ptr<IDevice> getDevice();
154};
155
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition Audaspace.h:119
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition Audaspace.h:116
#define AUD_API
Used for exporting symbols in the shared library.
Definition Audaspace.h:93
The IDevice interface.
The ISound interface.
The PlaybackCategory class.
This class allows to control groups of playing sounds easily.
Definition PlaybackManager.h:39
bool pause(unsigned int catKey)
Pauses all current playing sounds of a category.
bool clean(unsigned int catKey)
Removes all the invalid handles of a category.
bool setVolume(float volume, unsigned int catKey)
Sets the volume for a category.
std::shared_ptr< IDevice > getDevice()
Retrieves the device of the PlaybackManager.
bool stop(unsigned int catKey)
Stops and erases a category of sounds.
PlaybackManager(std::shared_ptr< IDevice > device)
Creates a new PlaybackManager.
unsigned int addCategory(float volume)
Adds an existent category to the manager and returns a key to access it.
std::shared_ptr< IHandle > play(std::shared_ptr< ISound > sound, unsigned int catKey)
Plays a sound and adds it to a new or existent category.
float getVolume(unsigned int catKey)
Retrieves the volume of a category.
bool resume(unsigned int catKey)
Resumes all the paused sounds of a category.
void clean()
Removes all the invalid handles of all the categories.
unsigned int addCategory(std::shared_ptr< PlaybackCategory > category)
Adds an existent category to the manager and returns a key to access it.