audio_out.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <string>
  7. #include <vector>
  8. #include "audio_core/buffer.h"
  9. #include "audio_core/sink.h"
  10. #include "audio_core/stream.h"
  11. #include "common/common_types.h"
  12. namespace AudioCore {
  13. /**
  14. * Represents an audio playback interface, used to open and play audio streams
  15. */
  16. class AudioOut {
  17. public:
  18. /// Opens a new audio stream
  19. StreamPtr OpenStream(u32 sample_rate, u32 num_channels, std::string&& name,
  20. Stream::ReleaseCallback&& release_callback);
  21. /// Returns a vector of recently released buffers specified by tag for the specified stream
  22. std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count);
  23. /// Starts an audio stream for playback
  24. void StartStream(StreamPtr stream);
  25. /// Stops an audio stream that is currently playing
  26. void StopStream(StreamPtr stream);
  27. /// Queues a buffer into the specified audio stream, returns true on success
  28. bool QueueBuffer(StreamPtr stream, Buffer::Tag tag, std::vector<s16>&& data);
  29. private:
  30. SinkPtr sink;
  31. };
  32. } // namespace AudioCore