LMMS
Loading...
Searching...
No Matches
AudioSoundIo.h
Go to the documentation of this file.
1/*
2 * AudioSoundIo.h - device-class that performs PCM-output via libsoundio
3 *
4 * Copyright (c) 2015 Andrew Kelley <superjoe30@gmail.com>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_AUDIO_SOUNDIO_H
26#define LMMS_AUDIO_SOUNDIO_H
27
28
29#include "lmmsconfig.h"
30#include "ComboBoxModel.h" // IWYU pragma: keep
31
32#ifdef LMMS_HAVE_SOUNDIO
33
34#include <soundio/soundio.h>
35
36#include "AudioDevice.h"
38
39namespace lmms
40{
41
42namespace gui
43{
44class ComboBox;
45class LcdSpinBox;
46}
47
48// Exists only to work around "Error: Meta object features not supported for nested classes"
49class AudioSoundIoSetupUtil : public QObject
50{
51 Q_OBJECT
52public:
53 virtual ~AudioSoundIoSetupUtil() = default;
54
56public slots:
57 void updateDevices();
58 void reconnectSoundIo();
59};
60
62{
63public:
64 AudioSoundIo( bool & _success_ful, AudioEngine* audioEngine );
65 virtual ~AudioSoundIo();
66
67 inline static QString name()
68 {
69 return QT_TRANSLATE_NOOP( "AudioDeviceSetupWidget", "soundio" );
70 }
71
73 {
74 public:
75 setupWidget( QWidget * _parent );
76 virtual ~setupWidget();
77
78 virtual void saveSettings();
79
80 void updateDevices();
81 void reconnectSoundIo();
82
83 private:
84
88
91
92 SoundIo * m_soundio;
93
94 struct DeviceId {
95 QString id;
96 bool is_raw;
97 };
98 QList<DeviceId> m_deviceList;
99
102
103 } ;
104
105private:
106 virtual void startProcessing();
107 virtual void stopProcessing();
108
109 SoundIo *m_soundio;
110 SoundIoOutStream *m_outstream;
111
116
119
121 void onBackendDisconnect(int err);
122
123 void writeCallback(int frame_count_min, int frame_count_max);
124 void errorCallback(int err);
125 void underflowCallback();
126
127 static void staticWriteCallback(SoundIoOutStream *outstream, int frame_count_min, int frame_count_max) {
128 return ((AudioSoundIo *)outstream->userdata)->writeCallback(frame_count_min, frame_count_max);
129 }
130 static void staticErrorCallback(SoundIoOutStream *outstream, int err) {
131 return ((AudioSoundIo *)outstream->userdata)->errorCallback(err);
132 }
133 static void staticUnderflowCallback(SoundIoOutStream *outstream) {
134 return ((AudioSoundIo *)outstream->userdata)->underflowCallback();
135 }
136 static void staticOnBackendDisconnect(SoundIo *soundio, int err) {
137 return ((AudioSoundIo *)soundio->userdata)->onBackendDisconnect(err);
138 }
139
140};
141
142
143} // namespace lmms
144
145#endif // LMMS_HAVE_SOUNDIO
146
147#endif // LMMS_AUDIO_SOUNDIO_H
AudioEngine * audioEngine()
Definition AudioDevice.h:121
AudioDevice(const ch_cnt_t _channels, AudioEngine *audioEngine)
Definition AudioDevice.cpp:33
Definition AudioEngine.h:66
gui::ComboBox * m_device
Definition AudioSoundIo.h:87
setupWidget(QWidget *_parent)
Definition AudioSoundIo.cpp:433
gui::ComboBox * m_backend
Definition AudioSoundIo.h:86
ComboBoxModel m_backendModel
Definition AudioSoundIo.h:89
AudioSoundIoSetupUtil m_setupUtil
Definition AudioSoundIo.h:85
virtual ~setupWidget()
Definition AudioSoundIo.cpp:477
void updateDevices()
Definition AudioSoundIo.cpp:412
QList< DeviceId > m_deviceList
Definition AudioSoundIo.h:98
int m_defaultOutIndex
Definition AudioSoundIo.h:100
virtual void saveSettings()
Definition AudioSoundIo.cpp:489
bool m_isFirst
Definition AudioSoundIo.h:101
void reconnectSoundIo()
Definition AudioSoundIo.cpp:355
SoundIo * m_soundio
Definition AudioSoundIo.h:92
ComboBoxModel m_deviceModel
Definition AudioSoundIo.h:90
virtual void startProcessing()
Definition AudioSoundIo.cpp:209
static void staticUnderflowCallback(SoundIoOutStream *outstream)
Definition AudioSoundIo.h:133
void errorCallback(int err)
Definition AudioSoundIo.cpp:260
static void staticOnBackendDisconnect(SoundIo *soundio, int err)
Definition AudioSoundIo.h:136
void writeCallback(int frame_count_min, int frame_count_max)
Definition AudioSoundIo.cpp:270
SampleFrame * m_outBuf
Definition AudioSoundIo.h:112
f_cnt_t m_outBufFrameIndex
Definition AudioSoundIo.h:115
SoundIoOutStream * m_outstream
Definition AudioSoundIo.h:110
static void staticErrorCallback(SoundIoOutStream *outstream, int err)
Definition AudioSoundIo.h:130
virtual ~AudioSoundIo()
Definition AudioSoundIo.cpp:193
int m_disconnectErr
Definition AudioSoundIo.h:120
static void staticWriteCallback(SoundIoOutStream *outstream, int frame_count_min, int frame_count_max)
Definition AudioSoundIo.h:127
f_cnt_t m_outBufFramesTotal
Definition AudioSoundIo.h:114
SoundIo * m_soundio
Definition AudioSoundIo.h:109
AudioSoundIo(bool &_success_ful, AudioEngine *audioEngine)
Definition AudioSoundIo.cpp:40
void onBackendDisconnect(int err)
Definition AudioSoundIo.cpp:188
bool m_stopped
Definition AudioSoundIo.h:117
static QString name()
Definition AudioSoundIo.h:67
virtual void stopProcessing()
Definition AudioSoundIo.cpp:240
bool m_outstreamStarted
Definition AudioSoundIo.h:118
void underflowCallback()
Definition AudioSoundIo.cpp:265
int m_outBufSize
Definition AudioSoundIo.h:113
Definition AudioSoundIo.h:50
void reconnectSoundIo()
Definition AudioSoundIo.cpp:333
void * m_setupWidget
Definition AudioSoundIo.h:55
void updateDevices()
Definition AudioSoundIo.cpp:338
virtual ~AudioSoundIoSetupUtil()=default
Definition ComboBoxModel.h:39
Definition SampleFrame.h:41
Definition AudioDeviceSetupWidget.h:35
Definition ComboBox.h:38
Definition LcdSpinBox.h:35
Definition AudioPortAudio.cpp:223
Definition AudioAlsa.cpp:35
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43
Definition AudioSoundIo.h:94
QString id
Definition AudioSoundIo.h:95
bool is_raw
Definition AudioSoundIo.h:96