MicrophoneSystemComponent.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <MicrophoneBus.h>
  11. namespace Audio
  12. {
  13. ////////////////////////////////////////////////////////////////////////////
  14. class MicrophoneSystemComponent
  15. : public AZ::Component
  16. , protected MicrophoneRequestBus::Handler
  17. {
  18. public:
  19. AZ_COMPONENT(MicrophoneSystemComponent, "{99982335-B44A-48A9-BBE5-851B4B3BB5E3}");
  20. static void Reflect(AZ::ReflectContext* context);
  21. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  22. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  23. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  24. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  25. MicrophoneSystemComponent();
  26. ~MicrophoneSystemComponent() override;
  27. protected:
  28. ////////////////////////////////////////////////////////////////////////
  29. // AZ::Component interface implementation
  30. void Init() override;
  31. void Activate() override;
  32. void Deactivate() override;
  33. ////////////////////////////////////////////////////////////////////////
  34. ////////////////////////////////////////////////////////////////////////
  35. // MicrophoneRequestBus interface implementation
  36. bool InitializeDevice() override;
  37. void ShutdownDevice() override;
  38. bool StartSession() override;
  39. void EndSession() override;
  40. bool IsCapturing() override;
  41. SAudioInputConfig GetFormatConfig() const override;
  42. AZStd::size_t GetData(void** outputData, AZStd::size_t numFrames, const SAudioInputConfig& targetConfig, bool shouldDeinterleave) override;
  43. ////////////////////////////////////////////////////////////////////////
  44. public:
  45. class Implementation : public MicrophoneRequestBus::Handler
  46. {
  47. public:
  48. AZ_CLASS_ALLOCATOR(Implementation, AZ::SystemAllocator);
  49. static Implementation* Create();
  50. };
  51. private:
  52. Implementation* m_impl = nullptr;
  53. bool m_initialized = false;
  54. };
  55. } // namespace Audio