Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
pump.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 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/pump.h
10
//! @brief Pump.
11
12
#ifndef ROC_SNDIO_PUMP_H_
13
#define ROC_SNDIO_PUMP_H_
14
15
#include "
roc_core/atomic.h
"
16
#include "
roc_core/buffer_pool.h
"
17
#include "
roc_core/noncopyable.h
"
18
#include "
roc_core/slice.h
"
19
#include "
roc_core/stddefs.h
"
20
#include "
roc_sndio/isink.h
"
21
#include "
roc_sndio/isource.h
"
22
23
namespace
roc
{
24
namespace
sndio {
25
26
//! Audio pump.
27
//! @remarks
28
//! Reads frames from source and writes them to sink.
29
class
Pump
:
public
core::NonCopyable
<> {
30
public
:
31
//! Pump mode.
32
enum
Mode
{
33
// Run until the source return EOF.
34
ModePermanent = 0,
35
36
// Run until the source return EOF or become inactive first time.
37
ModeOneshot = 1
38
};
39
40
//! Initialize.
41
Pump
(
core::BufferPool<audio::sample_t>
& buffer_pool,
42
ISource
& source,
43
ISink
& sink,
44
size_t
frame_size,
45
Mode
mode);
46
47
//! Check if the object was successfulyl constructed.
48
bool
valid
()
const
;
49
50
//! Run the pump.
51
//! @remarks
52
//! Run until the stop() is called or, if oneshot mode is enabled,
53
//! the source becomes inactive.
54
bool
run
();
55
56
//! Stop the pump.
57
//! @remarks
58
//! May be called from any thread.
59
void
stop
();
60
61
private
:
62
ISource
& source_;
63
ISink
& sink_;
64
65
core::Slice<audio::sample_t>
frame_buffer_;
66
67
size_t
n_bufs_;
68
const
bool
oneshot_;
69
70
core::Atomic
stop_;
71
};
72
73
}
// namespace sndio
74
}
// namespace roc
75
76
#endif
// ROC_SNDIO_PUMP_H_
atomic.h
Atomic integer.
buffer_pool.h
Buffer pool.
roc::core::Atomic
Atomic integer.
Definition:
atomic.h:21
roc::core::BufferPool
Buffer pool.
Definition:
buffer_pool.h:23
roc::core::NonCopyable
Base class for non-copyable objects.
Definition:
noncopyable.h:23
roc::core::Slice
Slice.
Definition:
slice.h:23
roc::sndio::ISink
Sink interface.
Definition:
isink.h:21
roc::sndio::ISource
Source interface.
Definition:
isource.h:21
roc::sndio::Pump
Audio pump.
Definition:
pump.h:29
roc::sndio::Pump::stop
void stop()
Stop the pump.
roc::sndio::Pump::run
bool run()
Run the pump.
roc::sndio::Pump::Mode
Mode
Pump mode.
Definition:
pump.h:32
roc::sndio::Pump::valid
bool valid() const
Check if the object was successfulyl constructed.
roc::sndio::Pump::Pump
Pump(core::BufferPool< audio::sample_t > &buffer_pool, ISource &source, ISink &sink, size_t frame_size, Mode mode)
Initialize.
isink.h
Sink interface.
isource.h
Source interface.
roc
Root namespace.
noncopyable.h
Non-copyable object.
slice.h
Slice.
stddefs.h
Commonly used types and functions.
roc_sndio
pump.h
Generated by
1.9.5