Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
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
15
#include "
roc_core/noncopyable.h
"
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
22
#include "
roc_sndio/pulseaudio_backend.h
"
23
#endif
// ROC_TARGET_PULSEAUDIO
24
25
#ifdef ROC_TARGET_SNDFILE
26
#include "
roc_sndio/sndfile_backend.h
"
27
#endif
// ROC_TARGET_SNDFILE
28
29
#ifdef ROC_TARGET_SOX
30
#include "
roc_sndio/sox_backend.h
"
31
#endif
// ROC_TARGET_SOX
32
33
#include "
roc_sndio/wav_backend.h
"
34
35
namespace
roc
{
36
namespace
sndio
{
37
38
//! Backend map.
39
class
BackendMap :
public
core::NonCopyable
<> {
40
public
:
41
//! Get instance.
42
static
BackendMap&
instance
() {
43
return
core::Singleton<BackendMap>::instance
();
44
}
45
46
//! Get number of backends available.
47
size_t
num_backends
()
const
;
48
49
//! Get backend by index.
50
IBackend
&
nth_backend
(
size_t
backend_index)
const
;
51
52
//! Get number of drivers available.
53
size_t
num_drivers
()
const
;
54
55
//! Get driver by index.
56
const
DriverInfo
&
nth_driver
(
size_t
driver_index)
const
;
57
58
//! Set internal buffer size for all backends that need it.
59
void
set_frame_size
(
core::nanoseconds_t
frame_length,
60
const
audio::SampleSpec
& sample_spec);
61
62
private
:
63
friend
class
core::Singleton
<BackendMap>;
64
65
BackendMap();
66
67
void
register_backends_();
68
void
register_drivers_();
69
70
void
add_backend_(
IBackend
*);
71
72
#ifdef ROC_TARGET_PULSEAUDIO
73
core::Optional<PulseaudioBackend>
pulseaudio_backend_;
74
#endif
// ROC_TARGET_PULSEAUDIO
75
76
#ifdef ROC_TARGET_SNDFILE
77
core::Optional<SndfileBackend>
sndfile_backend_;
78
#endif
// ROC_TARGET_SNDFILE
79
80
#ifdef ROC_TARGET_SOX
81
core::Optional<SoxBackend>
sox_backend_;
82
#endif
// ROC_TARGET_SOX
83
84
core::Optional<WavBackend>
wav_backend_;
85
86
core::Array<IBackend*, MaxBackends>
backends_;
87
core::Array<DriverInfo, MaxDrivers>
drivers_;
88
};
89
90
}
// namespace sndio
91
}
// namespace roc
92
93
#endif
// ROC_SNDIO_BACKEND_MAP_H_
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition
sample_spec.h:30
roc::core::Array
Dynamic array.
Definition
array.h:40
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::core::Optional
Optionally constructed object.
Definition
optional.h:25
roc::core::Singleton
Singleton.
Definition
singleton.h:26
roc::core::Singleton::instance
static T & instance()
Get singleton instance.
Definition
singleton.h:29
roc::sndio::BackendMap::nth_driver
const DriverInfo & nth_driver(size_t driver_index) const
Get driver by index.
roc::sndio::BackendMap::instance
static BackendMap & instance()
Get instance.
Definition
backend_map.h:42
roc::sndio::BackendMap::set_frame_size
void set_frame_size(core::nanoseconds_t frame_length, const audio::SampleSpec &sample_spec)
Set internal buffer size for all backends that need it.
roc::sndio::BackendMap::num_backends
size_t num_backends() const
Get number of backends available.
roc::sndio::BackendMap::num_drivers
size_t num_drivers() const
Get number of drivers available.
roc::sndio::BackendMap::nth_backend
IBackend & nth_backend(size_t backend_index) const
Get backend by index.
roc::sndio::IBackend
Backend interface.
Definition
ibackend.h:29
driver.h
Driver types.
ibackend.h
Backend interface.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::sndio
Sound I/O.
roc
Root namespace.
noncopyable.h
Non-copyable object.
optional.h
Optionally constructed object.
pulseaudio_backend.h
Pulseaudio backend.
singleton.h
Singleton.
sndfile_backend.h
SndFile backend.
sox_backend.h
SoX backend.
roc::sndio::DriverInfo
Driver information.
Definition
driver.h:51
wav_backend.h
WAV backend.
roc_sndio
backend_map.h
Generated by
1.17.0