audio_core: hle: mf: move transform initializer to ctor

This commit is contained in:
liushuyu 2019-02-13 14:32:14 -07:00
parent 6178cc08b7
commit 671ac441e9

View file

@ -46,6 +46,24 @@ WMFDecoder::Impl::Impl(Memory::MemorySystem& memory) : memory(memory) {
} }
LOG_INFO(Audio_DSP, "Media Foundation activated"); 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() { WMFDecoder::Impl::~Impl() {
@ -54,11 +72,9 @@ WMFDecoder::Impl::~Impl() {
// delete the transform object before shutting down MF // delete the transform object before shutting down MF
// otherwise access violation will occur // otherwise access violation will occur
transform.reset(); transform.reset();
}
MFShutdown(); MFShutdown();
CoUninitialize(); CoUninitialize();
}
transform_initialized = false;
format_selected = false;
} }
std::optional<BinaryResponse> WMFDecoder::Impl::ProcessRequest(const BinaryRequest& request) { std::optional<BinaryResponse> WMFDecoder::Impl::ProcessRequest(const BinaryRequest& request) {
@ -91,24 +107,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::Initalize(const BinaryRequest& r
BinaryResponse response; BinaryResponse response;
std::memcpy(&response, &request, sizeof(response)); std::memcpy(&response, &request, sizeof(response));
response.unknown1 = 0x0; 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; return response;
} }