buffer.h 947 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include <vector>
  6. #include "common/common_types.h"
  7. namespace AudioCore {
  8. /**
  9. * Represents a buffer of audio samples to be played in an audio stream
  10. */
  11. class Buffer {
  12. public:
  13. using Tag = u64;
  14. Buffer(Tag tag_, std::vector<s16>&& samples_) : tag{tag_}, samples{std::move(samples_)} {}
  15. /// Returns the raw audio data for the buffer
  16. std::vector<s16>& GetSamples() {
  17. return samples;
  18. }
  19. /// Returns the raw audio data for the buffer
  20. const std::vector<s16>& GetSamples() const {
  21. return samples;
  22. }
  23. /// Returns the buffer tag, this is provided by the game to the audout service
  24. Tag GetTag() const {
  25. return tag;
  26. }
  27. private:
  28. Tag tag;
  29. std::vector<s16> samples;
  30. };
  31. using BufferPtr = std::shared_ptr<Buffer>;
  32. } // namespace AudioCore