SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
dspengine.cpp
Go to the documentation of this file.
1 // Copyright (C) 2015 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include <QGlobalStatic>
20 #include <QThread>
21 
22 #include "dsp/dspengine.h"
26 
28  m_deviceSourceEnginesUIDSequence(0),
29  m_deviceSinkEnginesUIDSequence(0),
30  m_deviceMIMOEnginesUIDSequence(0),
31  m_audioInputDeviceIndex(-1), // default device
32  m_audioOutputDeviceIndex(-1) // default device
33 {
34  m_dvSerialSupport = false;
35  m_mimoSupport = false;
36  m_masterTimer.start(50);
37 }
38 
40 {
41  std::vector<DSPDeviceSourceEngine*>::iterator it = m_deviceSourceEngines.begin();
42 
43  while (it != m_deviceSourceEngines.end())
44  {
45  delete *it;
46  ++it;
47  }
48 }
49 
50 Q_GLOBAL_STATIC(DSPEngine, dspEngine)
52 {
53  return dspEngine;
54 }
55 
57 {
60  return m_deviceSourceEngines.back();
61 }
62 
64 {
65  if (m_deviceSourceEngines.size() > 0)
66  {
67  DSPDeviceSourceEngine *lastDeviceEngine = m_deviceSourceEngines.back();
68  delete lastDeviceEngine;
69  m_deviceSourceEngines.pop_back();
71  }
72 }
73 
75 {
78  return m_deviceSinkEngines.back();
79 }
80 
82 {
83  if (m_deviceSinkEngines.size() > 0)
84  {
85  DSPDeviceSinkEngine *lastDeviceEngine = m_deviceSinkEngines.back();
86  delete lastDeviceEngine;
87  m_deviceSinkEngines.pop_back();
89  }
90 }
91 
93 {
96  return m_deviceMIMOEngines.back();
97 }
98 
100 {
101  if (m_deviceMIMOEngines.size() > 0)
102  {
103  DSPDeviceMIMOEngine *lastDeviceEngine = m_deviceMIMOEngines.back();
104  delete lastDeviceEngine;
105  m_deviceMIMOEngines.pop_back();
107  }
108 }
109 
111 {
112  std::vector<DSPDeviceSourceEngine*>::iterator it = m_deviceSourceEngines.begin();
113 
114  while (it != m_deviceSourceEngines.end())
115  {
116  if ((*it)->getUID() == uid) {
117  return *it;
118  }
119 
120  ++it;
121  }
122 
123  return nullptr;
124 }
125 
127 {
128  std::vector<DSPDeviceSinkEngine*>::iterator it = m_deviceSinkEngines.begin();
129 
130  while (it != m_deviceSinkEngines.end())
131  {
132  if ((*it)->getUID() == uid) {
133  return *it;
134  }
135 
136  ++it;
137  }
138 
139  return nullptr;
140 }
141 
143 {
144  std::vector<DSPDeviceMIMOEngine*>::iterator it = m_deviceMIMOEngines.begin();
145 
146  while (it != m_deviceMIMOEngines.end())
147  {
148  if ((*it)->getUID() == uid) {
149  return *it;
150  }
151 
152  ++it;
153  }
154 
155  return nullptr;
156 }
157 
159 {
160  return m_ambeEngine.getNbDevices() > 0;
161 }
162 
164 { (void) support; }
165 
166 void DSPEngine::getDVSerialNames(std::vector<std::string>& deviceNames)
167 {
168  std::vector<QString> qDeviceRefs;
169  m_ambeEngine.getDeviceRefs(qDeviceRefs);
170  deviceNames.clear();
171 
172  for (std::vector<QString>::const_iterator it = qDeviceRefs.begin(); it != qDeviceRefs.end(); ++it) {
173  deviceNames.push_back(it->toStdString());
174  }
175 }
176 
178  const unsigned char *mbeFrame,
179  int mbeRateIndex,
180  int mbeVolumeIndex,
181  unsigned char channels,
182  bool useHP,
183  int upsampling,
184  AudioFifo *audioFifo)
185 {
186  m_ambeEngine.pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, useHP, upsampling, audioFifo);
187 }
void removeLastDeviceMIMOEngine()
Definition: dspengine.cpp:99
std::vector< DSPDeviceSinkEngine * > m_deviceSinkEngines
Definition: dspengine.h:91
DSPDeviceSinkEngine * getDeviceSinkEngineByUID(uint uid)
Definition: dspengine.cpp:126
DSPDeviceSourceEngine * addDeviceSourceEngine()
Definition: dspengine.cpp:56
uint m_deviceSinkEnginesUIDSequence
Definition: dspengine.h:92
void getDeviceRefs(std::vector< QString > &devicesRefs)
reference of the devices used (device path or url)
Definition: ambeengine.cpp:279
DSPDeviceSinkEngine * addDeviceSinkEngine()
Definition: dspengine.cpp:74
bool hasDVSerialSupport()
Definition: dspengine.cpp:158
uint m_deviceSourceEnginesUIDSequence
Definition: dspengine.h:90
void getDVSerialNames(std::vector< std::string > &deviceNames)
Definition: dspengine.cpp:166
uint m_deviceMIMOEnginesUIDSequence
Definition: dspengine.h:94
DSPDeviceSourceEngine * getDeviceSourceEngineByUID(uint uid)
Definition: dspengine.cpp:110
DSPDeviceMIMOEngine * getDeviceMIMOEngineByUID(uint uid)
Definition: dspengine.cpp:142
static DSPEngine * instance()
Definition: dspengine.cpp:51
void removeLastDeviceSinkEngine()
Definition: dspengine.cpp:81
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, unsigned char channels, bool useHP, int upsampling, AudioFifo *audioFifo)
Definition: dspengine.cpp:177
void removeLastDeviceSourceEngine()
Definition: dspengine.cpp:63
void setDVSerialSupport(bool support)
Definition: dspengine.cpp:163
std::vector< DSPDeviceMIMOEngine * > m_deviceMIMOEngines
Definition: dspengine.h:93
std::vector< DSPDeviceSourceEngine * > m_deviceSourceEngines
Definition: dspengine.h:89
AMBEEngine m_ambeEngine
Definition: dspengine.h:101
int getNbDevices() const
number of devices used
Definition: ambeengine.h:46
bool m_dvSerialSupport
Definition: dspengine.h:99
void pushMbeFrame(const unsigned char *mbeFrame, int mbeRateIndex, int mbeVolumeIndex, unsigned char channels, bool useHP, int upsampling, AudioFifo *audioFifo)
Definition: ambeengine.cpp:290
QTimer m_masterTimer
Definition: dspengine.h:98
DSPDeviceMIMOEngine * addDeviceMIMOEngine()
Definition: dspengine.cpp:92
bool m_mimoSupport
Definition: dspengine.h:100