diff options
| author | 2020-09-11 10:57:27 -0400 | |
|---|---|---|
| committer | 2020-09-11 10:57:27 -0400 | |
| commit | 324029d4f9fd2381f474e608a2859360324161e5 (patch) | |
| tree | d2dc348235f05f20686c526f7092590f596f65c2 /src/audio_core/cubeb_sink.cpp | |
| parent | Merge pull request #4597 from Morph1984/mjolnir-p2 (diff) | |
| parent | Preliminary effects (diff) | |
| download | yuzu-324029d4f9fd2381f474e608a2859360324161e5.tar.gz yuzu-324029d4f9fd2381f474e608a2859360324161e5.tar.xz yuzu-324029d4f9fd2381f474e608a2859360324161e5.zip | |
Merge pull request #4310 from ogniK5377/apollo-1-prod
audio_core: Apollo Part 1, AudioRenderer refactor
Diffstat (limited to 'src/audio_core/cubeb_sink.cpp')
| -rw-r--r-- | src/audio_core/cubeb_sink.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp index c27df946c..83c06c0ed 100644 --- a/src/audio_core/cubeb_sink.cpp +++ b/src/audio_core/cubeb_sink.cpp | |||
| @@ -23,14 +23,24 @@ class CubebSinkStream final : public SinkStream { | |||
| 23 | public: | 23 | public: |
| 24 | CubebSinkStream(cubeb* ctx, u32 sample_rate, u32 num_channels_, cubeb_devid output_device, | 24 | CubebSinkStream(cubeb* ctx, u32 sample_rate, u32 num_channels_, cubeb_devid output_device, |
| 25 | const std::string& name) | 25 | const std::string& name) |
| 26 | : ctx{ctx}, num_channels{std::min(num_channels_, 2u)}, time_stretch{sample_rate, | 26 | : ctx{ctx}, num_channels{std::min(num_channels_, 6u)}, time_stretch{sample_rate, |
| 27 | num_channels} { | 27 | num_channels} { |
| 28 | 28 | ||
| 29 | cubeb_stream_params params{}; | 29 | cubeb_stream_params params{}; |
| 30 | params.rate = sample_rate; | 30 | params.rate = sample_rate; |
| 31 | params.channels = num_channels; | 31 | params.channels = num_channels; |
| 32 | params.format = CUBEB_SAMPLE_S16NE; | 32 | params.format = CUBEB_SAMPLE_S16NE; |
| 33 | params.layout = num_channels == 1 ? CUBEB_LAYOUT_MONO : CUBEB_LAYOUT_STEREO; | 33 | switch (num_channels) { |
| 34 | case 1: | ||
| 35 | params.layout = CUBEB_LAYOUT_MONO; | ||
| 36 | break; | ||
| 37 | case 2: | ||
| 38 | params.layout = CUBEB_LAYOUT_STEREO; | ||
| 39 | break; | ||
| 40 | case 6: | ||
| 41 | params.layout = CUBEB_LAYOUT_3F2_LFE; | ||
| 42 | break; | ||
| 43 | } | ||
| 34 | 44 | ||
| 35 | u32 minimum_latency{}; | 45 | u32 minimum_latency{}; |
| 36 | if (cubeb_get_min_latency(ctx, ¶ms, &minimum_latency) != CUBEB_OK) { | 46 | if (cubeb_get_min_latency(ctx, ¶ms, &minimum_latency) != CUBEB_OK) { |
| @@ -193,6 +203,7 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const | |||
| 193 | const std::size_t samples_to_write = num_channels * num_frames; | 203 | const std::size_t samples_to_write = num_channels * num_frames; |
| 194 | std::size_t samples_written; | 204 | std::size_t samples_written; |
| 195 | 205 | ||
| 206 | /* | ||
| 196 | if (Settings::values.enable_audio_stretching.GetValue()) { | 207 | if (Settings::values.enable_audio_stretching.GetValue()) { |
| 197 | const std::vector<s16> in{impl->queue.Pop()}; | 208 | const std::vector<s16> in{impl->queue.Pop()}; |
| 198 | const std::size_t num_in{in.size() / num_channels}; | 209 | const std::size_t num_in{in.size() / num_channels}; |
| @@ -207,7 +218,8 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const | |||
| 207 | } | 218 | } |
| 208 | } else { | 219 | } else { |
| 209 | samples_written = impl->queue.Pop(buffer, samples_to_write); | 220 | samples_written = impl->queue.Pop(buffer, samples_to_write); |
| 210 | } | 221 | }*/ |
| 222 | samples_written = impl->queue.Pop(buffer, samples_to_write); | ||
| 211 | 223 | ||
| 212 | if (samples_written >= num_channels) { | 224 | if (samples_written >= num_channels) { |
| 213 | std::memcpy(&impl->last_frame[0], buffer + (samples_written - num_channels) * sizeof(s16), | 225 | std::memcpy(&impl->last_frame[0], buffer + (samples_written - num_channels) * sizeof(s16), |