Audaspace  1.4.0
A high level audio library.
DeviceManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2009-2016 Jörg Müller
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 "Audaspace.h"
26 
27 #include <memory>
28 #include <vector>
29 #include <unordered_map>
30 #include <string>
31 
33 
34 class IDevice;
35 class IDeviceFactory;
36 class I3DDevice;
37 
45 {
46 private:
47  static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
48 
49  static std::shared_ptr<IDevice> m_device;
50 
51  // delete copy constructor and operator=
52  DeviceManager(const DeviceManager&) = delete;
53  DeviceManager& operator=(const DeviceManager&) = delete;
54  DeviceManager() = delete;
55 
56 public:
65  static void registerDevice(std::string name, std::shared_ptr<IDeviceFactory> factory);
66 
72  static std::shared_ptr<IDeviceFactory> getDeviceFactory(std::string name);
73 
78  static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
79 
80 
87  static void setDevice(std::shared_ptr<IDevice> device);
88 
95  static void openDevice(std::string name);
96 
103  static void openDefaultDevice();
104 
108  static void releaseDevice();
109 
114  static std::shared_ptr<IDevice> getDevice();
115 
121  static std::shared_ptr<I3DDevice> get3DDevice();
122 
127  static std::vector<std::string> getAvailableDeviceNames();
128 };
129 
#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 IDeviceFactory interface opens an output device.
Definition: IDeviceFactory.h:35
The I3DDevice interface represents an output device for 3D sound.
Definition: I3DDevice.h:52
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition: Audaspace.h:119
The IDevice interface represents an output device for sound sources.
Definition: IDevice.h:46
The main header file of the library defining the namespace and basic data types.
This class manages all device plugins and maintains a device if asked to do so.
Definition: DeviceManager.h:44