AudioPlayingDetector.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "WallpaperEngine/Application/ApplicationContext.h"
  3. #include "WallpaperEngine/Render/Drivers/Detectors/FullScreenDetector.h"
  4. namespace WallpaperEngine {
  5. namespace Application {
  6. class ApplicationContext;
  7. }
  8. namespace Render::Drivers::Detectors {
  9. class FullScreenDetector;
  10. }
  11. namespace Audio::Drivers::Detectors {
  12. /**
  13. * Base class for any implementation of audio playing detection
  14. */
  15. class AudioPlayingDetector {
  16. public:
  17. AudioPlayingDetector (
  18. Application::ApplicationContext& appContext,
  19. const Render::Drivers::Detectors::FullScreenDetector& fullscreenDetector);
  20. virtual ~AudioPlayingDetector () = default;
  21. /**
  22. * @return If any kind of sound is currently playing on the default audio device
  23. */
  24. [[nodiscard]] bool anythingPlaying () const;
  25. /**
  26. * Updates the playing status to the specified value
  27. *
  28. * @param newState
  29. */
  30. void setIsPlaying (bool newState);
  31. /**
  32. * Checks if any audio is playing and updates state accordingly
  33. */
  34. virtual void update ();
  35. protected:
  36. /**
  37. * @return The application context using this detector
  38. */
  39. [[nodiscard]] Application::ApplicationContext& getApplicationContext () const;
  40. /**
  41. * @return The fullscreen detector used
  42. */
  43. [[nodiscard]] const Render::Drivers::Detectors::FullScreenDetector& getFullscreenDetector () const;
  44. private:
  45. bool m_isPlaying = false;
  46. Application::ApplicationContext& m_applicationContext;
  47. const Render::Drivers::Detectors::FullScreenDetector& m_fullscreenDetector;
  48. };
  49. } // namespace Audio::Drivers::Detectors
  50. } // namespace WallpaperEngine