AudioSettingsController.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // Created by Tobias Hieta on 21/08/15.
  3. //
  4. #include "AudioSettingsController.h"
  5. #include "SettingsComponent.h"
  6. #include "SettingsSection.h"
  7. #include "PlayerComponent.h"
  8. /////////////////////////////////////////////////////////////////////////////////////////
  9. AudioSettingsController::AudioSettingsController(QObject* parent) : QObject(parent)
  10. {
  11. SettingsSection* audioSection = SettingsComponent::Get().getSection(SETTINGS_SECTION_AUDIO);
  12. connect(audioSection, &SettingsSection::valuesUpdated, this, &AudioSettingsController::valuesUpdated);
  13. }
  14. /////////////////////////////////////////////////////////////////////////////////////////
  15. void AudioSettingsController::setHiddenPassthrough(const QStringList& codecs, bool hidden)
  16. {
  17. SettingsSection* audioSection = SettingsComponent::Get().getSection(SETTINGS_SECTION_AUDIO);
  18. for(const QString& codec : codecs)
  19. audioSection->setValueHidden("passthrough." + codec, hidden);
  20. }
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. void AudioSettingsController::valuesUpdated(const QVariantMap& values)
  23. {
  24. SettingsSection* audioSection = SettingsComponent::Get().getSection(SETTINGS_SECTION_AUDIO);
  25. auto prevDescriptions = audioSection->descriptions();
  26. QString type = SettingsComponent::Get().value(SETTINGS_SECTION_AUDIO, "devicetype").toString();
  27. audioSection->setValueHidden("channels", false);
  28. if (type == AUDIO_DEVICE_TYPE_BASIC)
  29. {
  30. setHiddenPassthrough(PlayerComponent::AudioCodecsAll(), true);
  31. }
  32. else if (type == AUDIO_DEVICE_TYPE_HDMI)
  33. {
  34. setHiddenPassthrough(PlayerComponent::AudioCodecsAll(), false);
  35. }
  36. else if (type == AUDIO_DEVICE_TYPE_SPDIF)
  37. {
  38. setHiddenPassthrough(PlayerComponent::AudioCodecsAll(), true);
  39. setHiddenPassthrough(PlayerComponent::AudioCodecsSPDIF(), false);
  40. audioSection->setValueHidden("channels", true);
  41. }
  42. auto newDescriptions = audioSection->descriptions();
  43. if (prevDescriptions != newDescriptions)
  44. emit settingsUpdated(SETTINGS_SECTION_AUDIO, newDescriptions);
  45. }