Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
driver.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Roc 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/driver.h
10
//! @brief Driver types.
11
12
#ifndef ROC_SNDIO_DRIVER_H_
13
#define ROC_SNDIO_DRIVER_H_
14
15
#include "
roc_core/panic.h
"
16
#include "
roc_core/stddefs.h
"
17
18
namespace
roc
{
19
namespace
sndio
{
20
21
class
IBackend
;
22
23
//! Maximum number of drivers.
24
static
const
size_t
MaxDrivers = 128;
25
26
//! Driver type.
27
enum
DriverType
{
28
//! Invalid type.
29
DriverType_Invalid
,
30
31
//! Driver for audio files.
32
DriverType_File
,
33
34
//! Driver for audio devices.
35
DriverType_Device
36
};
37
38
//! Driver flags.
39
enum
DriverFlags
{
40
//! Driver is used if no file or device is specified.
41
DriverFlag_IsDefault
= (1 << 0),
42
43
//! Driver supports sources (input).
44
DriverFlag_SupportsSource
= (1 << 1),
45
46
//! Driver supports sinks (output).
47
DriverFlag_SupportsSink
= (1 << 2)
48
};
49
50
//! Driver information.
51
struct
DriverInfo
{
52
//! Driver name.
53
char
name
[20];
54
55
//! Driver type.
56
DriverType
type
;
57
58
//! Driver flags.
59
unsigned
int
flags
;
60
61
//! Backend the driver uses.
62
IBackend
*
backend
;
63
64
//! Initialize.
65
DriverInfo
()
66
:
type
(
DriverType_Invalid
)
67
,
flags
(0)
68
,
backend
(NULL) {
69
strcpy(
name
,
""
);
70
}
71
72
//! Initialize.
73
DriverInfo
(
const
char
* driver_name,
74
DriverType
driver_type,
75
unsigned
int
driver_flags,
76
IBackend
* driver_backend)
77
:
type
(driver_type)
78
,
flags
(driver_flags)
79
,
backend
(driver_backend) {
80
if
(!driver_name || strlen(driver_name) >
sizeof
(
name
) - 1) {
81
roc_panic
(
"invalid driver name"
);
82
}
83
strcpy(
name
, driver_name);
84
}
85
};
86
87
//! Convert driver type to string.
88
const
char
*
driver_type_to_str
(
DriverType
type);
89
90
}
// namespace sndio
91
}
// namespace roc
92
93
#endif
// ROC_SNDIO_DRIVER_H_
roc::sndio::IBackend
Backend interface.
Definition
ibackend.h:29
roc::sndio
Sound I/O.
roc::sndio::DriverFlags
DriverFlags
Driver flags.
Definition
driver.h:39
roc::sndio::DriverFlag_IsDefault
@ DriverFlag_IsDefault
Driver is used if no file or device is specified.
Definition
driver.h:41
roc::sndio::DriverFlag_SupportsSink
@ DriverFlag_SupportsSink
Driver supports sinks (output).
Definition
driver.h:47
roc::sndio::DriverFlag_SupportsSource
@ DriverFlag_SupportsSource
Driver supports sources (input).
Definition
driver.h:44
roc::sndio::driver_type_to_str
const char * driver_type_to_str(DriverType type)
Convert driver type to string.
roc::sndio::DriverType
DriverType
Driver type.
Definition
driver.h:27
roc::sndio::DriverType_Invalid
@ DriverType_Invalid
Invalid type.
Definition
driver.h:29
roc::sndio::DriverType_Device
@ DriverType_Device
Driver for audio devices.
Definition
driver.h:35
roc::sndio::DriverType_File
@ DriverType_File
Driver for audio files.
Definition
driver.h:32
roc
Root namespace.
panic.h
Panic.
roc_panic
#define roc_panic(...)
Print error message and terminate program gracefully.
Definition
panic.h:50
stddefs.h
Commonly used types and functions.
roc::sndio::DriverInfo::type
DriverType type
Driver type.
Definition
driver.h:56
roc::sndio::DriverInfo::DriverInfo
DriverInfo()
Initialize.
Definition
driver.h:65
roc::sndio::DriverInfo::DriverInfo
DriverInfo(const char *driver_name, DriverType driver_type, unsigned int driver_flags, IBackend *driver_backend)
Initialize.
Definition
driver.h:73
roc::sndio::DriverInfo::name
char name[20]
Driver name.
Definition
driver.h:53
roc::sndio::DriverInfo::backend
IBackend * backend
Backend the driver uses.
Definition
driver.h:62
roc::sndio::DriverInfo::flags
unsigned int flags
Driver flags.
Definition
driver.h:59
roc_sndio
driver.h
Generated by
1.17.0