audio_out.h 1.2 KB

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