diff options
author | Martijn Kaijser <machine.sanctum@gmail.com> | 2013-10-06 09:49:57 -0700 |
---|---|---|
committer | Martijn Kaijser <machine.sanctum@gmail.com> | 2013-10-06 09:49:57 -0700 |
commit | 93a2953ba2fc31b2f1ac0af48e57f96f814328fe (patch) | |
tree | 03a7e7ca5384cca74c21fe0effe1abd0267f047c | |
parent | bd854dd0d5350755ddd958d0c4b99092bd2847a9 (diff) | |
parent | 06d741dd40b56dbd8b705151b34d0b5f22afd349 (diff) |
Merge pull request #3356 from popcornmix/streamsilence
[rbp] Add streamsilence option for hdmi
-rw-r--r-- | xbmc/cores/AudioEngine/AEFactory.cpp | 14 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/AEFactory.h | 3 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.cpp | 127 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.h | 74 | ||||
-rw-r--r-- | xbmc/cores/AudioEngine/Makefile.in | 2 |
5 files changed, 213 insertions, 7 deletions
diff --git a/xbmc/cores/AudioEngine/AEFactory.cpp b/xbmc/cores/AudioEngine/AEFactory.cpp index 920c26b427..16fc7085c1 100644 --- a/xbmc/cores/AudioEngine/AEFactory.cpp +++ b/xbmc/cores/AudioEngine/AEFactory.cpp @@ -34,6 +34,10 @@ #include "Engines/PulseAE/PulseAE.h" #endif +#if defined(TARGET_RASPBERRY_PI) + #include "Engines/PiAudio/PiAudioAE.h" +#endif + #include "guilib/LocalizeStrings.h" #include "settings/Setting.h" #include "utils/StringUtils.h" @@ -52,7 +56,7 @@ bool CAEFactory::LoadEngine() bool loaded = false; #if defined(TARGET_RASPBERRY_PI) - return true; + return CAEFactory::LoadEngine(AE_ENGINE_PIAUDIO); #elif defined(TARGET_DARWIN) return CAEFactory::LoadEngine(AE_ENGINE_COREAUDIO); #endif @@ -104,7 +108,9 @@ bool CAEFactory::LoadEngine(enum AEEngine engine) #if defined(HAS_PULSEAUDIO) case AE_ENGINE_PULSE : AE = new CPulseAE(); break; #endif - +#if defined(TARGET_RASPBERRY_PI) + case AE_ENGINE_PIAUDIO : AE = new PiAudioAE::CPiAudioAE(); break; +#endif default: return false; } @@ -130,10 +136,6 @@ void CAEFactory::UnLoadEngine() bool CAEFactory::StartEngine() { -#if defined(TARGET_RASPBERRY_PI) - return true; -#endif - if (!AE) return false; diff --git a/xbmc/cores/AudioEngine/AEFactory.h b/xbmc/cores/AudioEngine/AEFactory.h index ed345b6140..e3e8a3a30c 100644 --- a/xbmc/cores/AudioEngine/AEFactory.h +++ b/xbmc/cores/AudioEngine/AEFactory.h @@ -32,7 +32,8 @@ enum AEEngine AE_ENGINE_SOFT, AE_ENGINE_COREAUDIO, AE_ENGINE_PULSE, - AE_ENGINE_ACTIVE + AE_ENGINE_ACTIVE, + AE_ENGINE_PIAUDIO }; class CAEFactory diff --git a/xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.cpp b/xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.cpp new file mode 100644 index 0000000000..6bcd69d0c7 --- /dev/null +++ b/xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "PiAudioAE.h" + +using namespace PiAudioAE; +#include "Utils/AEUtil.h" + +#include "settings/Settings.h" +#include "settings/AdvancedSettings.h" +#include "windowing/WindowingFactory.h" + +#if defined(TARGET_RASPBERRY_PI) +#include "linux/RBP.h" +#endif + +CPiAudioAE::CPiAudioAE() +{ +} + +CPiAudioAE::~CPiAudioAE() +{ +} + +bool CPiAudioAE::Initialize() +{ + UpdateStreamSilence(); + return true; +} + +void CPiAudioAE::UpdateStreamSilence() +{ +#if defined(TARGET_RASPBERRY_PI) + bool enable = CSettings::Get().GetBool("audiooutput.streamsilence"); + char response[80] = ""; + char command[80] = ""; + sprintf(command, "force_audio hdmi %d", enable); + vc_gencmd(response, sizeof response, command); +#endif +} + +bool CPiAudioAE::Suspend() +{ + return true; +} + +bool CPiAudioAE::Resume() +{ + return true; +} + +float CPiAudioAE::GetVolume() +{ + return m_aeVolume; +} + +void CPiAudioAE::SetVolume(const float volume) +{ + m_aeVolume = std::max( 0.0f, std::min(1.0f, volume)); +} + +void CPiAudioAE::SetMute(const bool enabled) +{ + m_aeMuted = enabled; +} + +bool CPiAudioAE::IsMuted() +{ + return m_aeMuted; +} + +IAEStream *CPiAudioAE::MakeStream(enum AEDataFormat dataFormat, unsigned int sampleRate, unsigned int encodedSampleRate, CAEChannelInfo channelLayout, unsigned int options) +{ + return NULL; +} + +IAEStream *CPiAudioAE::FreeStream(IAEStream *stream) +{ + return NULL; +} + +IAESound *CPiAudioAE::MakeSound(const std::string& file) +{ + return NULL; +} + +void CPiAudioAE::FreeSound(IAESound *sound) +{ +} + +bool CPiAudioAE::SupportsRaw() +{ + return true; +} + +bool CPiAudioAE::SupportsDrain() +{ + return true; +} + +void CPiAudioAE::OnSettingsChange(const std::string& setting) +{ + if (setting == "audiooutput.streamsilence") + UpdateStreamSilence(); +} + +void CPiAudioAE::EnumerateOutputDevices(AEDeviceList &devices, bool passthrough) +{ +} + diff --git a/xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.h b/xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.h new file mode 100644 index 0000000000..419241b9c1 --- /dev/null +++ b/xbmc/cores/AudioEngine/Engines/PiAudio/PiAudioAE.h @@ -0,0 +1,74 @@ +#pragma once +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include "system.h" +#include "threads/Thread.h" + +#include "Interfaces/AEStream.h" +#include "Interfaces/AESound.h" +#include "AEFactory.h" + +namespace PiAudioAE +{ + +class CPiAudioAE : public IAE +{ +protected: + friend class ::CAEFactory; + CPiAudioAE(); + virtual ~CPiAudioAE(); + virtual bool Initialize(); + +public: + virtual bool Suspend(); + virtual bool Resume(); + virtual void OnSettingsChange(const std::string& setting); + + virtual float GetVolume(); + virtual void SetVolume(const float volume); + virtual void SetMute(const bool enabled); + virtual bool IsMuted(); + virtual void SetSoundMode(const int mode) {} + + /* returns a new stream for data in the specified format */ + virtual IAEStream *MakeStream(enum AEDataFormat dataFormat, unsigned int sampleRate, unsigned int encodedSampleRate, CAEChannelInfo channelLayout, unsigned int options = 0); + virtual IAEStream *FreeStream(IAEStream *stream); + + /* returns a new sound object */ + virtual IAESound *MakeSound(const std::string& file); + virtual void FreeSound(IAESound *sound); + + virtual void GarbageCollect() {}; + virtual void EnumerateOutputDevices(AEDeviceList &devices, bool passthrough); + + virtual bool SupportsRaw(); + virtual bool SupportsDrain(); + + virtual void OnLostDevice() {} + virtual void OnResetDevice() {} + +protected: + void UpdateStreamSilence(); + // polled via the interface + float m_aeVolume; + bool m_aeMuted; +}; +}; diff --git a/xbmc/cores/AudioEngine/Makefile.in b/xbmc/cores/AudioEngine/Makefile.in index 2e1a83d49d..c2d7ffae4a 100644 --- a/xbmc/cores/AudioEngine/Makefile.in +++ b/xbmc/cores/AudioEngine/Makefile.in @@ -50,6 +50,8 @@ SRCS += Engines/ActiveAE/ActiveAESound.cpp SRCS += Engines/ActiveAE/ActiveAEResample.cpp SRCS += Engines/ActiveAE/ActiveAEBuffer.cpp +SRCS += Engines/PiAudio/PiAudioAE.cpp + ifeq (@USE_ANDROID@,1) SRCS += Sinks/AESinkAUDIOTRACK.cpp else |