Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pulseaudio_source.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/target_pulseaudio/roc_sndio/pulseaudio_source.h
10 //! @brief PulseAudio source.
11 
12 #ifndef ROC_SNDIO_PULSEAUDIO_SOURCE_H_
13 #define ROC_SNDIO_PULSEAUDIO_SOURCE_H_
14 
15 #include "roc_sndio/isource.h"
17 
18 namespace roc {
19 namespace sndio {
20 
21 //! PulseAudio source,
22 class PulseaudioSource : public ISource, public PulseaudioDevice {
23 public:
24  //! Initialize.
25  PulseaudioSource(const Config& config);
26 
28 
29  //! Get device type.
30  virtual DeviceType type() const;
31 
32  //! Get device state.
33  virtual DeviceState state() const;
34 
35  //! Pause reading.
36  virtual void pause();
37 
38  //! Resume paused reading.
39  virtual bool resume();
40 
41  //! Restart reading from the beginning.
42  virtual bool restart();
43 
44  //! Get sample specification of the source.
45  virtual audio::SampleSpec sample_spec() const;
46 
47  //! Get latency of the source.
48  virtual core::nanoseconds_t latency() const;
49 
50  //! Check if the source supports latency reports.
51  virtual bool has_latency() const;
52 
53  //! Check if the source has own clock.
54  virtual bool has_clock() const;
55 
56  //! Adjust source clock to match consumer clock.
58 
59  //! Read frame.
60  virtual bool read(audio::Frame& frame);
61 };
62 
63 } // namespace sndio
64 } // namespace roc
65 
66 #endif // ROC_SNDIO_PULSEAUDIO_SOURCE_H_
Audio frame.
Definition: frame.h:25
Sample specification. Describes sample rate and channels.
Definition: sample_spec.h:26
Source interface.
Definition: isource.h:23
PulseAudio device. Base class for PulseAudio source and sink.
virtual DeviceState state() const
Get device state.
virtual bool has_clock() const
Check if the source has own clock.
virtual void pause()
Pause reading.
virtual core::nanoseconds_t latency() const
Get latency of the source.
virtual audio::SampleSpec sample_spec() const
Get sample specification of the source.
virtual DeviceType type() const
Get device type.
PulseaudioSource(const Config &config)
Initialize.
virtual bool read(audio::Frame &frame)
Read frame.
virtual bool resume()
Resume paused reading.
virtual void reclock(core::nanoseconds_t timestamp)
Adjust source clock to match consumer clock.
virtual bool restart()
Restart reading from the beginning.
virtual bool has_latency() const
Check if the source supports latency reports.
Source interface.
nanoseconds_t timestamp(clock_t clock)
Get current timestamp in nanoseconds.
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.
PulseAudio device.
Sink and source config.
Definition: config.h:29