mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
Multi device support: moved audio output multi client support to audio output object itself
This commit is contained in:
parent
83e1b84c38
commit
90b1fae799
@ -24,7 +24,8 @@
|
||||
|
||||
AudioOutput::AudioOutput() :
|
||||
m_mutex(),
|
||||
m_audioOutput(NULL),
|
||||
m_audioOutput(0),
|
||||
m_audioUsageCount(0),
|
||||
m_audioFifos()
|
||||
{
|
||||
}
|
||||
@ -47,9 +48,8 @@ bool AudioOutput::start(int device, int rate)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
//Q_UNUSED(device);
|
||||
//Q_UNUSED(rate);
|
||||
|
||||
if (m_audioUsageCount == 0)
|
||||
{
|
||||
QAudioDeviceInfo devInfo;
|
||||
|
||||
if (device < 0)
|
||||
@ -104,17 +104,28 @@ bool AudioOutput::start(int device, int rate)
|
||||
{
|
||||
qWarning("AudioOutput::start: cannot start");
|
||||
}
|
||||
}
|
||||
|
||||
m_audioUsageCount++;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void AudioOutput::stop()
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if (m_audioUsageCount > 0)
|
||||
{
|
||||
m_audioUsageCount--;
|
||||
|
||||
if (m_audioUsageCount == 0)
|
||||
{
|
||||
QIODevice::close();
|
||||
delete m_audioOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioOutput::addFifo(AudioFifo* audioFifo)
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
private:
|
||||
QMutex m_mutex;
|
||||
QAudioOutput* m_audioOutput;
|
||||
uint m_audioUsageCount;
|
||||
|
||||
typedef std::list<AudioFifo*> AudioFifos;
|
||||
AudioFifos m_audioFifos;
|
||||
|
@ -21,10 +21,8 @@
|
||||
|
||||
DSPEngine::DSPEngine() :
|
||||
m_deviceEnginesUIDSequence(0),
|
||||
m_audioSampleRate(48000), // Use default output device at 48 kHz
|
||||
m_audioUsageCount(0)
|
||||
m_audioSampleRate(48000) // Use default output device at 48 kHz
|
||||
{
|
||||
//m_deviceEngines.push_back(new DSPDeviceEngine(0)); // TODO: multi device support
|
||||
m_dvSerialSupport = false;
|
||||
}
|
||||
|
||||
@ -87,28 +85,15 @@ void DSPEngine::stopAllDeviceEngines()
|
||||
}
|
||||
|
||||
void DSPEngine::startAudio()
|
||||
{
|
||||
if (m_audioUsageCount == 0)
|
||||
{
|
||||
m_audioOutput.start(-1, m_audioSampleRate);
|
||||
m_audioSampleRate = m_audioOutput.getRate(); // update with actual rate
|
||||
}
|
||||
|
||||
m_audioUsageCount++;
|
||||
}
|
||||
|
||||
void DSPEngine::stopAudio()
|
||||
{
|
||||
if (m_audioUsageCount > 0)
|
||||
{
|
||||
m_audioUsageCount--;
|
||||
|
||||
if (m_audioUsageCount == 0)
|
||||
{
|
||||
m_audioOutput.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DSPEngine::startAudioImmediate()
|
||||
{
|
||||
|
@ -89,7 +89,6 @@ private:
|
||||
AudioOutput m_audioOutput;
|
||||
uint m_audioSampleRate;
|
||||
bool m_dvSerialSupport;
|
||||
uint m_audioUsageCount;
|
||||
#ifdef DSD_USE_SERIALDV
|
||||
DVSerialEngine m_dvSerialEngine;
|
||||
#endif
|
||||
|
@ -223,9 +223,18 @@ void MainWindow::removeLastDevice()
|
||||
|
||||
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);
|
||||
|
||||
ui->tabInputsView->removeTab(ui->tabInputsView->count() - 1);
|
||||
ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1);
|
||||
|
||||
m_deviceWidgetTabs.removeLast();
|
||||
ui->tabInputsView->clear();
|
||||
|
||||
for (int i = 0; i < m_deviceWidgetTabs.size(); i++)
|
||||
{
|
||||
qDebug("MainWindow::removeLastDevice: adding back tab for %s", m_deviceWidgetTabs[i].displayName.toStdString().c_str());
|
||||
ui->tabInputsView->addTab(m_deviceWidgetTabs[i].gui, m_deviceWidgetTabs[i].tabName);
|
||||
ui->tabInputsView->setTabToolTip(i, m_deviceWidgetTabs[i].displayName);
|
||||
}
|
||||
|
||||
delete m_deviceUIs.back();
|
||||
|
||||
lastDeviceEngine->stop();
|
||||
|
Loading…
Reference in New Issue
Block a user