audio_out.h 1.4 KB

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