summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-01-30 00:21:17 +0100
committerLioncash <mathew1800@gmail.com>2019-01-30 17:35:41 +0100
commita897feb21e603a7844c44a8ef5e00ce42ab96b43 (patch)
treef6023e5bd1d03840c9274ab1577aa282adec3d83
parenthwopus: Deduplicate the decoding code within DecodeInterleavedOld and DecodeInterleavedWithPerfOld (diff)
downloadyuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.tar
yuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.tar.gz
yuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.tar.bz2
yuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.tar.lz
yuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.tar.xz
yuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.tar.zst
yuzu-a897feb21e603a7844c44a8ef5e00ce42ab96b43.zip
-rw-r--r--src/core/hle/service/audio/hwopus.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index dffb890d5..11eba4a12 100644
--- a/src/core/hle/service/audio/hwopus.cpp
+++ b/src/core/hle/service/audio/hwopus.cpp
@@ -37,7 +37,7 @@ public:
{3, nullptr, "SetContextForMultiStream"},
{4, &IHardwareOpusDecoderManager::DecodeInterleavedWithPerfOld, "DecodeInterleavedWithPerfOld"},
{5, nullptr, "DecodeInterleavedForMultiStreamWithPerfOld"},
- {6, nullptr, "DecodeInterleaved"},
+ {6, &IHardwareOpusDecoderManager::DecodeInterleaved, "DecodeInterleaved"},
{7, nullptr, "DecodeInterleavedForMultiStream"},
};
// clang-format on
@@ -46,24 +46,49 @@ public:
}
private:
+ /// Describes extra behavior that may be asked of the decoding context.
+ enum class ExtraBehavior {
+ /// No extra behavior.
+ None,
+
+ /// Resets the decoder context back to a freshly initialized state.
+ ResetContext,
+ };
+
void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Audio, "called");
- DecodeInterleavedHelper(ctx, nullptr);
+ DecodeInterleavedHelper(ctx, nullptr, ExtraBehavior::None);
}
void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Audio, "called");
u64 performance = 0;
- DecodeInterleavedHelper(ctx, &performance);
+ DecodeInterleavedHelper(ctx, &performance, ExtraBehavior::None);
+ }
+
+ void DecodeInterleaved(Kernel::HLERequestContext& ctx) {
+ LOG_DEBUG(Audio, "called");
+
+ IPC::RequestParser rp{ctx};
+ const auto extra_behavior =
+ rp.Pop<bool>() ? ExtraBehavior::ResetContext : ExtraBehavior::None;
+
+ u64 performance = 0;
+ DecodeInterleavedHelper(ctx, &performance, extra_behavior);
}
- void DecodeInterleavedHelper(Kernel::HLERequestContext& ctx, u64* performance) {
+ void DecodeInterleavedHelper(Kernel::HLERequestContext& ctx, u64* performance,
+ ExtraBehavior extra_behavior) {
u32 consumed = 0;
u32 sample_count = 0;
std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16));
+ if (extra_behavior == ExtraBehavior::ResetContext) {
+ ResetDecoderContext();
+ }
+
if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples,
performance)) {
LOG_ERROR(Audio, "Failed to decode opus data");
@@ -136,6 +161,12 @@ private:
return true;
}
+ void ResetDecoderContext() {
+ ASSERT(decoder != nullptr);
+
+ opus_decoder_ctl(decoder.get(), OPUS_RESET_STATE);
+ }
+
struct OpusHeader {
u32_be sz; // Needs to be BE for some odd reason
INSERT_PADDING_WORDS(1);