Audaspace
1.9.0
A high level audio library.
Toggle main menu visibility
Loading...
Searching...
No Matches
devices
MixingThreadDevice.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright 2009-2016 Jörg Müller
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
******************************************************************************/
16
17
#pragma once
18
24
25
#include <condition_variable>
26
#include <thread>
27
28
#include "
devices/SoftwareDevice.h
"
29
#include "
util/RingBuffer.h
"
30
31
AUD_NAMESPACE_BEGIN
32
36
class
AUD_PLUGIN_API
MixingThreadDevice :
public
SoftwareDevice
37
{
38
private
:
42
volatile
bool
m_playback{
false
};
43
47
Buffer
m_mixingBuffer;
48
52
RingBuffer
m_ringBuffer;
53
57
bool
m_valid{
false
};
58
62
std::thread m_mixingThread;
63
67
std::mutex m_mixingLock;
68
72
std::condition_variable m_mixingCondition;
73
77
AUD_LOCAL
void
updateRingBuffer();
78
79
// delete copy constructor and operator=
80
MixingThreadDevice(
const
MixingThreadDevice&) =
delete
;
81
MixingThreadDevice& operator=(
const
MixingThreadDevice&) =
delete
;
82
83
protected
:
88
void
startMixingThread
(
size_t
buffersize);
89
93
void
notifyMixingThread
();
94
98
inline
RingBuffer
&
getRingBuffer
()
99
{
100
return
m_ringBuffer;
101
}
102
106
inline
bool
isMixingThreadRunning
()
107
{
108
return
m_valid;
109
}
110
111
virtual
void
playing
(
bool
playing
);
112
116
virtual
void
preMixingWork
(
bool
playing
);
117
122
MixingThreadDevice
();
123
128
void
stopMixingThread
();
129
};
130
131
AUD_NAMESPACE_END
AUD_NAMESPACE_END
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition
Audaspace.h:119
AUD_LOCAL
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition
Audaspace.h:80
AUD_NAMESPACE_BEGIN
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition
Audaspace.h:116
AUD_PLUGIN_API
#define AUD_PLUGIN_API
Used for exporting symbols in the shared library.
Definition
Audaspace.h:94
RingBuffer.h
The RingBuffer class.
SoftwareDevice.h
The SoftwareDevice class.
Buffer
This class is a simple buffer in RAM which is 32 Byte aligned and provides resize functionality.
Definition
Buffer.h:34
MixingThreadDevice::isMixingThreadRunning
bool isMixingThreadRunning()
Returns whether the thread is running or not.
Definition
MixingThreadDevice.h:106
MixingThreadDevice::notifyMixingThread
void notifyMixingThread()
Notify the mixing thread.
MixingThreadDevice::playing
virtual void playing(bool playing)
This function tells the device, to start or pause playback.
MixingThreadDevice::preMixingWork
virtual void preMixingWork(bool playing)
Called every iteration in the mixing thread before mixing.
MixingThreadDevice::MixingThreadDevice
MixingThreadDevice()
Empty default constructor.
MixingThreadDevice::startMixingThread
void startMixingThread(size_t buffersize)
Starts the streaming thread.
MixingThreadDevice::stopMixingThread
void stopMixingThread()
Stops all playback and notifies the mixing thread to stop.
MixingThreadDevice::getRingBuffer
RingBuffer & getRingBuffer()
Get ring buffer for reading.
Definition
MixingThreadDevice.h:98
RingBuffer
This class is a simple ring buffer in RAM which is 32 Byte aligned and provides functionality for con...
Definition
RingBuffer.h:37
SoftwareDevice::SoftwareDevice
SoftwareDevice()
Empty default constructor.
Generated by
1.17.0