Skip to content

Commit

Permalink
FAudio: Create fake codec data for WMA3.
Browse files Browse the repository at this point in the history
Already upstreamed, can be dropped the next bump.

Link: FNA-XNA/FAudio#327
  • Loading branch information
ivyl authored and rbernon committed Feb 20, 2024
1 parent 044acf4 commit 92181d9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libs/faudio/src/FAudio_platform_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,7 @@ static void FAudio_INTERNAL_DecodeWMAMF(
uint32_t FAudio_WMADEC_init(FAudioSourceVoice *voice, uint32_t type)
{
static const uint8_t fake_codec_data[16] = {0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t fake_codec_data_wma3[18] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 0, 0};
const FAudioWaveFormatExtensible *wfx = (FAudioWaveFormatExtensible *)voice->src.format;
struct FAudioWMADEC *impl;
MFT_OUTPUT_STREAM_INFO info = {0};
Expand Down Expand Up @@ -1361,11 +1362,17 @@ uint32_t FAudio_WMADEC_init(FAudioSourceVoice *voice, uint32_t type)
FAudio_assert(!FAILED(hr) && "Failed set input block align!");
break;
case FAUDIO_FORMAT_WMAUDIO3:
*(uint16_t *)fake_codec_data_wma3 = voice->src.format->wBitsPerSample;
for (i = 0; i < voice->src.format->nChannels; i++)
{
fake_codec_data_wma3[2] <<= 1;
fake_codec_data_wma3[2] |= 1;
}
hr = IMFMediaType_SetBlob(
media_type,
&MF_MT_USER_DATA,
(void *)&wfx->Samples,
wfx->Format.cbSize
(void *)fake_codec_data_wma3,
sizeof(fake_codec_data_wma3)
);
FAudio_assert(!FAILED(hr) && "Failed set codec private data!");
hr = IMFMediaType_SetGUID(
Expand Down

0 comments on commit 92181d9

Please sign in to comment.