Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
backend_map.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_sndio/backend_map.h
10//! @brief Backend map.
11
12#ifndef ROC_SNDIO_BACKEND_MAP_H_
13#define ROC_SNDIO_BACKEND_MAP_H_
14
16#include "roc_core/optional.h"
17#include "roc_core/singleton.h"
18#include "roc_sndio/driver.h"
19#include "roc_sndio/ibackend.h"
20
21#ifdef ROC_TARGET_PULSEAUDIO
23#endif // ROC_TARGET_PULSEAUDIO
24
25#ifdef ROC_TARGET_SOX
27#endif // ROC_TARGET_SOX
28
29namespace roc {
30namespace sndio {
31
32//! Backend map.
33class BackendMap : public core::NonCopyable<> {
34public:
35 //! Get instance.
39
40 //! Get number of backends available.
41 size_t num_backends() const;
42
43 //! Get backend by index.
44 IBackend& nth_backend(size_t backend_index) const;
45
46 //! Get number of drivers available.
47 size_t num_drivers() const;
48
49 //! Get driver by index.
50 const DriverInfo& nth_driver(size_t driver_index) const;
51
52 //! Set internal buffer size for all backends that need it.
54 const audio::SampleSpec& sample_spec);
55
56private:
57 friend class core::Singleton<BackendMap>;
58
59 BackendMap();
60
61 void register_backends_();
62 void register_drivers_();
63
64 void add_backend_(IBackend*);
65
66#ifdef ROC_TARGET_PULSEAUDIO
67 core::Optional<PulseaudioBackend> pulseaudio_backend_;
68#endif // ROC_TARGET_PULSEAUDIO
69
70#ifdef ROC_TARGET_SOX
71 core::Optional<SoxBackend> sox_backend_;
72#endif // ROC_TARGET_SOX
73
76};
77
78} // namespace sndio
79} // namespace roc
80
81#endif // ROC_SNDIO_BACKEND_MAP_H_
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:26
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
static T & instance()
Get singleton instance.
Definition singleton.h:29
const DriverInfo & nth_driver(size_t driver_index) const
Get driver by index.
static BackendMap & instance()
Get instance.
Definition backend_map.h:36
void set_frame_size(core::nanoseconds_t frame_length, const audio::SampleSpec &sample_spec)
Set internal buffer size for all backends that need it.
size_t num_backends() const
Get number of backends available.
size_t num_drivers() const
Get number of drivers available.
IBackend & nth_backend(size_t backend_index) const
Get backend by index.
Backend interface.
Definition ibackend.h:29
Driver types.
Backend interface.
Root namespace.
Non-copyable object.
Optionally constructed object.
Pulseaudio backend.
Singleton.
SoX backend.
Driver information.
Definition driver.h:51