diff options
| author | 2018-07-28 13:35:22 -0400 | |
|---|---|---|
| committer | 2018-07-30 18:58:40 -0400 | |
| commit | 0e8a2c7222b978507f62d7e0b83187b16532eae8 (patch) | |
| tree | bfcc69cc41fc9cf9fe9a80c321f27ba50d17065f /src/audio_core/stream.cpp | |
| parent | audio_core: Move to audout_u impl. (diff) | |
| download | yuzu-0e8a2c7222b978507f62d7e0b83187b16532eae8.tar.gz yuzu-0e8a2c7222b978507f62d7e0b83187b16532eae8.tar.xz yuzu-0e8a2c7222b978507f62d7e0b83187b16532eae8.zip | |
audio_core: Misc. improvements to stream/buffer/audio_out.
Diffstat (limited to 'src/audio_core/stream.cpp')
| -rw-r--r-- | src/audio_core/stream.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 82bff4b9e..63edc6c8d 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -13,24 +13,24 @@ namespace AudioCore { | |||
| 13 | 13 | ||
| 14 | constexpr size_t MaxAudioBufferCount{32}; | 14 | constexpr size_t MaxAudioBufferCount{32}; |
| 15 | 15 | ||
| 16 | /// Returns the sample size for the specified audio stream format | 16 | u32 Stream::GetNumChannels() const { |
| 17 | static size_t SampleSizeFromFormat(Stream::Format format) { | ||
| 18 | switch (format) { | 17 | switch (format) { |
| 19 | case Stream::Format::Mono16: | 18 | case Format::Mono16: |
| 19 | return 1; | ||
| 20 | case Format::Stereo16: | ||
| 20 | return 2; | 21 | return 2; |
| 21 | case Stream::Format::Stereo16: | 22 | case Format::Multi51Channel16: |
| 22 | return 4; | 23 | return 6; |
| 23 | case Stream::Format::Multi51Channel16: | 24 | } |
| 24 | return 12; | ||
| 25 | }; | ||
| 26 | |||
| 27 | LOG_CRITICAL(Audio, "Unimplemented format={}", static_cast<u32>(format)); | 25 | LOG_CRITICAL(Audio, "Unimplemented format={}", static_cast<u32>(format)); |
| 28 | UNREACHABLE(); | 26 | UNREACHABLE(); |
| 29 | return {}; | 27 | return {}; |
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | Stream::Stream(int sample_rate, Format format, ReleaseCallback&& release_callback) | 30 | u32 Stream::GetSampleSize() const { |
| 33 | : sample_rate{sample_rate}, format{format}, release_callback{std::move(release_callback)} { | 31 | return GetNumChannels() * 2; |
| 32 | } | ||
| 33 | |||
| 34 | release_event = CoreTiming::RegisterEvent( | 34 | release_event = CoreTiming::RegisterEvent( |
| 35 | "Stream::Release", [this](u64 userdata, int cycles_late) { ReleaseActiveBuffer(); }); | 35 | "Stream::Release", [this](u64 userdata, int cycles_late) { ReleaseActiveBuffer(); }); |
| 36 | } | 36 | } |
| @@ -45,7 +45,7 @@ void Stream::Stop() { | |||
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const { | 47 | s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const { |
| 48 | const size_t num_samples{buffer.GetData().size() / SampleSizeFromFormat(format)}; | 48 | const size_t num_samples{buffer.GetData().size() / GetSampleSize()}; |
| 49 | return CoreTiming::usToCycles((static_cast<u64>(num_samples) * 1000000) / sample_rate); | 49 | return CoreTiming::usToCycles((static_cast<u64>(num_samples) * 1000000) / sample_rate); |
| 50 | } | 50 | } |
| 51 | 51 | ||