diff options
Diffstat (limited to 'src/audio_core/hle/pipe.cpp')
| -rw-r--r-- | src/audio_core/hle/pipe.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/audio_core/hle/pipe.cpp b/src/audio_core/hle/pipe.cpp index 9381883b4..03280780f 100644 --- a/src/audio_core/hle/pipe.cpp +++ b/src/audio_core/hle/pipe.cpp | |||
| @@ -12,12 +12,14 @@ | |||
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | 14 | ||
| 15 | #include "core/hle/service/dsp_dsp.h" | ||
| 16 | |||
| 15 | namespace DSP { | 17 | namespace DSP { |
| 16 | namespace HLE { | 18 | namespace HLE { |
| 17 | 19 | ||
| 18 | static DspState dsp_state = DspState::Off; | 20 | static DspState dsp_state = DspState::Off; |
| 19 | 21 | ||
| 20 | static std::array<std::vector<u8>, static_cast<size_t>(DspPipe::DspPipe_MAX)> pipe_data; | 22 | static std::array<std::vector<u8>, NUM_DSP_PIPE> pipe_data; |
| 21 | 23 | ||
| 22 | void ResetPipes() { | 24 | void ResetPipes() { |
| 23 | for (auto& data : pipe_data) { | 25 | for (auto& data : pipe_data) { |
| @@ -27,16 +29,18 @@ void ResetPipes() { | |||
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) { | 31 | std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) { |
| 30 | if (pipe_number >= DspPipe::DspPipe_MAX) { | 32 | const size_t pipe_index = static_cast<size_t>(pipe_number); |
| 31 | LOG_ERROR(Audio_DSP, "pipe_number = %u invalid", pipe_number); | 33 | |
| 34 | if (pipe_index >= NUM_DSP_PIPE) { | ||
| 35 | LOG_ERROR(Audio_DSP, "pipe_number = %zu invalid", pipe_index); | ||
| 32 | return {}; | 36 | return {}; |
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | std::vector<u8>& data = pipe_data[static_cast<size_t>(pipe_number)]; | 39 | std::vector<u8>& data = pipe_data[pipe_index]; |
| 36 | 40 | ||
| 37 | if (length > data.size()) { | 41 | if (length > data.size()) { |
| 38 | LOG_WARNING(Audio_DSP, "pipe_number = %u is out of data, application requested read of %u but %zu remain", | 42 | 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()); | 43 | pipe_index, length, data.size()); |
| 40 | length = data.size(); | 44 | length = data.size(); |
| 41 | } | 45 | } |
| 42 | 46 | ||
| @@ -49,16 +53,20 @@ std::vector<u8> PipeRead(DspPipe pipe_number, u32 length) { | |||
| 49 | } | 53 | } |
| 50 | 54 | ||
| 51 | size_t GetPipeReadableSize(DspPipe pipe_number) { | 55 | size_t GetPipeReadableSize(DspPipe pipe_number) { |
| 52 | if (pipe_number >= DspPipe::DspPipe_MAX) { | 56 | const size_t pipe_index = static_cast<size_t>(pipe_number); |
| 53 | LOG_ERROR(Audio_DSP, "pipe_number = %u invalid", pipe_number); | 57 | |
| 58 | if (pipe_index >= NUM_DSP_PIPE) { | ||
| 59 | LOG_ERROR(Audio_DSP, "pipe_number = %zu invalid", pipe_index); | ||
| 54 | return 0; | 60 | return 0; |
| 55 | } | 61 | } |
| 56 | 62 | ||
| 57 | return pipe_data[static_cast<size_t>(pipe_number)].size(); | 63 | return pipe_data[pipe_index].size(); |
| 58 | } | 64 | } |
| 59 | 65 | ||
| 60 | static void WriteU16(DspPipe pipe_number, u16 value) { | 66 | static void WriteU16(DspPipe pipe_number, u16 value) { |
| 61 | std::vector<u8>& data = pipe_data[static_cast<size_t>(pipe_number)]; | 67 | const size_t pipe_index = static_cast<size_t>(pipe_number); |
| 68 | |||
| 69 | std::vector<u8>& data = pipe_data.at(pipe_index); | ||
| 62 | // Little endian | 70 | // Little endian |
| 63 | data.emplace_back(value & 0xFF); | 71 | data.emplace_back(value & 0xFF); |
| 64 | data.emplace_back(value >> 8); | 72 | data.emplace_back(value >> 8); |
| @@ -91,6 +99,8 @@ static void AudioPipeWriteStructAddresses() { | |||
| 91 | for (u16 addr : struct_addresses) { | 99 | for (u16 addr : struct_addresses) { |
| 92 | WriteU16(DspPipe::Audio, addr); | 100 | WriteU16(DspPipe::Audio, addr); |
| 93 | } | 101 | } |
| 102 | // Signal that we have data on this pipe. | ||
| 103 | DSP_DSP::SignalPipeInterrupt(DspPipe::Audio); | ||
| 94 | } | 104 | } |
| 95 | 105 | ||
| 96 | void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) { | 106 | void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) { |
| @@ -145,7 +155,7 @@ void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer) { | |||
| 145 | return; | 155 | return; |
| 146 | } | 156 | } |
| 147 | default: | 157 | default: |
| 148 | LOG_CRITICAL(Audio_DSP, "pipe_number = %u unimplemented", pipe_number); | 158 | LOG_CRITICAL(Audio_DSP, "pipe_number = %zu unimplemented", static_cast<size_t>(pipe_number)); |
| 149 | UNIMPLEMENTED(); | 159 | UNIMPLEMENTED(); |
| 150 | return; | 160 | return; |
| 151 | } | 161 | } |