Audaspace 1.10.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
24
25#include "Audaspace.h"
27
28#include <memory>
29#include <vector>
30#include <unordered_map>
31#include <string>
32
34
35class IDevice;
36class IDeviceFactory;
38class I3DDevice;
39class IReader;
40
47class AUD_API DeviceManager
48{
49private:
50 static std::unordered_map<std::string, std::shared_ptr<IDeviceFactory>> m_factories;
51
52 static std::shared_ptr<IDevice> m_device;
53 static std::unordered_map<std::string, std::shared_ptr<ICaptureDeviceFactory>> m_capture_factories;
54
55 // delete copy constructor and operator=
56 DeviceManager(const DeviceManager&) = delete;
57 DeviceManager& operator=(const DeviceManager&) = delete;
58 DeviceManager() = delete;
59
60public:
69 static void registerDevice(const std::string &name, std::shared_ptr<IDeviceFactory> factory);
70
76 static std::shared_ptr<IDeviceFactory> getDeviceFactory(const std::string &name);
77
82 static std::shared_ptr<IDeviceFactory> getDefaultDeviceFactory();
83
84
91 static void setDevice(std::shared_ptr<IDevice> device);
92
99 static void openDevice(const std::string &name);
100
107 static void openDefaultDevice();
108
112 static void releaseDevice();
113
118 static std::shared_ptr<IDevice> getDevice();
119
125 static std::shared_ptr<I3DDevice> get3DDevice();
126
131 static std::vector<std::string> getAvailableDeviceNames();
132
137 static std::vector<std::string> getAvailableCaptureDeviceNames();
138
144 static std::shared_ptr<ICaptureDeviceFactory> getCaptureDeviceFactory(const std::string& name);
145
151 static void registerCaptureDevice(const std::string& name, std::shared_ptr<ICaptureDeviceFactory> factory);
152
159 static std::shared_ptr<IReader> openCaptureDevice(const std::string& name,
160 Specs specs,
161 int buffersize = AUD_DEFAULT_BUFFER_SIZE);
162
163};
164
The main header file of the library defining the namespace and basic data types.
#define AUD_DEFAULT_BUFFER_SIZE
The default playback buffer size of a device.
Definition Audaspace.h:103
#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
Defines all important macros and basic data structures for stream format descriptions.
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::vector< std::string > getAvailableCaptureDeviceNames()
Returns a list of available capture devices.
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 std::shared_ptr< IReader > openCaptureDevice(const std::string &name, Specs specs, int buffersize=AUD_DEFAULT_BUFFER_SIZE)
Opens an input capture reader.
static void registerCaptureDevice(const std::string &name, std::shared_ptr< ICaptureDeviceFactory > factory)
Registers a capture device factory.
static void registerDevice(const std::string &name, std::shared_ptr< IDeviceFactory > factory)
Registers a device factory.
static std::shared_ptr< ICaptureDeviceFactory > getCaptureDeviceFactory(const std::string &name)
Returns the factory for a specific capture device.
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 ICaptureDeviceFactory interface opens an input capture device.
Definition ICaptureDeviceFactory.h:24
The IDeviceFactory interface opens an output device.
Definition IDeviceFactory.h:36
The IDevice interface represents an output device for sound sources.
Definition IDevice.h:46
This class represents a sound source as stream or as buffer which can be read for example by another ...
Definition IReader.h:35
192000 Hz.
Definition Specification.h:116