Skip to content

Commit 3aa1a5d

Browse files
Rename AudioPort -> AudioBusHandle (LMMS#7712)
No functional changes.
1 parent cf4b492 commit 3aa1a5d

23 files changed

+510
-533
lines changed

include/AudioBusHandle.h

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* AudioBusHandle.h - ThreadableJob between PlayHandle and MixerChannel
3+
*
4+
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5+
* Copyright (c) 2025 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
6+
*
7+
* This file is part of LMMS - https://lmms.io
8+
*
9+
* This program is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 2 of the License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public
20+
* License along with this program (see COPYING); if not, write to the
21+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22+
* Boston, MA 02110-1301 USA.
23+
*
24+
*/
25+
26+
#ifndef LMMS_AUDIO_BUS_HANDLE_H
27+
#define LMMS_AUDIO_BUS_HANDLE_H
28+
29+
#include <memory>
30+
#include <QString>
31+
#include <QMutex>
32+
33+
#include "PlayHandle.h"
34+
35+
namespace lmms
36+
{
37+
38+
class EffectChain;
39+
class FloatModel;
40+
class BoolModel;
41+
42+
/**
43+
@brief Job between @ref PlayHandle and @ref MixerChannel
44+
45+
A @ref ThreadableJob class located at the exit point of each @ref PlayHandle into a @ref MixerChannel
46+
(or into an audio device, in case of @ref AudioJack, but this is not supported in AudioBusHandle yet).
47+
It contains an optional @ref EffectChain which is e.g. visualized in the
48+
@ref InstrumentTrackWindow or @ref SampleTrackWindow.
49+
For processing, it adds all input play handles into an internal buffer,
50+
processes the @ref EffectChain (if existing) on that buffer
51+
and finally merges the buffer into its @ref MixerChannel.
52+
*/
53+
class AudioBusHandle : public ThreadableJob
54+
{
55+
public:
56+
AudioBusHandle(const QString& name, bool hasEffectChain = true,
57+
FloatModel* volumeModel = nullptr, FloatModel* panningModel = nullptr,
58+
BoolModel* mutedModel = nullptr);
59+
virtual ~AudioBusHandle();
60+
61+
SampleFrame* buffer() { return m_buffer; }
62+
63+
// indicate whether JACK & Co should provide output-buffer at ext. port
64+
bool extOutputEnabled() const { return m_extOutputEnabled; }
65+
void setExtOutputEnabled(bool enabled);
66+
67+
// next mixer-channel after this audio-bus-handle
68+
// (-1 = none 0 = master)
69+
mix_ch_t nextMixerChannel() const { return m_nextMixerChannel; }
70+
void setNextMixerChannel(const mix_ch_t chnl) { m_nextMixerChannel = chnl; }
71+
72+
const QString& name() const { return m_name; }
73+
void setName(const QString& newName);
74+
75+
EffectChain* effects() { return m_effects.get(); }
76+
bool processEffects();
77+
78+
// ThreadableJob stuff
79+
void doProcessing() override;
80+
bool requiresProcessing() const override { return true; }
81+
82+
void addPlayHandle(PlayHandle* handle);
83+
void removePlayHandle(PlayHandle* handle);
84+
85+
private:
86+
volatile bool m_bufferUsage;
87+
88+
SampleFrame* const m_buffer;
89+
90+
bool m_extOutputEnabled;
91+
mix_ch_t m_nextMixerChannel;
92+
93+
QString m_name;
94+
95+
std::unique_ptr<EffectChain> m_effects;
96+
97+
PlayHandleList m_playHandles;
98+
QMutex m_playHandleLock;
99+
100+
FloatModel* m_volumeModel;
101+
FloatModel* m_panningModel;
102+
BoolModel* m_mutedModel;
103+
104+
friend class AudioEngine;
105+
friend class AudioEngineWorkerThread;
106+
};
107+
108+
} // namespace lmms
109+
110+
#endif // LMMS_AUDIO_BUS_HANDLE_H

include/AudioDevice.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace lmms
3636
{
3737

3838
class AudioEngine;
39-
class AudioPort;
39+
class AudioBusHandle;
4040
class SampleFrame;
4141

4242

@@ -57,13 +57,13 @@ class AudioDevice
5757
}
5858

5959

60-
// if audio-driver supports ports, classes inherting AudioPort
60+
// if audio-driver supports ports, classes inherting AudioBusHandle
6161
// (e.g. channel-tracks) can register themselves for making
6262
// audio-driver able to collect their individual output and provide
6363
// them at a specific port - currently only supported by JACK
64-
virtual void registerPort( AudioPort * _port );
65-
virtual void unregisterPort( AudioPort * _port );
66-
virtual void renamePort( AudioPort * _port );
64+
virtual void registerPort(AudioBusHandle* port);
65+
virtual void unregisterPort(AudioBusHandle* port);
66+
virtual void renamePort(AudioBusHandle* port);
6767

6868
inline bool supportsCapture() const
6969
{

include/AudioEngine.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace lmms
4747

4848
class AudioDevice;
4949
class MidiClient;
50-
class AudioPort;
50+
class AudioBusHandle;
5151
class AudioEngineWorkerThread;
5252

5353

@@ -172,15 +172,15 @@ class LMMS_EXPORT AudioEngine : public QObject
172172
}
173173

174174

175-
// audio-port-stuff
176-
inline void addAudioPort(AudioPort * port)
175+
// audio-bus-handle-stuff
176+
inline void addAudioBusHandle(AudioBusHandle* busHandle)
177177
{
178178
requestChangeInModel();
179-
m_audioPorts.push_back(port);
179+
m_audioBusHandles.push_back(busHandle);
180180
doneChangeInModel();
181181
}
182182

183-
void removeAudioPort(AudioPort * port);
183+
void removeAudioBusHandle(AudioBusHandle* busHandle);
184184

185185

186186
// MIDI-client-stuff
@@ -366,7 +366,7 @@ class LMMS_EXPORT AudioEngine : public QObject
366366

367367
bool m_renderOnly;
368368

369-
std::vector<AudioPort *> m_audioPorts;
369+
std::vector<AudioBusHandle*> m_audioBusHandles;
370370

371371
fpp_t m_framesPerPeriod;
372372

include/AudioJack.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@
3636

3737
#include <atomic>
3838
#include <vector>
39+
#ifdef AUDIO_BUS_HANDLE_SUPPORT
40+
#include <QMap>
41+
#endif
3942

4043
#include "AudioDevice.h"
4144
#include "AudioDeviceSetupWidget.h"
45+
#ifdef AUDIO_BUS_HANDLE_SUPPORT
46+
#include "AudioBusHandle.h"
47+
#endif
4248

4349
class QLineEdit;
4450

@@ -94,9 +100,9 @@ private slots:
94100
void startProcessing() override;
95101
void stopProcessing() override;
96102

97-
void registerPort(AudioPort* port) override;
98-
void unregisterPort(AudioPort* port) override;
99-
void renamePort(AudioPort* port) override;
103+
void registerPort(AudioBusHandle* port) override;
104+
void unregisterPort(AudioBusHandle* port) override;
105+
void renamePort(AudioBusHandle* port) override;
100106

101107
int processCallback(jack_nframes_t nframes);
102108

@@ -116,13 +122,13 @@ private slots:
116122
f_cnt_t m_framesDoneInCurBuf;
117123
f_cnt_t m_framesToDoInCurBuf;
118124

119-
#ifdef AUDIO_PORT_SUPPORT
125+
#ifdef AUDIO_BUS_HANDLE_SUPPORT
120126
struct StereoPort
121127
{
122128
jack_port_t* ports[2];
123129
};
124130

125-
using JackPortMap = QMap<AudioPort*, StereoPort>;
131+
using JackPortMap = QMap<AudioBusHandle*, StereoPort>;
126132
JackPortMap m_portMap;
127133
#endif
128134

include/AudioPort.h

Lines changed: 0 additions & 139 deletions
This file was deleted.

include/InstrumentTrack.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include <limits>
3030

31-
#include "AudioPort.h"
31+
#include "AudioBusHandle.h"
3232
#include "InstrumentFunctions.h"
3333
#include "InstrumentSoundShaping.h"
3434
#include "Microtuner.h"
@@ -144,9 +144,9 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor
144144
const Plugin::Descriptor::SubPluginFeatures::Key* key = nullptr,
145145
bool keyFromDnd = false);
146146

147-
AudioPort * audioPort()
147+
AudioBusHandle* audioBusHandle()
148148
{
149-
return &m_audioPort;
149+
return &m_audioBusHandle;
150150
}
151151

152152
MidiPort * midiPort()
@@ -293,7 +293,7 @@ protected slots:
293293
FloatModel m_volumeModel;
294294
FloatModel m_panningModel;
295295

296-
AudioPort m_audioPort;
296+
AudioBusHandle m_audioBusHandle;
297297

298298
FloatModel m_pitchModel;
299299
IntModel m_pitchRangeModel;

0 commit comments

Comments
 (0)