Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
idevice.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/idevice.h
10//! @brief Device interface.
11
12#ifndef ROC_SNDIO_IDEVICE_H_
13#define ROC_SNDIO_IDEVICE_H_
14
16#include "roc_core/stddefs.h"
17#include "roc_core/time.h"
20
21namespace roc {
22namespace sndio {
23
24class ISink;
25class ISource;
26
27//! Base interface for sinks and sources.
28class IDevice {
29public:
30 virtual ~IDevice();
31
32 //! Cast IDevice to ISink.
33 virtual ISink* to_sink() = 0;
34
35 //! Cast IDevice to ISink.
36 virtual ISource* to_source() = 0;
37
38 //! Get device type.
39 virtual DeviceType type() const = 0;
40
41 //! Get device state.
42 virtual DeviceState state() const = 0;
43
44 //! Pause device.
45 virtual void pause() = 0;
46
47 //! Resume device after pause.
48 //! @returns
49 //! false if an error occurred.
50 virtual bool resume() = 0;
51
52 //! Restart device.
53 //! @remarks
54 //! If device was paused, it's automatically resumed.
55 //! @returns
56 //! false if an error occurred.
57 virtual bool restart() = 0;
58
59 //! Get sample specification of the device.
60 virtual audio::SampleSpec sample_spec() const = 0;
61
62 //! Get latency of the device.
63 virtual core::nanoseconds_t latency() const = 0;
64
65 //! Check if the device supports latency reports.
66 virtual bool has_latency() const = 0;
67
68 //! Check if the device has own clock.
69 virtual bool has_clock() const = 0;
70};
71
72} // namespace sndio
73} // namespace roc
74
75#endif // ROC_SNDIO_IDEVICE_H_
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:30
Base interface for sinks and sources.
Definition idevice.h:28
virtual audio::SampleSpec sample_spec() const =0
Get sample specification of the device.
virtual bool has_clock() const =0
Check if the device has own clock.
virtual void pause()=0
Pause device.
virtual bool restart()=0
Restart device.
virtual core::nanoseconds_t latency() const =0
Get latency of the device.
virtual DeviceState state() const =0
Get device state.
virtual DeviceType type() const =0
Get device type.
virtual ISource * to_source()=0
Cast IDevice to ISink.
virtual bool has_latency() const =0
Check if the device supports latency reports.
virtual bool resume()=0
Resume device after pause.
virtual ISink * to_sink()=0
Cast IDevice to ISink.
Sink interface.
Definition isink.h:22
Source interface.
Definition isource.h:23
Device state.
Device type.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
DeviceType
Device type.
Definition device_type.h:19
DeviceState
Device state.
Root namespace.
Sample specifications.
Commonly used types and functions.
Time definitions.