audio_out.h 1.5 KB

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