buffer.h 962 B

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