From 700c00f021dbe7674a42971d7ca3c3916d3b6b41 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Sun, 16 Jul 2023 17:54:40 -0700 Subject: [PATCH] audio_core/hle: Stub binary requests SaveState and LoadState. (#6684) * audio_core/hle: Stub binary requests SaveState and LoadState. * audio_core/hle: Fire DSP binary pipe interrupt on request completion instead of tick. --- src/audio_core/hle/audiotoolbox_decoder.cpp | 6 +++++- src/audio_core/hle/decoder.cpp | 4 +++- src/audio_core/hle/decoder.h | 9 ++++++++- src/audio_core/hle/fdk_decoder.cpp | 6 +++++- src/audio_core/hle/ffmpeg_decoder.cpp | 6 +++++- src/audio_core/hle/hle.cpp | 6 ++++-- src/audio_core/hle/mediandk_decoder.cpp | 6 +++++- src/audio_core/hle/wmf_decoder.cpp | 6 +++++- 8 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/audio_core/hle/audiotoolbox_decoder.cpp b/src/audio_core/hle/audiotoolbox_decoder.cpp index 2b122f008..83d4a41ae 100644 --- a/src/audio_core/hle/audiotoolbox_decoder.cpp +++ b/src/audio_core/hle/audiotoolbox_decoder.cpp @@ -85,7 +85,11 @@ std::optional AudioToolboxDecoder::Impl::ProcessRequest( case DecoderCommand::EncodeDecode: { return Decode(request); } - case DecoderCommand::Unknown: { + case DecoderCommand::Shutdown: + case DecoderCommand::SaveState: + case DecoderCommand::LoadState: { + LOG_WARNING(Audio_DSP, "Got unimplemented binary request: {}", + static_cast(request.header.cmd)); BinaryMessage response = request; response.header.result = ResultStatus::Success; return response; diff --git a/src/audio_core/hle/decoder.cpp b/src/audio_core/hle/decoder.cpp index a11fc4834..872da9c16 100644 --- a/src/audio_core/hle/decoder.cpp +++ b/src/audio_core/hle/decoder.cpp @@ -42,7 +42,9 @@ std::optional NullDecoder::ProcessRequest(const BinaryMessage& re BinaryMessage response{}; switch (request.header.cmd) { case DecoderCommand::Init: - case DecoderCommand::Unknown: + case DecoderCommand::Shutdown: + case DecoderCommand::SaveState: + case DecoderCommand::LoadState: response = request; response.header.result = ResultStatus::Success; return response; diff --git a/src/audio_core/hle/decoder.h b/src/audio_core/hle/decoder.h index 69bdaba89..d3cc910e8 100644 --- a/src/audio_core/hle/decoder.h +++ b/src/audio_core/hle/decoder.h @@ -14,9 +14,16 @@ namespace AudioCore::HLE { enum class DecoderCommand : u16 { + /// Initializes the decoder. Init = 0, + /// Decodes/encodes a data frame. EncodeDecode = 1, - Unknown = 2, // Probably UnInit + /// Shuts down the decoder. + Shutdown = 2, + /// Loads the saved decoder state. Used for DSP wake. + LoadState = 3, + /// Saves the decoder state. Used for DSP sleep. + SaveState = 4, }; enum class DecoderCodec : u16 { diff --git a/src/audio_core/hle/fdk_decoder.cpp b/src/audio_core/hle/fdk_decoder.cpp index 0de539085..a29d659b7 100644 --- a/src/audio_core/hle/fdk_decoder.cpp +++ b/src/audio_core/hle/fdk_decoder.cpp @@ -111,7 +111,11 @@ std::optional FDKDecoder::Impl::ProcessRequest(const BinaryMessag case DecoderCommand::EncodeDecode: { return Decode(request); } - case DecoderCommand::Unknown: { + case DecoderCommand::Shutdown: + case DecoderCommand::SaveState: + case DecoderCommand::LoadState: { + LOG_WARNING(Audio_DSP, "Got unimplemented binary request: {}", + static_cast(request.header.cmd)); BinaryMessage response = request; response.header.result = ResultStatus::Success; return response; diff --git a/src/audio_core/hle/ffmpeg_decoder.cpp b/src/audio_core/hle/ffmpeg_decoder.cpp index d291343ca..58dbfb3e9 100644 --- a/src/audio_core/hle/ffmpeg_decoder.cpp +++ b/src/audio_core/hle/ffmpeg_decoder.cpp @@ -80,7 +80,11 @@ std::optional FFMPEGDecoder::Impl::ProcessRequest(const BinaryMes case DecoderCommand::EncodeDecode: { return Decode(request); } - case DecoderCommand::Unknown: { + case DecoderCommand::Shutdown: + case DecoderCommand::SaveState: + case DecoderCommand::LoadState: { + LOG_WARNING(Audio_DSP, "Got unimplemented binary request: {}", + static_cast(request.header.cmd)); BinaryMessage response = request; response.header.result = ResultStatus::Success; return response; diff --git a/src/audio_core/hle/hle.cpp b/src/audio_core/hle/hle.cpp index 78551a7f7..38632d252 100644 --- a/src/audio_core/hle/hle.cpp +++ b/src/audio_core/hle/hle.cpp @@ -319,6 +319,10 @@ void DspHle::Impl::PipeWrite(DspPipe pipe_number, std::span buffer) { pipe_data[static_cast(pipe_number)].resize(sizeof(value)); std::memcpy(pipe_data[static_cast(pipe_number)].data(), &value, sizeof(value)); } + auto dsp = dsp_dsp.lock(); + if (dsp) { + dsp->SignalInterrupt(InterruptType::Pipe, DspPipe::Binary); + } break; } default: @@ -461,8 +465,6 @@ void DspHle::Impl::AudioTickCallback(s64 cycles_late) { // TODO(merry): Signal all the other interrupts as appropriate. if (auto service = dsp_dsp.lock()) { service->SignalInterrupt(InterruptType::Pipe, DspPipe::Audio); - // HACK(merry): Added to prevent regressions. Will remove soon. - service->SignalInterrupt(InterruptType::Pipe, DspPipe::Binary); } } diff --git a/src/audio_core/hle/mediandk_decoder.cpp b/src/audio_core/hle/mediandk_decoder.cpp index 4dc3154dc..7c63b3f75 100644 --- a/src/audio_core/hle/mediandk_decoder.cpp +++ b/src/audio_core/hle/mediandk_decoder.cpp @@ -110,7 +110,11 @@ std::optional MediaNDKDecoder::Impl::ProcessRequest(const BinaryM case DecoderCommand::EncodeDecode: { return Decode(request); } - case DecoderCommand::Unknown: { + case DecoderCommand::Shutdown: + case DecoderCommand::SaveState: + case DecoderCommand::LoadState: { + LOG_WARNING(Audio_DSP, "Got unimplemented binary request: {}", + static_cast(request.header.cmd)); BinaryMessage response = request; response.header.result = ResultStatus::Success; return response; diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index dca0428fe..e49f86eb0 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -115,7 +115,11 @@ std::optional WMFDecoder::Impl::ProcessRequest(const BinaryMessag case DecoderCommand::EncodeDecode: { return Decode(request); } - case DecoderCommand::Unknown: { + case DecoderCommand::Shutdown: + case DecoderCommand::SaveState: + case DecoderCommand::LoadState: { + LOG_WARNING(Audio_DSP, "Got unimplemented binary request: {}", + static_cast(request.header.cmd)); BinaryMessage response = request; response.header.result = ResultStatus::Success; return response;