summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/audio
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-10-15 20:49:45 +0200
committerLioncash <mathew1800@gmail.com>2020-10-18 01:50:39 +0200
commitbe1954e04cb5a0c3a526f78ed5490a5e65310280 (patch)
tree267db7ae4be88dbbc288fa605e35d4a2a13839f6 /src/core/hle/service/audio
parentMerge pull request #4787 from lioncash/conversion (diff)
downloadyuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar
yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.gz
yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.bz2
yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.lz
yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.xz
yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.zst
yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.zip
Diffstat (limited to 'src/core/hle/service/audio')
-rw-r--r--src/core/hle/service/audio/audout_u.cpp7
-rw-r--r--src/core/hle/service/audio/hwopus.cpp29
2 files changed, 19 insertions, 17 deletions
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 9b4910e53..a345a68e6 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -69,9 +69,10 @@ public:
buffer_event =
Kernel::WritableEvent::CreateEventPair(system.Kernel(), "IAudioOutBufferReleased");
- stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate,
- audio_params.channel_count, std::move(unique_name),
- [this] { buffer_event.writable->Signal(); });
+ stream =
+ audio_core.OpenStream(system.CoreTiming(), static_cast<u32>(audio_params.sample_rate),
+ audio_params.channel_count, std::move(unique_name),
+ [this] { buffer_event.writable->Signal(); });
}
private:
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index f1d81602c..16a6deb7e 100644
--- a/src/core/hle/service/audio/hwopus.cpp
+++ b/src/core/hle/service/audio/hwopus.cpp
@@ -50,8 +50,8 @@ public:
Enabled,
};
- explicit OpusDecoderState(OpusDecoderPtr decoder, u32 sample_rate, u32 channel_count)
- : decoder{std::move(decoder)}, sample_rate{sample_rate}, channel_count{channel_count} {}
+ explicit OpusDecoderState(OpusDecoderPtr decoder_, s32 sample_rate_, u32 channel_count_)
+ : decoder{std::move(decoder_)}, sample_rate{sample_rate_}, channel_count{channel_count_} {}
// Decodes interleaved Opus packets. Optionally allows reporting time taken to
// perform the decoding, as well as any relevant extra behavior.
@@ -113,15 +113,16 @@ private:
return false;
}
- const auto frame = input.data() + sizeof(OpusPacketHeader);
+ const auto* const frame = input.data() + sizeof(OpusPacketHeader);
const auto decoded_sample_count = opus_packet_get_nb_samples(
- frame, static_cast<opus_int32>(input.size() - sizeof(OpusPacketHeader)),
- static_cast<opus_int32>(sample_rate));
- if (decoded_sample_count * channel_count * sizeof(u16) > raw_output_sz) {
+ frame, static_cast<opus_int32>(input.size() - sizeof(OpusPacketHeader)), sample_rate);
+ const auto decoded_size =
+ static_cast<u32>(decoded_sample_count) * channel_count * sizeof(u16);
+ if (decoded_size > raw_output_sz) {
LOG_ERROR(
Audio,
"Decoded data does not fit into the output data, decoded_sz={}, raw_output_sz={}",
- decoded_sample_count * channel_count * sizeof(u16), raw_output_sz);
+ decoded_size, raw_output_sz);
return false;
}
@@ -137,11 +138,11 @@ private:
}
const auto end_time = std::chrono::high_resolution_clock::now() - start_time;
- sample_count = out_sample_count;
+ sample_count = static_cast<u32>(out_sample_count);
consumed = static_cast<u32>(sizeof(OpusPacketHeader) + hdr.size);
if (out_performance_time != nullptr) {
- *out_performance_time =
- std::chrono::duration_cast<std::chrono::milliseconds>(end_time).count();
+ *out_performance_time = static_cast<u64>(
+ std::chrono::duration_cast<std::chrono::milliseconds>(end_time).count());
}
return true;
@@ -154,7 +155,7 @@ private:
}
OpusDecoderPtr decoder;
- u32 sample_rate;
+ s32 sample_rate;
u32 channel_count;
};
@@ -212,7 +213,7 @@ std::size_t WorkerBufferSize(u32 channel_count) {
ASSERT_MSG(channel_count == 1 || channel_count == 2, "Invalid channel count");
constexpr int num_streams = 1;
const int num_stereo_streams = channel_count == 2 ? 1 : 0;
- return opus_multistream_decoder_get_size(num_streams, num_stereo_streams);
+ return static_cast<size_t>(opus_multistream_decoder_get_size(num_streams, num_stereo_streams));
}
// Creates the mapping table that maps the input channels to the particular
@@ -244,7 +245,7 @@ void HwOpus::GetWorkBufferSize(Kernel::HLERequestContext& ctx) {
"Invalid sample rate");
ASSERT_MSG(channel_count == 1 || channel_count == 2, "Invalid channel count");
- const u32 worker_buffer_sz = static_cast<u32>(WorkerBufferSize(channel_count));
+ const auto worker_buffer_sz = static_cast<u32>(WorkerBufferSize(channel_count));
LOG_DEBUG(Audio, "worker_buffer_sz={}", worker_buffer_sz);
IPC::ResponseBuilder rb{ctx, 3};
@@ -254,7 +255,7 @@ void HwOpus::GetWorkBufferSize(Kernel::HLERequestContext& ctx) {
void HwOpus::OpenOpusDecoder(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
- const auto sample_rate = rp.Pop<u32>();
+ const auto sample_rate = rp.Pop<s32>();
const auto channel_count = rp.Pop<u32>();
const auto buffer_sz = rp.Pop<u32>();