From 6281660844255f9680a04bdaacd5b9753764bb06 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 9 Feb 2019 11:59:00 -0700 Subject: [PATCH 1/6] audio_core: hle: mf: address yet another batch of reviews --- src/audio_core/hle/adts.h | 2 +- src/audio_core/hle/adts_reader.cpp | 2 +- src/audio_core/hle/wmf_decoder.cpp | 22 +++++++++-------- src/audio_core/hle/wmf_decoder_utils.cpp | 30 +++++++++++++----------- src/audio_core/hle/wmf_decoder_utils.h | 14 ++++++++--- 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/audio_core/hle/adts.h b/src/audio_core/hle/adts.h index 11c736986..9aba09fc3 100644 --- a/src/audio_core/hle/adts.h +++ b/src/audio_core/hle/adts.h @@ -20,4 +20,4 @@ ADTSData ParseADTS(const char* buffer); // last two bytes of MF AAC decoder user data // see https://docs.microsoft.com/en-us/windows/desktop/medfound/aac-decoder#example-media-types -u16 MFGetAACTag(const ADTSData input); +u16 MFGetAACTag(const ADTSData& input); diff --git a/src/audio_core/hle/adts_reader.cpp b/src/audio_core/hle/adts_reader.cpp index 93118f887..e70c32a3b 100644 --- a/src/audio_core/hle/adts_reader.cpp +++ b/src/audio_core/hle/adts_reader.cpp @@ -50,7 +50,7 @@ ADTSData ParseADTS(const char* buffer) { // Frame length flag (1 bit) // Depends on core coder (1 bit) // Extension flag (1 bit) -u16 MFGetAACTag(const ADTSData input) { +u16 MFGetAACTag(const ADTSData& input) { u16 tag = 0; tag |= input.profile << 11; diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index 3b4087bf7..44a250c33 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -22,7 +22,7 @@ private: MFOutputState DecodingLoop(ADTSData adts_header, std::array, 2>& out_streams); - bool initalized = false; + bool initialized = false; bool selected = false; Memory::MemorySystem& memory; @@ -36,7 +36,9 @@ WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) { MFCoInit(); } -WMFDecoder::Impl::~Impl() = default; +WMFDecoder::Impl::~Impl() { + Clear(); +} std::optional WMFDecoder::Impl::ProcessRequest(const BinaryRequest& request) { if (request.codec != DecoderCodec::AAC) { @@ -65,7 +67,7 @@ std::optional WMFDecoder::Impl::ProcessRequest(const BinaryReque } std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& request) { - if (initalized) { + if (initialized) { Clear(); } @@ -89,16 +91,16 @@ std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& r return response; } - initalized = true; + initialized = true; return response; } void WMFDecoder::Impl::Clear() { - if (initalized) { + if (initialized) { MFFlush(transform.get()); - MFDeInit(transform.get()); + MFDestroy(); } - initalized = false; + initialized = false; selected = false; } @@ -117,7 +119,7 @@ MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header, // the following was taken from ffmpeg version of the decoder f32 val_f32; - for (size_t i = 0; i < output_buffer->size();) { + for (std::size_t i = 0; i < output_buffer->size();) { for (std::size_t channel = 0; channel < adts_header.channels; channel++) { val_f32 = output_buffer->at(i); s16 val = static_cast(0x7FFF * val_f32); @@ -161,8 +163,8 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ response.num_channels = 2; response.num_samples = 1024; - if (!initalized) { - LOG_DEBUG(Audio_DSP, "Decoder not initalized"); + if (!initialized) { + LOG_DEBUG(Audio_DSP, "Decoder not initialized"); // This is a hack to continue games when decoder failed to initialize return response; } diff --git a/src/audio_core/hle/wmf_decoder_utils.cpp b/src/audio_core/hle/wmf_decoder_utils.cpp index c0c9c5744..7dec97abf 100644 --- a/src/audio_core/hle/wmf_decoder_utils.cpp +++ b/src/audio_core/hle/wmf_decoder_utils.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #include "common/logging/log.h" +#include "common/string_util.h" #include "wmf_decoder_utils.h" // utility functions @@ -9,16 +10,17 @@ void ReportError(std::string msg, HRESULT hr) { if (SUCCEEDED(hr)) { return; } - LPSTR err; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, hr, - // hardcode to use en_US because if any user had problems with this - // we can help them w/o translating anything - // default is to use the language currently active on the operating system - MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPSTR)&err, 0, nullptr); + LPWSTR err; + FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, hr, + // hardcode to use en_US because if any user had problems with this + // we can help them w/o translating anything + // default is to use the language currently active on the operating system + MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPWSTR)&err, 0, nullptr); if (err != nullptr) { - LOG_CRITICAL(Audio_DSP, "{}: {}", msg, err); + LOG_CRITICAL(Audio_DSP, "{}: {}", msg, Common::UTF16ToUTF8(err)); + LocalFree(err); } LOG_CRITICAL(Audio_DSP, "{}: {:08x}", msg, hr); } @@ -82,8 +84,8 @@ unique_mfptr MFDecoderInit(GUID audio_format) { return std::move(transform); } -void MFDeInit(IMFTransform* transform) { - MFShutdownObject(transform); +void MFDestroy() { + MFShutdown(); CoUninitialize(); } @@ -126,11 +128,11 @@ unique_mfptr CreateSample(void* data, DWORD len, DWORD alignment, LON ReportError("Unable to set sample duration, but continuing anyway", hr); } - return std::move(sample); + return sample; } bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSData& adts, - UINT8* user_data, UINT32 user_data_len, GUID audio_format) { + const UINT8* user_data, UINT32 user_data_len, GUID audio_format) { HRESULT hr = S_OK; unique_mfptr t; @@ -209,7 +211,7 @@ bool SelectOutputMediaType(IMFTransform* transform, int out_stream_id, GUID audi return false; } -std::optional DetectMediaType(char* buffer, size_t len) { +std::optional DetectMediaType(char* buffer, std::size_t len) { if (len < 7) { return std::nullopt; } diff --git a/src/audio_core/hle/wmf_decoder_utils.h b/src/audio_core/hle/wmf_decoder_utils.h index a5e5d0154..ac114edc9 100644 --- a/src/audio_core/hle/wmf_decoder_utils.h +++ b/src/audio_core/hle/wmf_decoder_utils.h @@ -29,6 +29,14 @@ struct MFRelease { }; }; +template <> +struct MFRelease { + void operator()(IMFTransform* pointer) const { + MFShutdownObject(pointer); + pointer->Release(); + }; +}; + // wrapper facilities for dealing with pointers template using unique_mfptr = std::unique_ptr>; @@ -67,13 +75,13 @@ struct ADTSMeta { // exported functions bool MFCoInit(); unique_mfptr MFDecoderInit(GUID audio_format = MFAudioFormat_AAC); -void MFDeInit(IMFTransform* transform); +void MFDestroy(); unique_mfptr CreateSample(void* data, DWORD len, DWORD alignment = 1, LONGLONG duration = 0); bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSData& adts, - UINT8* user_data, UINT32 user_data_len, + const UINT8* user_data, UINT32 user_data_len, GUID audio_format = MFAudioFormat_AAC); -std::optional DetectMediaType(char* buffer, size_t len); +std::optional DetectMediaType(char* buffer, std::size_t len); bool SelectOutputMediaType(IMFTransform* transform, int out_stream_id, GUID audio_format = MFAudioFormat_PCM); void MFFlush(IMFTransform* transform); From 01e0902fa42d35e78faacd15dd68ee40aea66d56 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 9 Feb 2019 13:40:09 -0700 Subject: [PATCH 2/6] audio_core: hle: mf: fix a memory accessing issue --- src/audio_core/hle/wmf_decoder.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index 44a250c33..c3c8d6f15 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -98,6 +98,9 @@ std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& r void WMFDecoder::Impl::Clear() { if (initialized) { MFFlush(transform.get()); + // delete the transform object before shutting down MF + // otherwise access violation will occur + transform.reset(); MFDestroy(); } initialized = false; From f0e041e27a849e5ec2091d347ac9055ec79eff45 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 9 Feb 2019 16:49:48 -0700 Subject: [PATCH 3/6] audio_core: hle: mf: correctly handle stream change --- src/audio_core/hle/wmf_decoder.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index c3c8d6f15..4d649349a 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -32,9 +32,7 @@ private: DWORD out_stream_id = 0; }; -WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) { - MFCoInit(); -} +WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) {} WMFDecoder::Impl::~Impl() { Clear(); @@ -67,8 +65,8 @@ std::optional WMFDecoder::Impl::ProcessRequest(const BinaryReque } std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& request) { - if (initialized) { - Clear(); + if (!initialized) { + MFCoInit(); } BinaryResponse response; @@ -141,7 +139,7 @@ MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header, // for status = 2, reset MF if (output_status == MFOutputState::NeedReconfig) { Clear(); - return MFOutputState::FatalError; + return MFOutputState::NeedReconfig; } // for status = 3, try again with new buffer @@ -182,6 +180,7 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ std::array, 2> out_streams; unique_mfptr sample; MFInputState input_status = MFInputState::OK; + MFOutputState output_status = MFOutputState::OK; std::optional adts_meta = DetectMediaType((char*)data, request.size); if (!adts_meta) { @@ -209,8 +208,9 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ while (true) { input_status = SendSample(transform.get(), in_stream_id, sample.get()); + output_status = DecodingLoop(adts_meta->ADTSHeader, out_streams); - if (DecodingLoop(adts_meta->ADTSHeader, out_streams) == MFOutputState::FatalError) { + if (output_status == MFOutputState::FatalError) { // if the decode issues are caused by MFT not accepting new samples, try again // NOTICE: you are required to check the output even if you already knew/guessed // MFT didn't accept the input sample @@ -221,6 +221,11 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ LOG_ERROR(Audio_DSP, "Errors occurred when receiving output"); return response; + } else if (output_status == MFOutputState::NeedReconfig) { + // re-initialize the whole thing to adapt to new parameters + this->Initalize(request); + // decode again + return this->Decode(request); } break; // jump out of the loop if at least we don't have obvious issues From 6178cc08b74055e8c9f821a9805c96dda4566ea4 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Wed, 13 Feb 2019 13:49:41 -0700 Subject: [PATCH 4/6] audio_core: hle: mf: conform to RAII as possible --- src/audio_core/hle/wmf_decoder.cpp | 68 +++++++++++++----------- src/audio_core/hle/wmf_decoder_utils.cpp | 27 ---------- src/audio_core/hle/wmf_decoder_utils.h | 2 - 3 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index 4d649349a..8599b206d 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -16,14 +16,12 @@ public: private: std::optional Initalize(const BinaryRequest& request); - void Clear(); - std::optional Decode(const BinaryRequest& request); MFOutputState DecodingLoop(ADTSData adts_header, std::array, 2>& out_streams); - bool initialized = false; - bool selected = false; + bool transform_initialized = false; + bool format_selected = false; Memory::MemorySystem& memory; @@ -32,10 +30,35 @@ private: DWORD out_stream_id = 0; }; -WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) {} +WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) { + HRESULT hr = S_OK; + hr = CoInitialize(NULL); + // S_FALSE will be returned when COM has already been initialized + if (hr != S_OK && hr != S_FALSE) { + ReportError("Failed to start COM components", hr); + } + + // lite startup is faster and all what we need is included + hr = MFStartup(MF_VERSION, MFSTARTUP_LITE); + if (hr != S_OK) { + // Do you know you can't initialize MF in test mode or safe mode? + ReportError("Failed to initialize Media Foundation", hr); + } + + LOG_INFO(Audio_DSP, "Media Foundation activated"); +} WMFDecoder::Impl::~Impl() { - Clear(); + if (transform_initialized) { + MFFlush(transform.get()); + // delete the transform object before shutting down MF + // otherwise access violation will occur + transform.reset(); + MFShutdown(); + CoUninitialize(); + } + transform_initialized = false; + format_selected = false; } std::optional WMFDecoder::Impl::ProcessRequest(const BinaryRequest& request) { @@ -65,17 +88,13 @@ std::optional WMFDecoder::Impl::ProcessRequest(const BinaryReque } std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& request) { - if (!initialized) { - MFCoInit(); - } - BinaryResponse response; std::memcpy(&response, &request, sizeof(response)); response.unknown1 = 0x0; transform = MFDecoderInit(); if (transform == nullptr) { - LOG_CRITICAL(Audio_DSP, "Can't init decoder"); + LOG_CRITICAL(Audio_DSP, "Can't initialize decoder"); return response; } @@ -89,22 +108,11 @@ std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& r return response; } - initialized = true; + transform_initialized = true; + format_selected = false; // select format again if application request initialize the DSP return response; } -void WMFDecoder::Impl::Clear() { - if (initialized) { - MFFlush(transform.get()); - // delete the transform object before shutting down MF - // otherwise access violation will occur - transform.reset(); - MFDestroy(); - } - initialized = false; - selected = false; -} - MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header, std::array, 2>& out_streams) { MFOutputState output_status = MFOutputState::OK; @@ -138,7 +146,7 @@ MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header, // for status = 2, reset MF if (output_status == MFOutputState::NeedReconfig) { - Clear(); + format_selected = false; return MFOutputState::NeedReconfig; } @@ -164,7 +172,7 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ response.num_channels = 2; response.num_samples = 1024; - if (!initialized) { + if (!transform_initialized) { LOG_DEBUG(Audio_DSP, "Decoder not initialized"); // This is a hack to continue games when decoder failed to initialize return response; @@ -190,7 +198,7 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ response.num_channels = adts_meta->ADTSHeader.channels; - if (!selected) { + if (!format_selected) { LOG_DEBUG(Audio_DSP, "New ADTS stream: channels = {}, sample rate = {}", adts_meta->ADTSHeader.channels, adts_meta->ADTSHeader.samplerate); SelectInputMediaType(transform.get(), in_stream_id, adts_meta->ADTSHeader, @@ -200,7 +208,7 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ // cache the result from detect_mediatype and call select_*_mediatype only once // This could increase performance very slightly transform->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, 0); - selected = true; + format_selected = true; } sample = CreateSample((void*)data, request.size, 1, 0); @@ -222,8 +230,8 @@ std::optional WMFDecoder::Impl::Decode(const BinaryRequest& requ LOG_ERROR(Audio_DSP, "Errors occurred when receiving output"); return response; } else if (output_status == MFOutputState::NeedReconfig) { - // re-initialize the whole thing to adapt to new parameters - this->Initalize(request); + // flush the transform + MFFlush(transform.get()); // decode again return this->Decode(request); } diff --git a/src/audio_core/hle/wmf_decoder_utils.cpp b/src/audio_core/hle/wmf_decoder_utils.cpp index 7dec97abf..e4055bfb2 100644 --- a/src/audio_core/hle/wmf_decoder_utils.cpp +++ b/src/audio_core/hle/wmf_decoder_utils.cpp @@ -25,28 +25,6 @@ void ReportError(std::string msg, HRESULT hr) { LOG_CRITICAL(Audio_DSP, "{}: {:08x}", msg, hr); } -bool MFCoInit() { - HRESULT hr = S_OK; - hr = CoInitialize(NULL); - // S_FALSE will be returned when COM has already been initialized - if (hr != S_OK && hr != S_FALSE) { - ReportError("Failed to start COM components", hr); - return false; - } - - // lite startup is faster and all what we need is included - hr = MFStartup(MF_VERSION, MFSTARTUP_LITE); - if (hr != S_OK) { - // Do you know you can't initialize MF in test mode or safe mode? - ReportError("Failed to initialize Media Foundation", hr); - return false; - } - - LOG_INFO(Audio_DSP, "Media Foundation activated"); - - return true; -} - unique_mfptr MFDecoderInit(GUID audio_format) { HRESULT hr = S_OK; MFT_REGISTER_TYPE_INFO reg = {0}; @@ -84,11 +62,6 @@ unique_mfptr MFDecoderInit(GUID audio_format) { return std::move(transform); } -void MFDestroy() { - MFShutdown(); - CoUninitialize(); -} - unique_mfptr CreateSample(void* data, DWORD len, DWORD alignment, LONGLONG duration) { HRESULT hr = S_OK; unique_mfptr buf; diff --git a/src/audio_core/hle/wmf_decoder_utils.h b/src/audio_core/hle/wmf_decoder_utils.h index ac114edc9..f9a75af79 100644 --- a/src/audio_core/hle/wmf_decoder_utils.h +++ b/src/audio_core/hle/wmf_decoder_utils.h @@ -73,9 +73,7 @@ struct ADTSMeta { }; // exported functions -bool MFCoInit(); unique_mfptr MFDecoderInit(GUID audio_format = MFAudioFormat_AAC); -void MFDestroy(); unique_mfptr CreateSample(void* data, DWORD len, DWORD alignment = 1, LONGLONG duration = 0); bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSData& adts, From 671ac441e95113bb63bed6d2e40b6316e95a3430 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Wed, 13 Feb 2019 14:32:14 -0700 Subject: [PATCH 5/6] audio_core: hle: mf: move transform initializer to ctor --- src/audio_core/hle/wmf_decoder.cpp | 43 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index 8599b206d..e78f24ca1 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -46,6 +46,24 @@ WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) { } LOG_INFO(Audio_DSP, "Media Foundation activated"); + + // initialize transform + transform = MFDecoderInit(); + if (transform == nullptr) { + LOG_CRITICAL(Audio_DSP, "Can't initialize decoder"); + return; + } + + hr = transform->GetStreamIDs(1, &in_stream_id, 1, &out_stream_id); + if (hr == E_NOTIMPL) { + // if not implemented, it means this MFT does not assign stream ID for you + in_stream_id = 0; + out_stream_id = 0; + } else if (FAILED(hr)) { + ReportError("Decoder failed to initialize the stream ID", hr); + return; + } + transform_initialized = true; } WMFDecoder::Impl::~Impl() { @@ -54,11 +72,9 @@ WMFDecoder::Impl::~Impl() { // delete the transform object before shutting down MF // otherwise access violation will occur transform.reset(); - MFShutdown(); - CoUninitialize(); } - transform_initialized = false; - format_selected = false; + MFShutdown(); + CoUninitialize(); } std::optional WMFDecoder::Impl::ProcessRequest(const BinaryRequest& request) { @@ -91,25 +107,8 @@ std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& r BinaryResponse response; std::memcpy(&response, &request, sizeof(response)); response.unknown1 = 0x0; - transform = MFDecoderInit(); - if (transform == nullptr) { - LOG_CRITICAL(Audio_DSP, "Can't initialize decoder"); - return response; - } - - HRESULT hr = transform->GetStreamIDs(1, &in_stream_id, 1, &out_stream_id); - if (hr == E_NOTIMPL) { - // if not implemented, it means this MFT does not assign stream ID for you - in_stream_id = 0; - out_stream_id = 0; - } else if (FAILED(hr)) { - ReportError("Decoder failed to initialize the stream ID", hr); - return response; - } - - transform_initialized = true; - format_selected = false; // select format again if application request initialize the DSP + format_selected = false; // select format again if application request initialize the DSP return response; } From a4ba35fe3afdf9d7ce8d8162b695c2066744a805 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Wed, 13 Feb 2019 15:15:11 -0700 Subject: [PATCH 6/6] audio_core: hle: mf: lint --- src/audio_core/hle/wmf_decoder_utils.cpp | 7 +++++-- src/audio_core/hle/wmf_decoder_utils.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/audio_core/hle/wmf_decoder_utils.cpp b/src/audio_core/hle/wmf_decoder_utils.cpp index e4055bfb2..21dd8a950 100644 --- a/src/audio_core/hle/wmf_decoder_utils.cpp +++ b/src/audio_core/hle/wmf_decoder_utils.cpp @@ -52,6 +52,8 @@ unique_mfptr MFDecoderInit(GUID audio_format) { if (FAILED(hr)) transform = nullptr; activate[n]->Release(); + if (SUCCEEDED(hr)) + break; } if (transform == nullptr) { ReportError("Failed to initialize MFT", hr); @@ -59,10 +61,11 @@ unique_mfptr MFDecoderInit(GUID audio_format) { return nullptr; } CoTaskMemFree(activate); - return std::move(transform); + return transform; } -unique_mfptr CreateSample(void* data, DWORD len, DWORD alignment, LONGLONG duration) { +unique_mfptr CreateSample(const void* data, DWORD len, DWORD alignment, + LONGLONG duration) { HRESULT hr = S_OK; unique_mfptr buf; unique_mfptr sample; diff --git a/src/audio_core/hle/wmf_decoder_utils.h b/src/audio_core/hle/wmf_decoder_utils.h index f9a75af79..26e1217a2 100644 --- a/src/audio_core/hle/wmf_decoder_utils.h +++ b/src/audio_core/hle/wmf_decoder_utils.h @@ -74,7 +74,7 @@ struct ADTSMeta { // exported functions unique_mfptr MFDecoderInit(GUID audio_format = MFAudioFormat_AAC); -unique_mfptr CreateSample(void* data, DWORD len, DWORD alignment = 1, +unique_mfptr CreateSample(const void* data, DWORD len, DWORD alignment = 1, LONGLONG duration = 0); bool SelectInputMediaType(IMFTransform* transform, int in_stream_id, const ADTSData& adts, const UINT8* user_data, UINT32 user_data_len,