Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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
18namespace roc {
19namespace sndio {
20
21class IBackend;
22
23//! Maximum number of drivers.
24static const size_t MaxDrivers = 128;
25
26//! Driver type.
28 //! Invalid type.
30
31 //! Driver for audio files.
33
34 //! Driver for audio devices.
36};
37
38//! Driver flags.
40 //! Driver is used if no file or device is specified.
42
43 //! Driver supports sources (input).
45
46 //! Driver supports sinks (output).
48};
49
50//! Driver information.
51struct DriverInfo {
52 //! Driver name.
53 char name[20];
54
55 //! Driver type.
57
58 //! Driver flags.
59 unsigned int flags;
60
61 //! Backend the driver uses.
63
64 //! Initialize.
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.
89
90} // namespace sndio
91} // namespace roc
92
93#endif // ROC_SNDIO_DRIVER_H_
Backend interface.
Definition ibackend.h:29
DriverFlags
Driver flags.
Definition driver.h:39
@ DriverFlag_IsDefault
Driver is used if no file or device is specified.
Definition driver.h:41
@ DriverFlag_SupportsSink
Driver supports sinks (output).
Definition driver.h:47
@ DriverFlag_SupportsSource
Driver supports sources (input).
Definition driver.h:44
const char * driver_type_to_str(DriverType type)
Convert driver type to string.
DriverType
Driver type.
Definition driver.h:27
@ DriverType_Invalid
Invalid type.
Definition driver.h:29
@ DriverType_Device
Driver for audio devices.
Definition driver.h:35
@ DriverType_File
Driver for audio files.
Definition driver.h:32
Root namespace.
Panic.
#define roc_panic(...)
Print error message and terminate program gracefully.
Definition panic.h:50
Commonly used types and functions.
Driver information.
Definition driver.h:51
DriverType type
Driver type.
Definition driver.h:56
DriverInfo()
Initialize.
Definition driver.h:65
DriverInfo(const char *driver_name, DriverType driver_type, unsigned int driver_flags, IBackend *driver_backend)
Initialize.
Definition driver.h:73
char name[20]
Driver name.
Definition driver.h:53
IBackend * backend
Backend the driver uses.
Definition driver.h:62
unsigned int flags
Driver flags.
Definition driver.h:59