mirror of
https://github.com/PabloMK7/citra
synced 2024-11-15 13:18:24 +00:00
audio_core: hle: mf: use more enum
This commit is contained in:
parent
be764e4f88
commit
452ac7b874
3 changed files with 14 additions and 12 deletions
|
@ -104,7 +104,7 @@ void WMFDecoder::Impl::Clear() {
|
|||
}
|
||||
|
||||
MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header,
|
||||
std::array<std::vector<u8>, 2>& out_streams) {
|
||||
std::array<std::vector<u8>, 2>& out_streams) {
|
||||
MFOutputState output_status = OK;
|
||||
char* output_buffer = nullptr;
|
||||
DWORD output_len = 0;
|
||||
|
@ -184,7 +184,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::Decode(const BinaryRequest& requ
|
|||
unique_mfptr<IMFSample> sample;
|
||||
ADTSData adts_header;
|
||||
char* aac_tag = (char*)calloc(1, 14);
|
||||
int input_status = 0;
|
||||
MFInputState input_status = INPUT_OK;
|
||||
|
||||
if (DetectMediaType((char*)data, request.size, &adts_header, &aac_tag) != 0) {
|
||||
LOG_ERROR(Audio_DSP, "Unable to deduce decoding parameters from ADTS stream");
|
||||
|
@ -215,7 +215,7 @@ std::optional<BinaryResponse> WMFDecoder::Impl::Decode(const BinaryRequest& requ
|
|||
// 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
|
||||
if (input_status == 1) {
|
||||
if (input_status == TRY_AGAIN) {
|
||||
// try again
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -234,26 +234,26 @@ int DetectMediaType(char* buffer, size_t len, ADTSData* output, char** aac_tag)
|
|||
}
|
||||
|
||||
void MFFlush(IMFTransform* transform) {
|
||||
HRESULT hr = (transform)->ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH, 0);
|
||||
HRESULT hr = transform->ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH, 0);
|
||||
if (FAILED(hr)) {
|
||||
ReportError("MFT: Flush command failed", hr);
|
||||
}
|
||||
hr = (transform)->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0);
|
||||
hr = transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0);
|
||||
if (FAILED(hr)) {
|
||||
ReportError("Failed to end streaming for MFT", hr);
|
||||
}
|
||||
}
|
||||
|
||||
int SendSample(IMFTransform* transform, DWORD in_stream_id, IMFSample* in_sample) {
|
||||
MFInputState SendSample(IMFTransform* transform, DWORD in_stream_id, IMFSample* in_sample) {
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (in_sample) {
|
||||
hr = transform->ProcessInput(in_stream_id, in_sample, 0);
|
||||
if (hr == MF_E_NOTACCEPTING) {
|
||||
return 1; // try again
|
||||
return TRY_AGAIN; // try again
|
||||
} else if (FAILED(hr)) {
|
||||
ReportError("MFT: Failed to process input", hr);
|
||||
return -1;
|
||||
return INPUT_ERROR;
|
||||
} // FAILED(hr)
|
||||
} else {
|
||||
hr = transform->ProcessMessage(MFT_MESSAGE_COMMAND_DRAIN, 0);
|
||||
|
@ -262,7 +262,7 @@ int SendSample(IMFTransform* transform, DWORD in_stream_id, IMFSample* in_sample
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return INPUT_OK;
|
||||
}
|
||||
|
||||
std::tuple<MFOutputState, unique_mfptr<IMFSample>> ReceiveSample(IMFTransform* transform,
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
|
||||
#include "adts.h"
|
||||
|
||||
enum MFOutputState { FATAL_ERROR = -1, OK = 0, NEED_MORE_INPUT, NEED_RECONFIG, HAVE_MORE_DATA };
|
||||
enum MFOutputState { FATAL_ERROR, OK, NEED_MORE_INPUT, NEED_RECONFIG, HAVE_MORE_DATA };
|
||||
enum MFInputState { INPUT_ERROR, INPUT_OK, TRY_AGAIN };
|
||||
|
||||
// utility functions
|
||||
template <class T>
|
||||
|
@ -36,7 +37,8 @@ void ReportError(std::string msg, HRESULT hr);
|
|||
bool MFCoInit();
|
||||
bool MFDecoderInit(IMFTransform** transform, GUID audio_format = MFAudioFormat_AAC);
|
||||
void MFDeInit(IMFTransform* transform);
|
||||
unique_mfptr<IMFSample> CreateSample(void* data, DWORD len, DWORD alignment = 1, LONGLONG duration = 0);
|
||||
unique_mfptr<IMFSample> 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,
|
||||
GUID audio_format = MFAudioFormat_AAC);
|
||||
|
@ -44,7 +46,7 @@ int DetectMediaType(char* buffer, size_t len, ADTSData* output, char** aac_tag);
|
|||
bool SelectOutputMediaType(IMFTransform* transform, int out_stream_id,
|
||||
GUID audio_format = MFAudioFormat_PCM);
|
||||
void MFFlush(IMFTransform* transform);
|
||||
int SendSample(IMFTransform* transform, DWORD in_stream_id, IMFSample* in_sample);
|
||||
MFInputState SendSample(IMFTransform* transform, DWORD in_stream_id, IMFSample* in_sample);
|
||||
std::tuple<MFOutputState, unique_mfptr<IMFSample>> ReceiveSample(IMFTransform* transform,
|
||||
DWORD out_stream_id);
|
||||
int CopySampleToBuffer(IMFSample* sample, void** output, DWORD* len);
|
||||
|
|
Loading…
Reference in a new issue