sink.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <vector>
  6. #include "common/common_types.h"
  7. namespace AudioCore {
  8. /**
  9. * This class is an interface for an audio sink. An audio sink accepts samples in stereo signed
  10. * PCM16 format to be output. Sinks *do not* handle resampling and expect the correct sample rate.
  11. * They are dumb outputs.
  12. */
  13. class Sink {
  14. public:
  15. virtual ~Sink() = default;
  16. /// The native rate of this sink. The sink expects to be fed samples that respect this. (Units:
  17. /// samples/sec)
  18. virtual unsigned int GetNativeSampleRate() const = 0;
  19. /**
  20. * Feed stereo samples to sink.
  21. * @param samples Samples in interleaved stereo PCM16 format.
  22. * @param sample_count Number of samples.
  23. */
  24. virtual void EnqueueSamples(const s16* samples, size_t sample_count) = 0;
  25. /// Samples enqueued that have not been played yet.
  26. virtual std::size_t SamplesInQueue() const = 0;
  27. /**
  28. * Sets the desired output device.
  29. * @param device_id ID of the desired device.
  30. */
  31. virtual void SetDevice(int device_id) = 0;
  32. /// Returns the list of available devices.
  33. virtual std::vector<std::string> GetDeviceList() const = 0;
  34. };
  35. } // namespace