Skip to content

Commit

Permalink
Change audio latency setting to a wxSpinCtrl, fixes layout problem on…
Browse files Browse the repository at this point in the history
… linux.
  • Loading branch information
jordan-woyak committed Jan 16, 2013
1 parent 7d11f8c commit 6612763
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
28 changes: 12 additions & 16 deletions Source/Core/DolphinWX/Src/ConfigMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ EVT_CHECKBOX(ID_DSPTHREAD, CConfigMain::AudioSettingsChanged)
EVT_CHECKBOX(ID_ENABLE_THROTTLE, CConfigMain::AudioSettingsChanged)
EVT_CHECKBOX(ID_DUMP_AUDIO, CConfigMain::AudioSettingsChanged)
EVT_CHECKBOX(ID_DPL2DECODER, CConfigMain::AudioSettingsChanged)
EVT_SLIDER(ID_LATENCY, CConfigMain::AudioSettingsChanged)
EVT_CHOICE(ID_BACKEND, CConfigMain::AudioSettingsChanged)
EVT_SLIDER(ID_VOLUME, CConfigMain::AudioSettingsChanged)

Expand Down Expand Up @@ -217,7 +216,7 @@ void CConfigMain::UpdateGUI()
DSPEngine->Disable();
DSPThread->Disable();
DPL2Decoder->Disable();
LatencySlider->Disable();
Latency->Disable();

// Disable stuff on GamecubePage
GCSystemLang->Disable();
Expand Down Expand Up @@ -365,9 +364,8 @@ void CConfigMain::InitializeGUIValues()
DumpAudio->SetValue(ac_Config.m_DumpAudio ? true : false);
DPL2Decoder->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL);
DPL2Decoder->SetValue(startup_params.bDPL2Decoder);
LatencySlider->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL);
LatencySlider->SetValue(startup_params.iLatency);
LatencyText->SetLabel(wxString::Format(wxT("%d"), startup_params.iLatency));
Latency->Enable(std::string(ac_Config.sBackend) == BACKEND_OPENAL);
Latency->SetValue(startup_params.iLatency);
// add backends to the list
AddAudioBackends();

Expand Down Expand Up @@ -525,7 +523,7 @@ void CConfigMain::InitializeGUITooltips()
DPL2Decoder->SetToolTip(_("Enables Dolby Pro Logic II emulation using 5.1 surround. OpenAL backend only. May need to rename soft_oal.dll to OpenAL32.dll to make it work."));
#endif

LatencySlider->SetToolTip(_("Sets the latency (in ms). Higher values may reduce audio crackling. OpenAL backend only."));
Latency->SetToolTip(_("Sets the latency (in ms). Higher values may reduce audio crackling. OpenAL backend only."));
}

void CConfigMain::CreateGUIControls()
Expand Down Expand Up @@ -630,14 +628,14 @@ void CConfigMain::CreateGUIControls()
wxDefaultPosition, wxDefaultSize, 0);
BackendSelection = new wxChoice(AudioPage, ID_BACKEND, wxDefaultPosition,
wxDefaultSize, wxArrayBackends, 0, wxDefaultValidator, wxEmptyString);
LatencySlider = new wxSlider(AudioPage, ID_LATENCY, 0, 0, 30,
wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL);
LatencyText = new wxStaticText(AudioPage, wxID_ANY, wxT(""),
wxDefaultPosition, wxDefaultSize, 0);
Latency = new wxSpinCtrl(AudioPage, ID_LATENCY, "", wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS, 0, 30);

Latency->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &CConfigMain::AudioSettingsChanged, this);

if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
LatencySlider->Disable();
Latency->Disable();
BackendSelection->Disable();
DPL2Decoder->Disable();
}
Expand All @@ -657,8 +655,7 @@ void CConfigMain::CreateGUIControls()
sBackend->Add(TEXT_BOX(AudioPage, _("Audio Backend:")), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5);
sBackend->Add(BackendSelection, wxGBPosition(0, 1), wxDefaultSpan, wxALL, 5);
sBackend->Add(TEXT_BOX(AudioPage, _("Latency:")), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5);
sBackend->Add(LatencySlider, wxGBPosition(1, 1), wxDefaultSpan, wxALL, 5);
sBackend->Add(LatencyText, wxGBPosition(1, 2), wxDefaultSpan, wxALL, 5);
sBackend->Add(Latency, wxGBPosition(1, 1), wxDefaultSpan, wxALL, 5);
wxStaticBoxSizer *sbBackend = new wxStaticBoxSizer(wxHORIZONTAL, AudioPage, _("Backend Settings"));
sbBackend->Add(sBackend, 0, wxEXPAND);

Expand Down Expand Up @@ -945,15 +942,14 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event)

case ID_BACKEND:
VolumeSlider->Enable(SupportsVolumeChanges(std::string(BackendSelection->GetStringSelection().mb_str())));
LatencySlider->Enable(std::string(BackendSelection->GetStringSelection().mb_str()) == BACKEND_OPENAL);
Latency->Enable(std::string(BackendSelection->GetStringSelection().mb_str()) == BACKEND_OPENAL);
DPL2Decoder->Enable(std::string(BackendSelection->GetStringSelection().mb_str()) == BACKEND_OPENAL);
ac_Config.sBackend = BackendSelection->GetStringSelection().mb_str();
ac_Config.Update();
break;

case ID_LATENCY:
SConfig::GetInstance().m_LocalCoreStartupParameter.iLatency = LatencySlider->GetValue();
LatencyText->SetLabel(wxString::Format(wxT("%d"), LatencySlider->GetValue()));
SConfig::GetInstance().m_LocalCoreStartupParameter.iLatency = Latency->GetValue();
break;

default:
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/DolphinWX/Src/ConfigMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ class CConfigMain : public wxDialog
wxCheckBox* DPL2Decoder;
wxArrayString wxArrayBackends;
wxChoice* BackendSelection;
wxSlider* LatencySlider;
wxStaticText* LatencyText;
wxSpinCtrl* Latency;

// Interface
wxCheckBox* ConfirmStop;
Expand Down

0 comments on commit 6612763

Please sign in to comment.