You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/AudioSystem/Code/Source/AudioSystemGemSystemCompone...

101 lines
4.2 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Component/Component.h>
#include <AzFramework/API/ApplicationAPI.h>
#include <IAudioSystem.h>
#include <ISystem.h>
#if defined(AUDIO_SYSTEM_EDITOR)
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <Include/IPlugin.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#endif // AUDIO_SYSTEM_EDITOR
namespace AudioSystemGem
{
class AudioSystemGemSystemComponent
: public AZ::Component
, public ISystemEventListener
, public AzFramework::ApplicationLifecycleEvents::Bus::Handler
, protected Audio::Gem::AudioSystemGemRequestBus::Handler
#if defined(AUDIO_SYSTEM_EDITOR)
, private AzToolsFramework::EditorEvents::Bus::Handler
#endif // AUDIO_SYSTEM_EDITOR
{
public:
AZ_COMPONENT(AudioSystemGemSystemComponent, "{55095EE9-38E6-485F-8314-DF35CDFECC6B}", AZ::Component);
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
protected:
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// Audio::Gem::AudioSystemGemRequestBus interface implementation
bool Initialize(const SSystemInitParams* initParams) override;
void Release() override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// ISystemEventListener
void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AzFramework::ApplicationLifecycleEvents interface implementation
void OnApplicationConstrained(Event /*lastEvent*/) override;
void OnApplicationUnconstrained(Event /*lastEvent*/) override;
////////////////////////////////////////////////////////////////////////
#if defined(AUDIO_SYSTEM_EDITOR)
////////////////////////////////////////////////////////////////////////
// AzToolsFramework::EditorEvents::Bus interface implementation
void NotifyRegisterViews() override;
void NotifyIEditorAvailable(IEditor*) override;
////////////////////////////////////////////////////////////////////////
#endif // AUDIO_SYSTEM_EDITOR
private:
////////////////////////////////////////////////////////////////////////
bool CreateAudioSystem();
bool CreateNullAudioSystem();
void PrepareAudioSystem();
Audio::SAudioRequest m_loseFocusRequest;
Audio::SAudioRequest m_getFocusRequest;
Audio::SAudioManagerRequestData<Audio::eAMRT_LOSE_FOCUS> m_loseFocusData;
Audio::SAudioManagerRequestData<Audio::eAMRT_GET_FOCUS> m_getFocusData;
/// This is here to express ownership
AZStd::unique_ptr<Audio::IAudioSystem> m_audioSystem;
#if defined(AUDIO_SYSTEM_EDITOR)
AZStd::unique_ptr<IPlugin> m_editorPlugin;
#endif // AUDIO_SYSTEM_EDITOR
};
} // namespace AudioSystemGem