summaryrefslogtreecommitdiffstats
path: root/src/audio_core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/hle')
-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) {
return {};
}
+ if (length > UINT16_MAX) { // Can only read at most UINT16_MAX from the pipe
+ LOG_ERROR(Audio_DSP, "length of %u greater than max of %u", length, UINT16_MAX);
+ return {};
+ }
+
std::vector<u8>& data = pipe_data[pipe_index];
if (length > data.size()) {
LOG_WARNING(Audio_DSP, "pipe_number = %zu is out of data, application requested read of %u but %zu remain",
pipe_index, length, data.size());
- length = data.size();
+ length = static_cast<u32>(data.size());
}
if (length == 0)
@@ -94,7 +99,7 @@ static void AudioPipeWriteStructAddresses() {
};
// Begin with a u16 denoting the number of structs.
- WriteU16(DspPipe::Audio, struct_addresses.size());
+ WriteU16(DspPipe::Audio, static_cast<u16>(struct_addresses.size()));
// Then write the struct addresses.
for (u16 addr : struct_addresses) {
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 {
constexpr size_t NUM_DSP_PIPE = 8;
/**
- * Read a DSP pipe.
- * @param pipe_number The Pipe ID
- * @param length How much data to request.
- * @return The data read from the pipe. The size of this vector can be less than the length requested.
+ * Reads `length` bytes from the DSP pipe identified with `pipe_number`.
+ * @note Can read up to the maximum value of a u16 in bytes (65,535).
+ * @note IF an error is encoutered with either an invalid `pipe_number` or `length` value, an empty vector will be returned.
+ * @note IF `length` is set to 0, an empty vector will be returned.
+ * @note IF `length` is greater than the amount of data available, this function will only read the available amount.
+ * @param pipe_number a `DspPipe`
+ * @param length the number of bytes to read. The max is 65,535 (max of u16).
+ * @returns a vector of bytes from the specified pipe. On error, will be empty.
*/
std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);