summaryrefslogtreecommitdiff
path: root/src/audio_core
diff options
context:
space:
mode:
authorGravatar bunnei2016-05-07 17:24:16 -0400
committerGravatar bunnei2016-05-07 17:24:16 -0400
commit6abc6003f50cbaec555516bbaf8fce5bbecb2ff1 (patch)
tree18ae5ec147f016b62e73d1de683d453c50407034 /src/audio_core
parentMerge pull request #1761 from Subv/applets_fb (diff)
parentfixup simple type conversions where possible (diff)
downloadyuzu-6abc6003f50cbaec555516bbaf8fce5bbecb2ff1.tar.gz
yuzu-6abc6003f50cbaec555516bbaf8fce5bbecb2ff1.tar.xz
yuzu-6abc6003f50cbaec555516bbaf8fce5bbecb2ff1.zip
Merge pull request #1718 from alex-laties/fixup-type-conversions
fixup simple type conversions where possible
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/hle/pipe.cpp9
-rw-r--r--src/audio_core/hle/pipe.h12
2 files changed, 15 insertions, 6 deletions
diff --git a/src/audio_core/hle/pipe.cpp b/src/audio_core/hle/pipe.cpp
index 03280780f..44dff1345 100644
--- a/src/audio_core/hle/pipe.cpp
+++ b/src/audio_core/hle/pipe.cpp
@@ -36,12 +36,17 @@ std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) {
36 return {}; 36 return {};
37 } 37 }
38 38
39 if (length > UINT16_MAX) { // Can only read at most UINT16_MAX from the pipe
40 LOG_ERROR(Audio_DSP, "length of %u greater than max of %u", length, UINT16_MAX);
41 return {};
42 }
43
39 std::vector<u8>& data = pipe_data[pipe_index]; 44 std::vector<u8>& data = pipe_data[pipe_index];
40 45
41 if (length > data.size()) { 46 if (length > data.size()) {
42 LOG_WARNING(Audio_DSP, "pipe_number = %zu is out of data, application requested read of %u but %zu remain", 47 LOG_WARNING(Audio_DSP, "pipe_number = %zu is out of data, application requested read of %u but %zu remain",
43 pipe_index, length, data.size()); 48 pipe_index, length, data.size());
44 length = data.size(); 49 length = static_cast<u32>(data.size());
45 } 50 }
46 51
47 if (length == 0) 52 if (length == 0)
@@ -94,7 +99,7 @@ static void AudioPipeWriteStructAddresses() {
94 }; 99 };
95 100
96 // Begin with a u16 denoting the number of structs. 101 // Begin with a u16 denoting the number of structs.
97 WriteU16(DspPipe::Audio, struct_addresses.size()); 102 WriteU16(DspPipe::Audio, static_cast<u16>(struct_addresses.size()));
98 // Then write the struct addresses. 103 // Then write the struct addresses.
99 for (u16 addr : struct_addresses) { 104 for (u16 addr : struct_addresses) {
100 WriteU16(DspPipe::Audio, addr); 105 WriteU16(DspPipe::Audio, addr);
diff --git a/src/audio_core/hle/pipe.h b/src/audio_core/hle/pipe.h
index 64d97f8ba..b714c0496 100644
--- a/src/audio_core/hle/pipe.h
+++ b/src/audio_core/hle/pipe.h
@@ -24,10 +24,14 @@ enum class DspPipe {
24constexpr size_t NUM_DSP_PIPE = 8; 24constexpr size_t NUM_DSP_PIPE = 8;
25 25
26/** 26/**
27 * Read a DSP pipe. 27 * Reads `length` bytes from the DSP pipe identified with `pipe_number`.
28 * @param pipe_number The Pipe ID 28 * @note Can read up to the maximum value of a u16 in bytes (65,535).
29 * @param length How much data to request. 29 * @note IF an error is encoutered with either an invalid `pipe_number` or `length` value, an empty vector will be returned.
30 * @return The data read from the pipe. The size of this vector can be less than the length requested. 30 * @note IF `length` is set to 0, an empty vector will be returned.
31 * @note IF `length` is greater than the amount of data available, this function will only read the available amount.
32 * @param pipe_number a `DspPipe`
33 * @param length the number of bytes to read. The max is 65,535 (max of u16).
34 * @returns a vector of bytes from the specified pipe. On error, will be empty.
31 */ 35 */
32std::vector<u8> PipeRead(DspPipe pipe_number, u32 length); 36std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);
33 37