bool CGUIDialogFreeSurround::OnClick(int controlId)
{
  CDSPProcess_FreeSurround *process = NULL;

  switch (controlId)
  {
    case DSP_SETTING_FREESURROUND_CIRCULAR_WRAP:
    {
      m_Settings.fCircularWrap = m_CircularWrap->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetCircularWrap(m_Settings.fCircularWrap);
      break;
    }
    case DSP_SETTING_FREESURROUND_SHIFT:
    {
      m_Settings.fShift = m_Shift->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetShift(m_Settings.fShift);
      break;
    }
    case DSP_SETTING_FREESURROUND_DEPTH:
    {
      m_Settings.fDepth = m_Depth->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetDepth(m_Settings.fDepth);
      break;
    }
    case DSP_SETTING_FREESURROUND_FOCUS:
    {
      m_Settings.fFocus = m_Focus->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetFocus(m_Settings.fFocus);
      break;
    }
    case DSP_SETTING_FREESURROUND_CENTER_IMAGE:
    {
      m_Settings.fCenterImage = m_CenterImage->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetCenterImage(m_Settings.fCenterImage);
      break;
    }
    case DSP_SETTING_FREESURROUND_FRONT_SEPARATION:
    {
      m_Settings.fFrontSeparation = m_FrontSeparation->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetFrontSeparation(m_Settings.fFrontSeparation);
      break;
    }
    case DSP_SETTING_FREESURROUND_REAR_SEPARATION:
    {
      m_Settings.fRearSeparation = m_RearSeparation->GetFloatValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetRearSeparation(m_Settings.fRearSeparation);
      break;
    }
    case DSP_SETTING_FREESURROUND_LFE:
    {
      m_Settings.bLFE = m_LFE->IsSelected();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetBassRedirection(m_Settings.bLFE);
      break;
    }
    case DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF:
    {
      m_Settings.fLowCutoff = m_LFE_LowCutoff->GetIntValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetLowCutoff(m_Settings.fLowCutoff);
      break;
    }
    case DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF:
    {
      m_Settings.fHighCutoff = m_LFE_HighCutoff->GetIntValue();
      process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetHighCutoff(m_Settings.fHighCutoff);
      break;
    }
    case BUTTON_OK:
      SaveSettingsData();
    case BUTTON_CANCEL:
    {
      if (controlId == BUTTON_CANCEL)
      {
        process = g_usedDSPs[m_StreamId];
        if (process)
          process->ResetSettings();
      }
      Close();
      break;
    }
    case BUTTON_DEFAULT:
    {
      CDSPSettings defaultSettings;
      m_Settings.fCircularWrap           = defaultSettings.m_Settings.fCircularWrap;
      m_Settings.fShift                  = defaultSettings.m_Settings.fShift;
      m_Settings.fDepth                  = defaultSettings.m_Settings.fDepth;
      m_Settings.fFocus                  = defaultSettings.m_Settings.fFocus;
      m_Settings.fCenterImage            = defaultSettings.m_Settings.fCenterImage;
      m_Settings.fFrontSeparation        = defaultSettings.m_Settings.fFrontSeparation;
      m_Settings.fRearSeparation         = defaultSettings.m_Settings.fRearSeparation;
      m_Settings.bLFE                    = defaultSettings.m_Settings.bLFE;
      m_Settings.fLowCutoff              = defaultSettings.m_Settings.fLowCutoff;
      m_Settings.fHighCutoff             = defaultSettings.m_Settings.fHighCutoff;

      m_CircularWrap->SetIntValue((int)m_Settings.fCircularWrap);
      m_Shift->SetFloatValue(m_Settings.fShift);
      m_Depth->SetFloatValue(m_Settings.fDepth);
      m_Focus->SetFloatValue(m_Settings.fFocus);
      m_CenterImage->SetFloatValue(m_Settings.fCenterImage);
      m_FrontSeparation->SetFloatValue(m_Settings.fFrontSeparation);
      m_RearSeparation->SetFloatValue(m_Settings.fRearSeparation);
      m_LFE->SetSelected(m_Settings.bLFE);
      m_LFE_LowCutoff->SetIntValue(m_Settings.fLowCutoff);
      m_LFE_HighCutoff->SetIntValue(m_Settings.fHighCutoff);

      process = g_usedDSPs[m_StreamId];
      if (process)
      {
        process->SetCircularWrap(m_Settings.fCircularWrap);
        process->SetShift(m_Settings.fShift);
        process->SetDepth(m_Settings.fDepth);
        process->SetFocus(m_Settings.fFocus);
        process->SetCenterImage(m_Settings.fCenterImage);
        process->SetFrontSeparation(m_Settings.fFrontSeparation);
        process->SetRearSeparation(m_Settings.fRearSeparation);
        process->SetBassRedirection(m_Settings.bLFE);
        process->SetLowCutoff(m_Settings.fLowCutoff);
        process->SetHighCutoff(m_Settings.fHighCutoff);
      }
      break;
    }
    default:
      break;
  }

  return true;
}
bool CGUIDialogFreeSurround::OnClick(int controlId)
{
  switch (controlId)
  {
    case DSP_SETTING_FREESURROUND_CIRCULAR_WRAP:
    {
      m_Settings.fCircularWrap = m_CircularWrap->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetCircularWrap(m_Settings.fCircularWrap);
      break;
    }
    case DSP_SETTING_FREESURROUND_SHIFT:
    {
      m_Settings.fShift = m_Shift->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetShift(m_Settings.fShift);
      break;
    }
    case DSP_SETTING_FREESURROUND_DEPTH:
    {
      m_Settings.fDepth = m_Depth->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetDepth(m_Settings.fDepth);
      break;
    }
    case DSP_SETTING_FREESURROUND_FOCUS:
    {
      m_Settings.fFocus = m_Focus->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetFocus(m_Settings.fFocus);
      break;
    }
    case DSP_SETTING_FREESURROUND_CENTER_IMAGE:
    {
      m_Settings.fCenterImage = m_CenterImage->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetCenterImage(m_Settings.fCenterImage);
      break;
    }
    case DSP_SETTING_FREESURROUND_FRONT_SEPARATION:
    {
      m_Settings.fFrontSeparation = m_FrontSeparation->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetFrontSeparation(m_Settings.fFrontSeparation);
      break;
    }
    case DSP_SETTING_FREESURROUND_REAR_SEPARATION:
    {
      m_Settings.fRearSeparation = m_RearSeparation->GetFloatValue();
      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
        process->SetRearSeparation(m_Settings.fRearSeparation);
      break;
    }
    case BUTTON_OK:
      SaveSettingsData();
    case BUTTON_CANCEL:
    {
      if (controlId == BUTTON_CANCEL)
      {
        CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
        if (process)
          process->ResetSettings();
      }
      m_window->Close();
      GUI->Control_releaseSettingsSlider(m_CircularWrap);
      GUI->Control_releaseSettingsSlider(m_Shift);
      GUI->Control_releaseSettingsSlider(m_Depth);
      GUI->Control_releaseSettingsSlider(m_Focus);
      GUI->Control_releaseSettingsSlider(m_CenterImage);
      GUI->Control_releaseSettingsSlider(m_FrontSeparation);
      GUI->Control_releaseSettingsSlider(m_RearSeparation);

      break;
    }
    case BUTTON_DEFAULT:
    {
      CDSPSettings defaultSettings;
      m_Settings.fCircularWrap           = defaultSettings.m_Settings.fCircularWrap;
      m_Settings.fShift                  = defaultSettings.m_Settings.fShift;
      m_Settings.fDepth                  = defaultSettings.m_Settings.fDepth;
      m_Settings.fFocus                  = defaultSettings.m_Settings.fFocus;
      m_Settings.fCenterImage            = defaultSettings.m_Settings.fCenterImage;
      m_Settings.fFrontSeparation        = defaultSettings.m_Settings.fFrontSeparation;
      m_Settings.fRearSeparation         = defaultSettings.m_Settings.fRearSeparation;

      m_CircularWrap->SetIntValue((int)m_Settings.fCircularWrap);
      m_Shift->SetFloatValue(m_Settings.fShift);
      m_Depth->SetFloatValue(m_Settings.fDepth);
      m_Focus->SetFloatValue(m_Settings.fFocus);
      m_CenterImage->SetFloatValue(m_Settings.fCenterImage);
      m_FrontSeparation->SetFloatValue(m_Settings.fFrontSeparation);
      m_RearSeparation->SetFloatValue(m_Settings.fRearSeparation);

      CDSPProcess_FreeSurround *process = g_usedDSPs[m_StreamId];
      if (process)
      {
        process->SetCircularWrap(m_Settings.fCircularWrap);
        process->SetShift(m_Settings.fShift);
        process->SetDepth(m_Settings.fDepth);
        process->SetFocus(m_Settings.fFocus);
        process->SetCenterImage(m_Settings.fCenterImage);
        process->SetFrontSeparation(m_Settings.fFrontSeparation);
        process->SetRearSeparation(m_Settings.fRearSeparation);
      }
      break;
    }
    default:
      break;
  }

  return true;
}