Audaspace 1.5.0
A high level audio library.
Loading...
Searching...
No Matches
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
34class IDevice;
35class IDeviceFactory;
36class I3DDevice;
37
45{
46private:
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
56public:
65 static void registerDevice(const std::string &name, std::shared_ptr<IDeviceFactory> factory);
66
72 static std::shared_ptr<IDeviceFactory> getDeviceFactory(const 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(const 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
The main header file of the library defining the namespace and basic data types.
#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
This class manages all device plugins and maintains a device if asked to do so.
Definition DeviceManager.h:45
static std::shared_ptr< IDeviceFactory > getDeviceFactory(const std::string &name)
Returns the factory for a specific device.
static void releaseDevice()
Releases the currently handled device.
static std::shared_ptr< I3DDevice > get3DDevice()
Returns the currently handled 3D device.
static void setDevice(std::shared_ptr< IDevice > device)
Sets a device that should be handled by the manager.
static std::vector< std::string > getAvailableDeviceNames()
Returns a list of available devices.
static void openDevice(const std::string &name)
Opens a device which will then be handled by the manager.
static void registerDevice(const std::string &name, std::shared_ptr< IDeviceFactory > factory)
Registers a device factory.
static void openDefaultDevice()
Opens the default device which will then be handled by the manager.
static std::shared_ptr< IDeviceFactory > getDefaultDeviceFactory()
Returns the default device based on the priorities of the registered factories.
static std::shared_ptr< IDevice > getDevice()
Returns the currently handled device.
The I3DDevice interface represents an output device for 3D sound.
Definition I3DDevice.h:53
The IDeviceFactory interface opens an output device.
Definition IDeviceFactory.h:36
The IDevice interface represents an output device for sound sources.
Definition IDevice.h:47