Skip to content

Commit

Permalink
Merge branch 'ms-easy-setup' into ms-easy-setup-with-2020c
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Dec 30, 2022
2 parents 1c4d515 + 816eca8 commit e60d7a8
Showing 1 changed file with 66 additions and 39 deletions.
105 changes: 66 additions & 39 deletions src/dlg_easy_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,60 +316,74 @@ void EasySetupDialog::ExchangeSoundDeviceData(int inout)
{
if (inout == EXCHANGE_DATA_IN)
{
// Set initial selections so we have something valid on exit
m_analogDevicePlayback->SetSelection(0);
m_analogDeviceRecord->SetSelection(0);
m_radioDevice->SetSelection(0);

wxString soundCard1InDeviceName = wxGetApp().m_soundCard1InDeviceName;
int soundCard1InSampleRate = wxGetApp().m_soundCard1InSampleRate;
wxString soundCard1OutDeviceName = wxGetApp().m_soundCard1OutDeviceName;
int soundCard1OutSampleRate = wxGetApp().m_soundCard1OutSampleRate;
wxString soundCard2InDeviceName = wxGetApp().m_soundCard2InDeviceName;
wxString soundCard2OutDeviceName = wxGetApp().m_soundCard2OutDeviceName;
wxString radioSoundDevice;

if (soundCard1InDeviceName != "none" && soundCard1OutDeviceName != "none")
if (soundCard1InDeviceName == "none" && soundCard1OutDeviceName == "none")
{
// Previous existing setup, determine what it is
if (soundCard2InDeviceName == "none" && soundCard2OutDeviceName == "none")
{
// RX-only setup
auto index = m_analogDeviceRecord->FindString(RX_ONLY_STRING);
assert(index >= 0);
m_analogDeviceRecord->SetSelection(index);
// Set initial selections so we have something valid on exit.
SoundDeviceData* analogPlaybackDeviceData =
(SoundDeviceData*)m_analogDevicePlayback->GetClientObject(0);

index = m_analogDevicePlayback->FindString(soundCard1OutDeviceName);
if (index >= 0)
{
m_analogDevicePlayback->SetSelection(index);
}
SoundDeviceData* radioDeviceData =
(SoundDeviceData*)m_radioDevice->GetClientObject(0);

radioSoundDevice = soundCard1InDeviceName;
soundCard1InDeviceName = radioDeviceData->rxDeviceName;
soundCard1OutDeviceName = analogPlaybackDeviceData->rxDeviceName;
}

// Previous existing setup, determine what it is
if (soundCard2InDeviceName == "none" && soundCard2OutDeviceName == "none")
{
// RX-only setup
auto index = m_analogDeviceRecord->FindString(RX_ONLY_STRING);
assert(index >= 0);
m_analogDeviceRecord->SetSelection(index);

index = m_analogDevicePlayback->FindString(soundCard1OutDeviceName);
if (index >= 0)
{
m_analogDevicePlayback->SetSelection(index);
}
else

radioSoundDevice = soundCard1InDeviceName;
}
else
{
// RX and TX setup
auto index = m_analogDeviceRecord->FindString(soundCard2InDeviceName);
if (index >= 0)
{
// RX and TX setup
auto index = m_analogDeviceRecord->FindString(soundCard2InDeviceName);
if (index >= 0)
{
m_analogDeviceRecord->SetSelection(index);
}
m_analogDeviceRecord->SetSelection(index);
}

index = m_analogDevicePlayback->FindString(soundCard2OutDeviceName);
if (index >= 0)
{
m_analogDevicePlayback->SetSelection(index);
}

if (soundCard1OutDeviceName == soundCard1InDeviceName)
{
// We're not on a setup with different sound devices on the radio side (e.g. SDRs)
radioSoundDevice = soundCard1InDeviceName;

index = m_analogDevicePlayback->FindString(soundCard2OutDeviceName);
// Remove multiple devices entry if it's in there.
int index = m_radioDevice->FindString(MULTIPLE_DEVICES_STRING);
if (index >= 0)
{
m_analogDevicePlayback->SetSelection(index);
}

if (soundCard1OutDeviceName == soundCard1InDeviceName)
{
// We're not on a setup with different sound devices on the radio side (e.g. SDRs)
radioSoundDevice = soundCard1InDeviceName;
}
else
{
radioSoundDevice = MULTIPLE_DEVICES_STRING;
m_radioDevice->Delete(index);
}
}
else
{
radioSoundDevice = MULTIPLE_DEVICES_STRING;
}
}

if (radioSoundDevice == MULTIPLE_DEVICES_STRING)
Expand All @@ -391,12 +405,25 @@ void EasySetupDialog::ExchangeSoundDeviceData(int inout)
}
}
}

int index = m_radioDevice->FindString(radioSoundDevice);
if (index != wxNOT_FOUND)
{
m_radioDevice->SetSelection(index);
}
else if (radioSoundDevice == MULTIPLE_DEVICES_STRING)
{
SoundDeviceData* data = new SoundDeviceData();
assert(data != nullptr);

data->rxDeviceName = soundCard1InDeviceName;
data->rxSampleRate = soundCard1InSampleRate;
data->txDeviceName = soundCard1OutDeviceName;
data->txSampleRate = soundCard1OutSampleRate;

m_radioDevice->Insert(MULTIPLE_DEVICES_STRING, 0, data);
m_radioDevice->SetSelection(0);
}
}
else if (inout == EXCHANGE_DATA_OUT)
{
Expand Down

0 comments on commit e60d7a8

Please sign in to comment.