Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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 
15 #include "roc_audio/sample_spec.h"
16 #include "roc_core/stddefs.h"
17 #include "roc_core/time.h"
18 #include "roc_sndio/device_state.h"
19 #include "roc_sndio/device_type.h"
20 
21 namespace roc {
22 namespace sndio {
23 
24 //! Base interface for sinks and sources.
25 class IDevice {
26 public:
27  virtual ~IDevice();
28 
29  //! Get device type.
30  virtual DeviceType type() const = 0;
31 
32  //! Get device state.
33  virtual DeviceState state() const = 0;
34 
35  //! Pause device.
36  virtual void pause() = 0;
37 
38  //! Resume device after pause.
39  //! @returns
40  //! false if an error occured.
41  virtual bool resume() = 0;
42 
43  //! Restart device.
44  //! @remarks
45  //! If device was paused, it's automatically resumed.
46  //! @returns
47  //! false if an error occured.
48  virtual bool restart() = 0;
49 
50  //! Get sample specification of the device.
51  virtual audio::SampleSpec sample_spec() const = 0;
52 
53  //! Get latency of the device.
54  virtual core::nanoseconds_t latency() const = 0;
55 
56  //! Check if the device supports latency reports.
57  virtual bool has_latency() const = 0;
58 
59  //! Check if the device has own clock.
60  virtual bool has_clock() const = 0;
61 };
62 
63 } // namespace sndio
64 } // namespace roc
65 
66 #endif // ROC_SNDIO_IDEVICE_H_
Sample specification. Describes sample rate and channels.
Definition: sample_spec.h:26
Base interface for sinks and sources.
Definition: idevice.h:25
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 bool has_latency() const =0
Check if the device supports latency reports.
virtual bool resume()=0
Resume device after pause.
Device state.
Device type.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
DeviceType
Device type.
Definition: device_type.h:19
DeviceState
Device state.
Definition: device_state.h:19
Root namespace.
Sample specifications.
Commonly used types and functions.
Time definitions.