AudioInputStream.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "AudioSourceManager.h"
  10. #include <IAudioSystem.h>
  11. #include <AudioRingBuffer.h>
  12. namespace Audio
  13. {
  14. /**
  15. * A type of AudioInputSource representing an audio stream.
  16. * holds a buffer of the raw data and provides methods to read chunks of data at a time
  17. * to an output (AkAudioBuffer).
  18. */
  19. class AudioInputStreaming
  20. : public AudioInputSource
  21. , public AudioStreamingRequestBus::Handler
  22. {
  23. public:
  24. AUDIO_IMPL_CLASS_ALLOCATOR(AudioInputStreaming)
  25. AudioInputStreaming(const SAudioInputConfig& sourceConfig);
  26. ~AudioInputStreaming() override;
  27. // AudioInputSource Interface
  28. void ReadInput(const AudioStreamData& data) override;
  29. void WriteOutput(AkAudioBuffer* akBuffer) override;
  30. bool IsOk() const override;
  31. void OnDeactivated() override;
  32. void OnActivated() override;
  33. // AudioStreamingRequestBus::Handler Interface
  34. size_t ReadStreamingInput(const AudioStreamData& data) override;
  35. size_t ReadStreamingMultiTrackInput(AudioStreamMultiTrackData& data) override;
  36. void FlushStreamingInput();
  37. size_t GetStreamingInputNumFramesReady() const;
  38. private:
  39. AZStd::unique_ptr<RingBufferBase> m_buffer = nullptr;
  40. size_t m_framesReady;
  41. };
  42. } // namespace Audio