diff options
| author | 2016-04-24 09:12:15 +0100 | |
|---|---|---|
| committer | 2016-04-25 07:50:53 +0100 | |
| commit | 555907ce8dc842ef0859537a0c25443a5e9527bb (patch) | |
| tree | ae607e6947de12a92cbaccc6492094e6aaa2ff32 /src/audio_core | |
| parent | DSP_DSP: Remove unused variable (diff) | |
| download | yuzu-555907ce8dc842ef0859537a0c25443a5e9527bb.tar.gz yuzu-555907ce8dc842ef0859537a0c25443a5e9527bb.tar.xz yuzu-555907ce8dc842ef0859537a0c25443a5e9527bb.zip | |
DSP/Pipe: There are 8 pipes
Diffstat (limited to 'src/audio_core')
| -rw-r--r-- | src/audio_core/hle/pipe.cpp | 28 | ||||
| -rw-r--r-- | src/audio_core/hle/pipe.h | 4 |
2 files changed, 19 insertions, 13 deletions
diff --git a/src/audio_core/hle/pipe.cpp b/src/audio_core/hle/pipe.cpp index 9381883b4..7ec97dfda 100644 --- a/src/audio_core/hle/pipe.cpp +++ b/src/audio_core/hle/pipe.cpp | |||
| @@ -17,7 +17,7 @@ namespace HLE { | |||
| 17 | 17 | ||
| 18 | static DspState dsp_state = DspState::Off; | 18 | static DspState dsp_state = DspState::Off; |
| 19 | 19 | ||
| 20 | static std::array<std::vector<u8>, static_cast<size_t>(DspPipe::DspPipe_MAX)> pipe_data; | 20 | static std::array<std::vector<u8>, NUM_DSP_PIPE> pipe_data; |
| 21 | 21 | ||
| 22 | void ResetPipes() { | 22 | void ResetPipes() { |
| 23 | for (auto& data : pipe_data) { | 23 | for (auto& data : pipe_data) { |
| @@ -27,16 +27,18 @@ void ResetPipes() { | |||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) { | 29 | std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) { |
| 30 | if (pipe_number >= DspPipe::DspPipe_MAX) { | 30 | const size_t pipe_index = static_cast<size_t>(pipe_number); |
| 31 | LOG_ERROR(Audio_DSP, "pipe_number = %u invalid", pipe_number); | 31 | |
| 32 | if (pipe_index >= NUM_DSP_PIPE) { | ||
| 33 | LOG_ERROR(Audio_DSP, "pipe_number = %zu invalid", pipe_index); | ||
| 32 | return {}; | 34 | return {}; |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | std::vector<u8>& data = pipe_data[static_cast<size_t>(pipe_number)]; | 37 | std::vector<u8>& data = pipe_data[pipe_index]; |
| 36 | 38 | ||
| 37 | if (length > data.size()) { | 39 | if (length > data.size()) { |
| 38 | LOG_WARNING(Audio_DSP, "pipe_number = %u is out of data, application requested read of %u but %zu remain", | 40 | LOG_WARNING(Audio_DSP, "pipe_number = %zu is out of data, application requested read of %u but %zu remain", |
| 39 | pipe_number, length, data.size()); | 41 | pipe_index, length, data.size()); |
| 40 | length = data.size(); | 42 | length = data.size(); |
| 41 | } | 43 | } |
| 42 | 44 | ||
| @@ -49,16 +51,20 @@ std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) { | |||
| 49 | } | 51 | } |
| 50 | 52 | ||
| 51 | size_t GetPipeReadableSize(DspPipe pipe_number) { | 53 | size_t GetPipeReadableSize(DspPipe pipe_number) { |
| 52 | if (pipe_number >= DspPipe::DspPipe_MAX) { | 54 | const size_t pipe_index = static_cast<size_t>(pipe_number); |
| 53 | LOG_ERROR(Audio_DSP, "pipe_number = %u invalid", pipe_number); | 55 | |
| 56 | if (pipe_index >= NUM_DSP_PIPE) { | ||
| 57 | LOG_ERROR(Audio_DSP, "pipe_number = %zu invalid", pipe_index); | ||
| 54 | return 0; | 58 | return 0; |
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | return pipe_data[static_cast<size_t>(pipe_number)].size(); | 61 | return pipe_data[pipe_index].size(); |
| 58 | } | 62 | } |
| 59 | 63 | ||
| 60 | static void WriteU16(DspPipe pipe_number, u16 value) { | 64 | static void WriteU16(DspPipe pipe_number, u16 value) { |
| 61 | std::vector<u8>& data = pipe_data[static_cast<size_t>(pipe_number)]; | 65 | const size_t pipe_index = static_cast<size_t>(pipe_number); |
| 66 | |||
| 67 | std::vector<u8>& data = pipe_data.at(pipe_index); | ||
| 62 | // Little endian | 68 | // Little endian |
| 63 | data.emplace_back(value & 0xFF); | 69 | data.emplace_back(value & 0xFF); |
| 64 | data.emplace_back(value >> 8); | 70 | data.emplace_back(value >> 8); |
| @@ -145,7 +151,7 @@ void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) { | |||
| 145 | return; | 151 | return; |
| 146 | } | 152 | } |
| 147 | default: | 153 | default: |
| 148 | LOG_CRITICAL(Audio_DSP, "pipe_number = %u unimplemented", pipe_number); | 154 | LOG_CRITICAL(Audio_DSP, "pipe_number = %zu unimplemented", static_cast<size_t>(pipe_number)); |
| 149 | UNIMPLEMENTED(); | 155 | UNIMPLEMENTED(); |
| 150 | return; | 156 | return; |
| 151 | } | 157 | } |
diff --git a/src/audio_core/hle/pipe.h b/src/audio_core/hle/pipe.h index 382d35e87..64d97f8ba 100644 --- a/src/audio_core/hle/pipe.h +++ b/src/audio_core/hle/pipe.h | |||
| @@ -19,9 +19,9 @@ enum class DspPipe { | |||
| 19 | Debug = 0, | 19 | Debug = 0, |
| 20 | Dma = 1, | 20 | Dma = 1, |
| 21 | Audio = 2, | 21 | Audio = 2, |
| 22 | Binary = 3, | 22 | Binary = 3 |
| 23 | DspPipe_MAX | ||
| 24 | }; | 23 | }; |
| 24 | constexpr size_t NUM_DSP_PIPE = 8; | ||
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | * Read a DSP pipe. | 27 | * Read a DSP pipe. |