Audaspace 1.7.0
A high level audio library.
Loading...
Searching...
No Matches
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
29#include "util/RingBuffer.h"
30
32
36class AUD_PLUGIN_API MixingThreadDevice : public SoftwareDevice
37{
38private:
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
83protected:
88 void startMixingThread(size_t buffersize);
89
94
99 {
100 return m_ringBuffer;
101 }
102
107 {
108 return m_valid;
109 }
110
111 virtual void playing(bool playing);
112
116 virtual void preMixingWork(bool playing);
117
123
129};
130
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition Audaspace.h:119
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition Audaspace.h:80
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition Audaspace.h:116
#define AUD_PLUGIN_API
Used for exporting symbols in the shared library.
Definition Audaspace.h:94
The RingBuffer class.
The SoftwareDevice class.
This class is a simple buffer in RAM which is 32 Byte aligned and provides resize functionality.
Definition Buffer.h:34
bool isMixingThreadRunning()
Returns whether the thread is running or not.
Definition MixingThreadDevice.h:106
void notifyMixingThread()
Notify the mixing thread.
virtual void playing(bool playing)
This function tells the device, to start or pause playback.
virtual void preMixingWork(bool playing)
Called every iteration in the mixing thread before mixing.
MixingThreadDevice()
Empty default constructor.
void startMixingThread(size_t buffersize)
Starts the streaming thread.
void stopMixingThread()
Stops all playback and notifies the mixing thread to stop.
RingBuffer & getRingBuffer()
Get ring buffer for reading.
Definition MixingThreadDevice.h:98
This class is a simple ring buffer in RAM which is 32 Byte aligned and provides functionality for con...
Definition RingBuffer.h:37
SoftwareDevice()
Empty default constructor.