summaryrefslogtreecommitdiff
path: root/src/audio_core
diff options
context:
space:
mode:
authorGravatar fearlessTobi2018-09-15 15:21:06 +0200
committerGravatar fearlessTobi2018-09-15 15:21:06 +0200
commit63c2e32e207d31ecadd9022e1d7cd705c9febac8 (patch)
tree8a90e8ef2804f147dff7225a543a8740ecf7160c /src/audio_core
parentMerge pull request #1310 from lioncash/kernel-ns (diff)
downloadyuzu-63c2e32e207d31ecadd9022e1d7cd705c9febac8.tar.gz
yuzu-63c2e32e207d31ecadd9022e1d7cd705c9febac8.tar.xz
yuzu-63c2e32e207d31ecadd9022e1d7cd705c9febac8.zip
Port #4182 from Citra: "Prefix all size_t with std::"
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/algorithm/filter.cpp12
-rw-r--r--src/audio_core/algorithm/filter.h4
-rw-r--r--src/audio_core/algorithm/interpolate.cpp12
-rw-r--r--src/audio_core/algorithm/interpolate.h4
-rw-r--r--src/audio_core/audio_out.cpp3
-rw-r--r--src/audio_core/audio_out.h2
-rw-r--r--src/audio_core/audio_renderer.cpp24
-rw-r--r--src/audio_core/audio_renderer.h8
-rw-r--r--src/audio_core/codec.cpp20
-rw-r--r--src/audio_core/codec.h2
-rw-r--r--src/audio_core/cubeb_sink.cpp21
-rw-r--r--src/audio_core/null_sink.h2
-rw-r--r--src/audio_core/stream.cpp8
-rw-r--r--src/audio_core/stream.h4
-rw-r--r--src/audio_core/time_stretch.cpp3
-rw-r--r--src/audio_core/time_stretch.h2
16 files changed, 67 insertions, 64 deletions
diff --git a/src/audio_core/algorithm/filter.cpp b/src/audio_core/algorithm/filter.cpp
index 9fcd0614d..f65bf64f7 100644
--- a/src/audio_core/algorithm/filter.cpp
+++ b/src/audio_core/algorithm/filter.cpp
@@ -35,12 +35,12 @@ Filter::Filter(double a0, double a1, double a2, double b0, double b1, double b2)
35 : a1(a1 / a0), a2(a2 / a0), b0(b0 / a0), b1(b1 / a0), b2(b2 / a0) {} 35 : a1(a1 / a0), a2(a2 / a0), b0(b0 / a0), b1(b1 / a0), b2(b2 / a0) {}
36 36
37void Filter::Process(std::vector<s16>& signal) { 37void Filter::Process(std::vector<s16>& signal) {
38 const size_t num_frames = signal.size() / 2; 38 const std::size_t num_frames = signal.size() / 2;
39 for (size_t i = 0; i < num_frames; i++) { 39 for (std::size_t i = 0; i < num_frames; i++) {
40 std::rotate(in.begin(), in.end() - 1, in.end()); 40 std::rotate(in.begin(), in.end() - 1, in.end());
41 std::rotate(out.begin(), out.end() - 1, out.end()); 41 std::rotate(out.begin(), out.end() - 1, out.end());
42 42
43 for (size_t ch = 0; ch < channel_count; ch++) { 43 for (std::size_t ch = 0; ch < channel_count; ch++) {
44 in[0][ch] = signal[i * channel_count + ch]; 44 in[0][ch] = signal[i * channel_count + ch];
45 45
46 out[0][ch] = b0 * in[0][ch] + b1 * in[1][ch] + b2 * in[2][ch] - a1 * out[1][ch] - 46 out[0][ch] = b0 * in[0][ch] + b1 * in[1][ch] + b2 * in[2][ch] - a1 * out[1][ch] -
@@ -54,14 +54,14 @@ void Filter::Process(std::vector<s16>& signal) {
54/// Calculates the appropriate Q for each biquad in a cascading filter. 54/// Calculates the appropriate Q for each biquad in a cascading filter.
55/// @param total_count The total number of biquads to be cascaded. 55/// @param total_count The total number of biquads to be cascaded.
56/// @param index 0-index of the biquad to calculate the Q value for. 56/// @param index 0-index of the biquad to calculate the Q value for.
57static double CascadingBiquadQ(size_t total_count, size_t index) { 57static double CascadingBiquadQ(std::size_t total_count, std::size_t index) {
58 const double pole = M_PI * (2 * index + 1) / (4.0 * total_count); 58 const double pole = M_PI * (2 * index + 1) / (4.0 * total_count);
59 return 1.0 / (2.0 * std::cos(pole)); 59 return 1.0 / (2.0 * std::cos(pole));
60} 60}
61 61
62CascadingFilter CascadingFilter::LowPass(double cutoff, size_t cascade_size) { 62CascadingFilter CascadingFilter::LowPass(double cutoff, std::size_t cascade_size) {
63 std::vector<Filter> cascade(cascade_size); 63 std::vector<Filter> cascade(cascade_size);
64 for (size_t i = 0; i < cascade_size; i++) { 64 for (std::size_t i = 0; i < cascade_size; i++) {
65 cascade[i] = Filter::LowPass(cutoff, CascadingBiquadQ(cascade_size, i)); 65 cascade[i] = Filter::LowPass(cutoff, CascadingBiquadQ(cascade_size, i));
66 } 66 }
67 return CascadingFilter{std::move(cascade)}; 67 return CascadingFilter{std::move(cascade)};
diff --git a/src/audio_core/algorithm/filter.h b/src/audio_core/algorithm/filter.h
index a41beef98..3546d149b 100644
--- a/src/audio_core/algorithm/filter.h
+++ b/src/audio_core/algorithm/filter.h
@@ -30,7 +30,7 @@ public:
30 void Process(std::vector<s16>& signal); 30 void Process(std::vector<s16>& signal);
31 31
32private: 32private:
33 static constexpr size_t channel_count = 2; 33 static constexpr std::size_t channel_count = 2;
34 34
35 /// Coefficients are in normalized form (a0 = 1.0). 35 /// Coefficients are in normalized form (a0 = 1.0).
36 double a1, a2, b0, b1, b2; 36 double a1, a2, b0, b1, b2;
@@ -46,7 +46,7 @@ public:
46 /// Creates a cascading low-pass filter. 46 /// Creates a cascading low-pass filter.
47 /// @param cutoff Determines the cutoff frequency. A value from 0.0 to 1.0. 47 /// @param cutoff Determines the cutoff frequency. A value from 0.0 to 1.0.
48 /// @param cascade_size Number of biquads in cascade. 48 /// @param cascade_size Number of biquads in cascade.
49 static CascadingFilter LowPass(double cutoff, size_t cascade_size); 49 static CascadingFilter LowPass(double cutoff, std::size_t cascade_size);
50 50
51 /// Passthrough. 51 /// Passthrough.
52 CascadingFilter(); 52 CascadingFilter();
diff --git a/src/audio_core/algorithm/interpolate.cpp b/src/audio_core/algorithm/interpolate.cpp
index 11459821f..3aea9b0f2 100644
--- a/src/audio_core/algorithm/interpolate.cpp
+++ b/src/audio_core/algorithm/interpolate.cpp
@@ -14,7 +14,7 @@
14namespace AudioCore { 14namespace AudioCore {
15 15
16/// The Lanczos kernel 16/// The Lanczos kernel
17static double Lanczos(size_t a, double x) { 17static double Lanczos(std::size_t a, double x) {
18 if (x == 0.0) 18 if (x == 0.0)
19 return 1.0; 19 return 1.0;
20 const double px = M_PI * x; 20 const double px = M_PI * x;
@@ -37,15 +37,15 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input,
37 } 37 }
38 state.nyquist.Process(input); 38 state.nyquist.Process(input);
39 39
40 constexpr size_t taps = InterpolationState::lanczos_taps; 40 constexpr std::size_t taps = InterpolationState::lanczos_taps;
41 const size_t num_frames = input.size() / 2; 41 const std::size_t num_frames = input.size() / 2;
42 42
43 std::vector<s16> output; 43 std::vector<s16> output;
44 output.reserve(static_cast<size_t>(input.size() / ratio + 4)); 44 output.reserve(static_cast<std::size_t>(input.size() / ratio + 4));
45 45
46 double& pos = state.position; 46 double& pos = state.position;
47 auto& h = state.history; 47 auto& h = state.history;
48 for (size_t i = 0; i < num_frames; ++i) { 48 for (std::size_t i = 0; i < num_frames; ++i) {
49 std::rotate(h.begin(), h.end() - 1, h.end()); 49 std::rotate(h.begin(), h.end() - 1, h.end());
50 h[0][0] = input[i * 2 + 0]; 50 h[0][0] = input[i * 2 + 0];
51 h[0][1] = input[i * 2 + 1]; 51 h[0][1] = input[i * 2 + 1];
@@ -53,7 +53,7 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input,
53 while (pos <= 1.0) { 53 while (pos <= 1.0) {
54 double l = 0.0; 54 double l = 0.0;
55 double r = 0.0; 55 double r = 0.0;
56 for (size_t j = 0; j < h.size(); j++) { 56 for (std::size_t j = 0; j < h.size(); j++) {
57 l += Lanczos(taps, pos + j - taps + 1) * h[j][0]; 57 l += Lanczos(taps, pos + j - taps + 1) * h[j][0];
58 r += Lanczos(taps, pos + j - taps + 1) * h[j][1]; 58 r += Lanczos(taps, pos + j - taps + 1) * h[j][1];
59 } 59 }
diff --git a/src/audio_core/algorithm/interpolate.h b/src/audio_core/algorithm/interpolate.h
index c79c2eef4..edbd6460f 100644
--- a/src/audio_core/algorithm/interpolate.h
+++ b/src/audio_core/algorithm/interpolate.h
@@ -12,8 +12,8 @@
12namespace AudioCore { 12namespace AudioCore {
13 13
14struct InterpolationState { 14struct InterpolationState {
15 static constexpr size_t lanczos_taps = 4; 15 static constexpr std::size_t lanczos_taps = 4;
16 static constexpr size_t history_size = lanczos_taps * 2 - 1; 16 static constexpr std::size_t history_size = lanczos_taps * 2 - 1;
17 17
18 double current_ratio = 0.0; 18 double current_ratio = 0.0;
19 CascadingFilter nyquist; 19 CascadingFilter nyquist;
diff --git a/src/audio_core/audio_out.cpp b/src/audio_core/audio_out.cpp
index 12632a95c..0c8f5b18e 100644
--- a/src/audio_core/audio_out.cpp
+++ b/src/audio_core/audio_out.cpp
@@ -39,7 +39,8 @@ StreamPtr AudioOut::OpenStream(u32 sample_rate, u32 num_channels, std::string&&
39 sink->AcquireSinkStream(sample_rate, num_channels, name), std::move(name)); 39 sink->AcquireSinkStream(sample_rate, num_channels, name), std::move(name));
40} 40}
41 41
42std::vector<Buffer::Tag> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) { 42std::vector<Buffer::Tag> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream,
43 std::size_t max_count) {
43 return stream->GetTagsAndReleaseBuffers(max_count); 44 return stream->GetTagsAndReleaseBuffers(max_count);
44} 45}
45 46
diff --git a/src/audio_core/audio_out.h b/src/audio_core/audio_out.h
index 39b7e656b..df9607ac7 100644
--- a/src/audio_core/audio_out.h
+++ b/src/audio_core/audio_out.h
@@ -25,7 +25,7 @@ public:
25 Stream::ReleaseCallback&& release_callback); 25 Stream::ReleaseCallback&& release_callback);
26 26
27 /// Returns a vector of recently released buffers specified by tag for the specified stream 27 /// Returns a vector of recently released buffers specified by tag for the specified stream
28 std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count); 28 std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(StreamPtr stream, std::size_t max_count);
29 29
30 /// Starts an audio stream for playback 30 /// Starts an audio stream for playback
31 void StartStream(StreamPtr stream); 31 void StartStream(StreamPtr stream);
diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp
index a75cd3be5..ed3b7defc 100644
--- a/src/audio_core/audio_renderer.cpp
+++ b/src/audio_core/audio_renderer.cpp
@@ -52,8 +52,8 @@ std::vector<u8> AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_
52 memory_pool_count * sizeof(MemoryPoolInfo)); 52 memory_pool_count * sizeof(MemoryPoolInfo));
53 53
54 // Copy VoiceInfo structs 54 // Copy VoiceInfo structs
55 size_t offset{sizeof(UpdateDataHeader) + config.behavior_size + config.memory_pools_size + 55 std::size_t offset{sizeof(UpdateDataHeader) + config.behavior_size + config.memory_pools_size +
56 config.voice_resource_size}; 56 config.voice_resource_size};
57 for (auto& voice : voices) { 57 for (auto& voice : voices) {
58 std::memcpy(&voice.Info(), input_params.data() + offset, sizeof(VoiceInfo)); 58 std::memcpy(&voice.Info(), input_params.data() + offset, sizeof(VoiceInfo));
59 offset += sizeof(VoiceInfo); 59 offset += sizeof(VoiceInfo);
@@ -72,7 +72,7 @@ std::vector<u8> AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_
72 72
73 // Update memory pool state 73 // Update memory pool state
74 std::vector<MemoryPoolEntry> memory_pool(memory_pool_count); 74 std::vector<MemoryPoolEntry> memory_pool(memory_pool_count);
75 for (size_t index = 0; index < memory_pool.size(); ++index) { 75 for (std::size_t index = 0; index < memory_pool.size(); ++index) {
76 if (mem_pool_info[index].pool_state == MemoryPoolStates::RequestAttach) { 76 if (mem_pool_info[index].pool_state == MemoryPoolStates::RequestAttach) {
77 memory_pool[index].state = MemoryPoolStates::Attached; 77 memory_pool[index].state = MemoryPoolStates::Attached;
78 } else if (mem_pool_info[index].pool_state == MemoryPoolStates::RequestDetach) { 78 } else if (mem_pool_info[index].pool_state == MemoryPoolStates::RequestDetach) {
@@ -93,7 +93,7 @@ std::vector<u8> AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_
93 response_data.memory_pools_size); 93 response_data.memory_pools_size);
94 94
95 // Copy output voice status 95 // Copy output voice status
96 size_t voice_out_status_offset{sizeof(UpdateDataHeader) + response_data.memory_pools_size}; 96 std::size_t voice_out_status_offset{sizeof(UpdateDataHeader) + response_data.memory_pools_size};
97 for (const auto& voice : voices) { 97 for (const auto& voice : voices) {
98 std::memcpy(output_params.data() + voice_out_status_offset, &voice.GetOutStatus(), 98 std::memcpy(output_params.data() + voice_out_status_offset, &voice.GetOutStatus(),
99 sizeof(VoiceOutStatus)); 99 sizeof(VoiceOutStatus));
@@ -103,12 +103,12 @@ std::vector<u8> AudioRenderer::UpdateAudioRenderer(const std::vector<u8>& input_
103 return output_params; 103 return output_params;
104} 104}
105 105
106void AudioRenderer::VoiceState::SetWaveIndex(size_t index) { 106void AudioRenderer::VoiceState::SetWaveIndex(std::size_t index) {
107 wave_index = index & 3; 107 wave_index = index & 3;
108 is_refresh_pending = true; 108 is_refresh_pending = true;
109} 109}
110 110
111std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(size_t sample_count) { 111std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(std::size_t sample_count) {
112 if (!IsPlaying()) { 112 if (!IsPlaying()) {
113 return {}; 113 return {};
114 } 114 }
@@ -117,9 +117,9 @@ std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(size_t sample_count)
117 RefreshBuffer(); 117 RefreshBuffer();
118 } 118 }
119 119
120 const size_t max_size{samples.size() - offset}; 120 const std::size_t max_size{samples.size() - offset};
121 const size_t dequeue_offset{offset}; 121 const std::size_t dequeue_offset{offset};
122 size_t size{sample_count * STREAM_NUM_CHANNELS}; 122 std::size_t size{sample_count * STREAM_NUM_CHANNELS};
123 if (size > max_size) { 123 if (size > max_size) {
124 size = max_size; 124 size = max_size;
125 } 125 }
@@ -184,7 +184,7 @@ void AudioRenderer::VoiceState::RefreshBuffer() {
184 case 1: 184 case 1:
185 // 1 channel is upsampled to 2 channel 185 // 1 channel is upsampled to 2 channel
186 samples.resize(new_samples.size() * 2); 186 samples.resize(new_samples.size() * 2);
187 for (size_t index = 0; index < new_samples.size(); ++index) { 187 for (std::size_t index = 0; index < new_samples.size(); ++index) {
188 samples[index * 2] = new_samples[index]; 188 samples[index * 2] = new_samples[index];
189 samples[index * 2 + 1] = new_samples[index]; 189 samples[index * 2 + 1] = new_samples[index];
190 } 190 }
@@ -210,7 +210,7 @@ static constexpr s16 ClampToS16(s32 value) {
210} 210}
211 211
212void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) { 212void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) {
213 constexpr size_t BUFFER_SIZE{512}; 213 constexpr std::size_t BUFFER_SIZE{512};
214 std::vector<s16> buffer(BUFFER_SIZE * stream->GetNumChannels()); 214 std::vector<s16> buffer(BUFFER_SIZE * stream->GetNumChannels());
215 215
216 for (auto& voice : voices) { 216 for (auto& voice : voices) {
@@ -218,7 +218,7 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) {
218 continue; 218 continue;
219 } 219 }
220 220
221 size_t offset{}; 221 std::size_t offset{};
222 s64 samples_remaining{BUFFER_SIZE}; 222 s64 samples_remaining{BUFFER_SIZE};
223 while (samples_remaining > 0) { 223 while (samples_remaining > 0) {
224 const std::vector<s16> samples{voice.DequeueSamples(samples_remaining)}; 224 const std::vector<s16> samples{voice.DequeueSamples(samples_remaining)};
diff --git a/src/audio_core/audio_renderer.h b/src/audio_core/audio_renderer.h
index 6d069d693..c8d2cd188 100644
--- a/src/audio_core/audio_renderer.h
+++ b/src/audio_core/audio_renderer.h
@@ -184,16 +184,16 @@ private:
184 return info; 184 return info;
185 } 185 }
186 186
187 void SetWaveIndex(size_t index); 187 void SetWaveIndex(std::size_t index);
188 std::vector<s16> DequeueSamples(size_t sample_count); 188 std::vector<s16> DequeueSamples(std::size_t sample_count);
189 void UpdateState(); 189 void UpdateState();
190 void RefreshBuffer(); 190 void RefreshBuffer();
191 191
192 private: 192 private:
193 bool is_in_use{}; 193 bool is_in_use{};
194 bool is_refresh_pending{}; 194 bool is_refresh_pending{};
195 size_t wave_index{}; 195 std::size_t wave_index{};
196 size_t offset{}; 196 std::size_t offset{};
197 Codec::ADPCMState adpcm_state{}; 197 Codec::ADPCMState adpcm_state{};
198 InterpolationState interp_state{}; 198 InterpolationState interp_state{};
199 std::vector<s16> samples; 199 std::vector<s16> samples;
diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp
index c3021403f..454de798b 100644
--- a/src/audio_core/codec.cpp
+++ b/src/audio_core/codec.cpp
@@ -8,27 +8,27 @@
8 8
9namespace AudioCore::Codec { 9namespace AudioCore::Codec {
10 10
11std::vector<s16> DecodeADPCM(const u8* const data, size_t size, const ADPCM_Coeff& coeff, 11std::vector<s16> DecodeADPCM(const u8* const data, std::size_t size, const ADPCM_Coeff& coeff,
12 ADPCMState& state) { 12 ADPCMState& state) {
13 // GC-ADPCM with scale factor and variable coefficients. 13 // GC-ADPCM with scale factor and variable coefficients.
14 // Frames are 8 bytes long containing 14 samples each. 14 // Frames are 8 bytes long containing 14 samples each.
15 // Samples are 4 bits (one nibble) long. 15 // Samples are 4 bits (one nibble) long.
16 16
17 constexpr size_t FRAME_LEN = 8; 17 constexpr std::size_t FRAME_LEN = 8;
18 constexpr size_t SAMPLES_PER_FRAME = 14; 18 constexpr std::size_t SAMPLES_PER_FRAME = 14;
19 constexpr std::array<int, 16> SIGNED_NIBBLES = { 19 constexpr std::array<int, 16> SIGNED_NIBBLES = {
20 {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}}; 20 {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}};
21 21
22 const size_t sample_count = (size / FRAME_LEN) * SAMPLES_PER_FRAME; 22 const std::size_t sample_count = (size / FRAME_LEN) * SAMPLES_PER_FRAME;
23 const size_t ret_size = 23 const std::size_t ret_size =
24 sample_count % 2 == 0 ? sample_count : sample_count + 1; // Ensure multiple of two. 24 sample_count % 2 == 0 ? sample_count : sample_count + 1; // Ensure multiple of two.
25 std::vector<s16> ret(ret_size); 25 std::vector<s16> ret(ret_size);
26 26
27 int yn1 = state.yn1, yn2 = state.yn2; 27 int yn1 = state.yn1, yn2 = state.yn2;
28 28
29 const size_t NUM_FRAMES = 29 const std::size_t NUM_FRAMES =
30 (sample_count + (SAMPLES_PER_FRAME - 1)) / SAMPLES_PER_FRAME; // Round up. 30 (sample_count + (SAMPLES_PER_FRAME - 1)) / SAMPLES_PER_FRAME; // Round up.
31 for (size_t framei = 0; framei < NUM_FRAMES; framei++) { 31 for (std::size_t framei = 0; framei < NUM_FRAMES; framei++) {
32 const int frame_header = data[framei * FRAME_LEN]; 32 const int frame_header = data[framei * FRAME_LEN];
33 const int scale = 1 << (frame_header & 0xF); 33 const int scale = 1 << (frame_header & 0xF);
34 const int idx = (frame_header >> 4) & 0x7; 34 const int idx = (frame_header >> 4) & 0x7;
@@ -53,9 +53,9 @@ std::vector<s16> DecodeADPCM(const u8* const data, size_t size, const ADPCM_Coef
53 return static_cast<s16>(val); 53 return static_cast<s16>(val);
54 }; 54 };
55 55
56 size_t outputi = framei * SAMPLES_PER_FRAME; 56 std::size_t outputi = framei * SAMPLES_PER_FRAME;
57 size_t datai = framei * FRAME_LEN + 1; 57 std::size_t datai = framei * FRAME_LEN + 1;
58 for (size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) { 58 for (std::size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) {
59 const s16 sample1 = decode_sample(SIGNED_NIBBLES[data[datai] >> 4]); 59 const s16 sample1 = decode_sample(SIGNED_NIBBLES[data[datai] >> 4]);
60 ret[outputi] = sample1; 60 ret[outputi] = sample1;
61 outputi++; 61 outputi++;
diff --git a/src/audio_core/codec.h b/src/audio_core/codec.h
index 3f845c42c..ef2ce01a8 100644
--- a/src/audio_core/codec.h
+++ b/src/audio_core/codec.h
@@ -38,7 +38,7 @@ using ADPCM_Coeff = std::array<s16, 16>;
38 * @param state ADPCM state, this is updated with new state 38 * @param state ADPCM state, this is updated with new state
39 * @return Decoded stereo signed PCM16 data, sample_count in length 39 * @return Decoded stereo signed PCM16 data, sample_count in length
40 */ 40 */
41std::vector<s16> DecodeADPCM(const u8* const data, size_t size, const ADPCM_Coeff& coeff, 41std::vector<s16> DecodeADPCM(const u8* const data, std::size_t size, const ADPCM_Coeff& coeff,
42 ADPCMState& state); 42 ADPCMState& state);
43 43
44}; // namespace AudioCore::Codec 44}; // namespace AudioCore::Codec
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp
index 79155a7a0..855d64d05 100644
--- a/src/audio_core/cubeb_sink.cpp
+++ b/src/audio_core/cubeb_sink.cpp
@@ -63,8 +63,8 @@ public:
63 // Downsample 6 channels to 2 63 // Downsample 6 channels to 2
64 std::vector<s16> buf; 64 std::vector<s16> buf;
65 buf.reserve(samples.size() * num_channels / source_num_channels); 65 buf.reserve(samples.size() * num_channels / source_num_channels);
66 for (size_t i = 0; i < samples.size(); i += source_num_channels) { 66 for (std::size_t i = 0; i < samples.size(); i += source_num_channels) {
67 for (size_t ch = 0; ch < num_channels; ch++) { 67 for (std::size_t ch = 0; ch < num_channels; ch++) {
68 buf.push_back(samples[i + ch]); 68 buf.push_back(samples[i + ch]);
69 } 69 }
70 } 70 }
@@ -75,7 +75,7 @@ public:
75 queue.Push(samples); 75 queue.Push(samples);
76 } 76 }
77 77
78 size_t SamplesInQueue(u32 num_channels) const override { 78 std::size_t SamplesInQueue(u32 num_channels) const override {
79 if (!ctx) 79 if (!ctx)
80 return 0; 80 return 0;
81 81
@@ -159,15 +159,16 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const
159 return {}; 159 return {};
160 } 160 }
161 161
162 const size_t num_channels = impl->GetNumChannels(); 162 const std::size_t num_channels = impl->GetNumChannels();
163 const size_t samples_to_write = num_channels * num_frames; 163 const std::size_t samples_to_write = num_channels * num_frames;
164 size_t samples_written; 164 std::size_t samples_written;
165 165
166 if (Settings::values.enable_audio_stretching) { 166 if (Settings::values.enable_audio_stretching) {
167 const std::vector<s16> in{impl->queue.Pop()}; 167 const std::vector<s16> in{impl->queue.Pop()};
168 const size_t num_in{in.size() / num_channels}; 168 const std::size_t num_in{in.size() / num_channels};
169 s16* const out{reinterpret_cast<s16*>(buffer)}; 169 s16* const out{reinterpret_cast<s16*>(buffer)};
170 const size_t out_frames = impl->time_stretch.Process(in.data(), num_in, out, num_frames); 170 const std::size_t out_frames =
171 impl->time_stretch.Process(in.data(), num_in, out, num_frames);
171 samples_written = out_frames * num_channels; 172 samples_written = out_frames * num_channels;
172 173
173 if (impl->should_flush) { 174 if (impl->should_flush) {
@@ -184,7 +185,7 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const
184 } 185 }
185 186
186 // Fill the rest of the frames with last_frame 187 // Fill the rest of the frames with last_frame
187 for (size_t i = samples_written; i < samples_to_write; i += num_channels) { 188 for (std::size_t i = samples_written; i < samples_to_write; i += num_channels) {
188 std::memcpy(buffer + i * sizeof(s16), &impl->last_frame[0], num_channels * sizeof(s16)); 189 std::memcpy(buffer + i * sizeof(s16), &impl->last_frame[0], num_channels * sizeof(s16));
189 } 190 }
190 191
@@ -206,7 +207,7 @@ std::vector<std::string> ListCubebSinkDevices() {
206 if (cubeb_enumerate_devices(ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection) != CUBEB_OK) { 207 if (cubeb_enumerate_devices(ctx, CUBEB_DEVICE_TYPE_OUTPUT, &collection) != CUBEB_OK) {
207 LOG_WARNING(Audio_Sink, "Audio output device enumeration not supported"); 208 LOG_WARNING(Audio_Sink, "Audio output device enumeration not supported");
208 } else { 209 } else {
209 for (size_t i = 0; i < collection.count; i++) { 210 for (std::size_t i = 0; i < collection.count; i++) {
210 const cubeb_device_info& device = collection.device[i]; 211 const cubeb_device_info& device = collection.device[i];
211 if (device.friendly_name) { 212 if (device.friendly_name) {
212 device_list.emplace_back(device.friendly_name); 213 device_list.emplace_back(device.friendly_name);
diff --git a/src/audio_core/null_sink.h b/src/audio_core/null_sink.h
index 2ed0c83b6..a78d78893 100644
--- a/src/audio_core/null_sink.h
+++ b/src/audio_core/null_sink.h
@@ -22,7 +22,7 @@ private:
22 struct NullSinkStreamImpl final : SinkStream { 22 struct NullSinkStreamImpl final : SinkStream {
23 void EnqueueSamples(u32 /*num_channels*/, const std::vector<s16>& /*samples*/) override {} 23 void EnqueueSamples(u32 /*num_channels*/, const std::vector<s16>& /*samples*/) override {}
24 24
25 size_t SamplesInQueue(u32 /*num_channels*/) const override { 25 std::size_t SamplesInQueue(u32 /*num_channels*/) const override {
26 return 0; 26 return 0;
27 } 27 }
28 28
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp
index 84dcdd98d..386f2ec66 100644
--- a/src/audio_core/stream.cpp
+++ b/src/audio_core/stream.cpp
@@ -17,7 +17,7 @@
17 17
18namespace AudioCore { 18namespace AudioCore {
19 19
20constexpr size_t MaxAudioBufferCount{32}; 20constexpr std::size_t MaxAudioBufferCount{32};
21 21
22u32 Stream::GetNumChannels() const { 22u32 Stream::GetNumChannels() const {
23 switch (format) { 23 switch (format) {
@@ -52,7 +52,7 @@ void Stream::Stop() {
52} 52}
53 53
54s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const { 54s64 Stream::GetBufferReleaseCycles(const Buffer& buffer) const {
55 const size_t num_samples{buffer.GetSamples().size() / GetNumChannels()}; 55 const std::size_t num_samples{buffer.GetSamples().size() / GetNumChannels()};
56 return CoreTiming::usToCycles((static_cast<u64>(num_samples) * 1000000) / sample_rate); 56 return CoreTiming::usToCycles((static_cast<u64>(num_samples) * 1000000) / sample_rate);
57} 57}
58 58
@@ -122,9 +122,9 @@ bool Stream::ContainsBuffer(Buffer::Tag tag) const {
122 return {}; 122 return {};
123} 123}
124 124
125std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers(size_t max_count) { 125std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers(std::size_t max_count) {
126 std::vector<Buffer::Tag> tags; 126 std::vector<Buffer::Tag> tags;
127 for (size_t count = 0; count < max_count && !released_buffers.empty(); ++count) { 127 for (std::size_t count = 0; count < max_count && !released_buffers.empty(); ++count) {
128 tags.push_back(released_buffers.front()->GetTag()); 128 tags.push_back(released_buffers.front()->GetTag());
129 released_buffers.pop(); 129 released_buffers.pop();
130 } 130 }
diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h
index 049b92ca9..3a435982d 100644
--- a/src/audio_core/stream.h
+++ b/src/audio_core/stream.h
@@ -49,7 +49,7 @@ public:
49 bool ContainsBuffer(Buffer::Tag tag) const; 49 bool ContainsBuffer(Buffer::Tag tag) const;
50 50
51 /// Returns a vector of recently released buffers specified by tag 51 /// Returns a vector of recently released buffers specified by tag
52 std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(size_t max_count); 52 std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(std::size_t max_count);
53 53
54 /// Returns true if the stream is currently playing 54 /// Returns true if the stream is currently playing
55 bool IsPlaying() const { 55 bool IsPlaying() const {
@@ -57,7 +57,7 @@ public:
57 } 57 }
58 58
59 /// Returns the number of queued buffers 59 /// Returns the number of queued buffers
60 size_t GetQueueSize() const { 60 std::size_t GetQueueSize() const {
61 return queued_buffers.size(); 61 return queued_buffers.size();
62 } 62 }
63 63
diff --git a/src/audio_core/time_stretch.cpp b/src/audio_core/time_stretch.cpp
index da094c46b..5da35e74e 100644
--- a/src/audio_core/time_stretch.cpp
+++ b/src/audio_core/time_stretch.cpp
@@ -26,7 +26,8 @@ void TimeStretcher::Flush() {
26 m_sound_touch.flush(); 26 m_sound_touch.flush();
27} 27}
28 28
29size_t TimeStretcher::Process(const s16* in, size_t num_in, s16* out, size_t num_out) { 29std::size_t TimeStretcher::Process(const s16* in, std::size_t num_in, s16* out,
30 std::size_t num_out) {
30 const double time_delta = static_cast<double>(num_out) / m_sample_rate; // seconds 31 const double time_delta = static_cast<double>(num_out) / m_sample_rate; // seconds
31 32
32 // We were given actual_samples number of samples, and num_samples were requested from us. 33 // We were given actual_samples number of samples, and num_samples were requested from us.
diff --git a/src/audio_core/time_stretch.h b/src/audio_core/time_stretch.h
index 7e39e695e..c2286fba1 100644
--- a/src/audio_core/time_stretch.h
+++ b/src/audio_core/time_stretch.h
@@ -20,7 +20,7 @@ public:
20 /// @param out Output sample buffer 20 /// @param out Output sample buffer
21 /// @param num_out Desired number of output frames in `out` 21 /// @param num_out Desired number of output frames in `out`
22 /// @returns Actual number of frames written to `out` 22 /// @returns Actual number of frames written to `out`
23 size_t Process(const s16* in, size_t num_in, s16* out, size_t num_out); 23 std::size_t Process(const s16* in, std::size_t num_in, s16* out, std::size_t num_out);
24 24
25 void Clear(); 25 void Clear();
26 26