Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
PlaybackCategory.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 "devices/IHandle.h"
26#include "devices/IDevice.h"
27#include "VolumeStorage.h"
28
29#include <unordered_map>
30#include <memory>
31
33
38{
39private:
43 unsigned int m_currentID;
44
48 std::unordered_map<unsigned int, std::shared_ptr<IHandle>> m_handles;
49
53 std::shared_ptr<IDevice> m_device;
54
58 Status m_status;
59
63 std::shared_ptr<VolumeStorage> m_volumeStorage;
64
65 // delete copy constructor and operator=
66 PlaybackCategory(const PlaybackCategory&) = delete;
67 PlaybackCategory& operator=(const PlaybackCategory&) = delete;
68
69public:
74 PlaybackCategory(std::shared_ptr<IDevice> device);
76
82 std::shared_ptr<IHandle> play(std::shared_ptr<ISound> sound);
83
87 void resume();
88
92 void pause();
93
98 float getVolume();
99
104 void setVolume(float volume);
105
109 void stop();
110
115 std::shared_ptr<VolumeStorage> getSharedVolume();
116
122
123private:
124 static void cleanHandleCallback(void* data);
125};
126
#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.
Defines the IHandle interface as well as possible states of the handle.
Status
Status of a playback handle.
Definition IHandle.h:31
The VolumeStorage class.
This class represents a category of related sounds which are currently playing and allows to control ...
Definition PlaybackCategory.h:38
float getVolume()
Retrieves the volume of the category.
void cleanHandles()
Cleans the category erasing all the invalid handles.
void resume()
Resumes all the paused sounds of the category.
PlaybackCategory(std::shared_ptr< IDevice > device)
Creates a new PlaybackCategory.
void setVolume(float volume)
Sets the volume for the category.
void stop()
Stops all the playing back or paused sounds.
void pause()
Pauses all current played back sounds of the category.
std::shared_ptr< IHandle > play(std::shared_ptr< ISound > sound)
Plays a new sound in the category.
std::shared_ptr< VolumeStorage > getSharedVolume()
Retrieves the shared volume of the category.