mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Added sound muting when apps are fullscreen too
Finally closes #150 and #152 Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
978f56cdca
commit
45761fb858
@ -266,12 +266,6 @@ namespace WallpaperEngine::Application
|
|||||||
|
|
||||||
void CWallpaperApplication::show ()
|
void CWallpaperApplication::show ()
|
||||||
{
|
{
|
||||||
// audio playing detector
|
|
||||||
WallpaperEngine::Audio::Detectors::CPulseAudioPlayingDetector audioDetector (this->m_context);
|
|
||||||
// initialize sdl audio driver
|
|
||||||
WallpaperEngine::Audio::Drivers::CSDLAudioDriver audioDriver (this->m_context, audioDetector);
|
|
||||||
// initialize audio context
|
|
||||||
WallpaperEngine::Audio::CAudioContext audioContext (audioDriver);
|
|
||||||
// initialize OpenGL driver
|
// initialize OpenGL driver
|
||||||
WallpaperEngine::Render::Drivers::CX11OpenGLDriver videoDriver ("wallpaperengine");
|
WallpaperEngine::Render::Drivers::CX11OpenGLDriver videoDriver ("wallpaperengine");
|
||||||
// initialize the input subsystem
|
// initialize the input subsystem
|
||||||
@ -280,6 +274,12 @@ namespace WallpaperEngine::Application
|
|||||||
WallpaperEngine::Render::Drivers::Output::COutput* output;
|
WallpaperEngine::Render::Drivers::Output::COutput* output;
|
||||||
// fullscreen detector is common for the different render modes
|
// fullscreen detector is common for the different render modes
|
||||||
WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector fullscreenDetector (videoDriver);
|
WallpaperEngine::Render::Drivers::Detectors::CX11FullScreenDetector fullscreenDetector (videoDriver);
|
||||||
|
// audio playing detector
|
||||||
|
WallpaperEngine::Audio::Detectors::CPulseAudioPlayingDetector audioDetector (this->m_context, fullscreenDetector);
|
||||||
|
// initialize sdl audio driver
|
||||||
|
WallpaperEngine::Audio::Drivers::CSDLAudioDriver audioDriver (this->m_context, audioDetector);
|
||||||
|
// initialize audio context
|
||||||
|
WallpaperEngine::Audio::CAudioContext audioContext (audioDriver);
|
||||||
|
|
||||||
// initialize the requested output
|
// initialize the requested output
|
||||||
switch (this->m_context.settings.render.mode)
|
switch (this->m_context.settings.render.mode)
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace WallpaperEngine::Audio::Detectors
|
namespace WallpaperEngine::Audio::Detectors
|
||||||
{
|
{
|
||||||
CAudioPlayingDetector::CAudioPlayingDetector (Application::CApplicationContext& appContext) :
|
CAudioPlayingDetector::CAudioPlayingDetector (
|
||||||
m_applicationContext (appContext)
|
Application::CApplicationContext& appContext,
|
||||||
|
Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector) :
|
||||||
|
m_applicationContext (appContext),
|
||||||
|
m_fullscreenDetector (fullscreenDetector)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,4 +14,9 @@ namespace WallpaperEngine::Audio::Detectors
|
|||||||
{
|
{
|
||||||
return this->m_applicationContext;
|
return this->m_applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Render::Drivers::Detectors::CFullScreenDetector& CAudioPlayingDetector::getFullscreenDetector ()
|
||||||
|
{
|
||||||
|
return this->m_fullscreenDetector;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,18 +1,26 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "WallpaperEngine/Render/Drivers/Detectors/CFullScreenDetector.h"
|
||||||
#include "WallpaperEngine/Application/CApplicationContext.h"
|
#include "WallpaperEngine/Application/CApplicationContext.h"
|
||||||
|
|
||||||
namespace WallpaperEngine::Application
|
namespace WallpaperEngine
|
||||||
{
|
{
|
||||||
|
namespace Application
|
||||||
|
{
|
||||||
class CApplicationContext;
|
class CApplicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace WallpaperEngine::Audio::Detectors
|
namespace Render::Drivers::Detectors
|
||||||
{
|
{
|
||||||
|
class CFullScreenDetector;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Audio::Detectors
|
||||||
|
{
|
||||||
class CAudioPlayingDetector
|
class CAudioPlayingDetector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CAudioPlayingDetector (Application::CApplicationContext& appContext);
|
CAudioPlayingDetector (Application::CApplicationContext& appContext, Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If any kind of sound is currently playing on the default audio device
|
* @return If any kind of sound is currently playing on the default audio device
|
||||||
@ -22,8 +30,14 @@ namespace WallpaperEngine::Audio::Detectors
|
|||||||
* @return The application context using this detector
|
* @return The application context using this detector
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] Application::CApplicationContext& getApplicationContext ();
|
[[nodiscard]] Application::CApplicationContext& getApplicationContext ();
|
||||||
|
/**
|
||||||
|
* @return The fullscreen detector used
|
||||||
|
*/
|
||||||
|
[[nodiscard]] Render::Drivers::Detectors::CFullScreenDetector& getFullscreenDetector ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application::CApplicationContext& m_applicationContext;
|
Application::CApplicationContext& m_applicationContext;
|
||||||
|
Render::Drivers::Detectors::CFullScreenDetector& m_fullscreenDetector;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,10 @@ namespace WallpaperEngine::Audio::Detectors
|
|||||||
pa_operation_unref (op);
|
pa_operation_unref (op);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPulseAudioPlayingDetector::CPulseAudioPlayingDetector (Application::CApplicationContext& appContext) :
|
CPulseAudioPlayingDetector::CPulseAudioPlayingDetector (
|
||||||
CAudioPlayingDetector (appContext),
|
Application::CApplicationContext& appContext,
|
||||||
|
Render::Drivers::Detectors::CFullScreenDetector& fullscreenDetector) :
|
||||||
|
CAudioPlayingDetector (appContext, fullscreenDetector),
|
||||||
m_mainloop (nullptr),
|
m_mainloop (nullptr),
|
||||||
m_mainloopApi (nullptr),
|
m_mainloopApi (nullptr),
|
||||||
m_context (nullptr),
|
m_context (nullptr),
|
||||||
@ -69,6 +71,8 @@ namespace WallpaperEngine::Audio::Detectors
|
|||||||
{
|
{
|
||||||
if (!this->getApplicationContext ().settings.audio.automute)
|
if (!this->getApplicationContext ().settings.audio.automute)
|
||||||
return false;
|
return false;
|
||||||
|
if (this->getFullscreenDetector ().anythingFullscreen ())
|
||||||
|
return true;
|
||||||
|
|
||||||
// reset playing state
|
// reset playing state
|
||||||
this->setIsPlaying (false);
|
this->setIsPlaying (false);
|
||||||
|
@ -10,7 +10,7 @@ namespace WallpaperEngine::Audio::Detectors
|
|||||||
class CPulseAudioPlayingDetector : public CAudioPlayingDetector
|
class CPulseAudioPlayingDetector : public CAudioPlayingDetector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CPulseAudioPlayingDetector (Application::CApplicationContext& appContext);
|
explicit CPulseAudioPlayingDetector (Application::CApplicationContext& appContext, Render::Drivers::Detectors::CFullScreenDetector&);
|
||||||
~CPulseAudioPlayingDetector ();
|
~CPulseAudioPlayingDetector ();
|
||||||
|
|
||||||
[[nodiscard]] bool anythingPlaying () override;
|
[[nodiscard]] bool anythingPlaying () override;
|
||||||
|
Loading…
Reference in New Issue
Block a user