Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create fake codec data for WMA3 #327

Merged
merged 1 commit into from
Dec 25, 2023
Merged

Conversation

ivyl
Copy link
Contributor

@ivyl ivyl commented Dec 25, 2023

The extra codec data is not being passed by the METAL GEAR SOLID 3: Snake Eater - Master Collection Version. I've tried to make it work:

diff --git a/libs/faudio/src/FAudio.c b/libs/faudio/src/FAudio.c
index 7d34b666535..d235fd44a1a 100644
--- a/libs/faudio/src/FAudio.c
+++ b/libs/faudio/src/FAudio.c
@@ -297,7 +297,7 @@ uint32_t FAudio_CreateSourceVoice(
      pSourceFormat->wFormatTag == FAUDIO_FORMAT_WMAUDIO3   )
   {
      FAudioWaveFormatExtensible *fmtex = (FAudioWaveFormatExtensible*) audio->pMalloc(
-        sizeof(FAudioWaveFormatExtensible)
+        sizeof(FAudioWaveFormatExtensible) + pSourceFormat->cbSize
      );
      /* convert PCM to EXTENSIBLE */
      fmtex->Format.wFormatTag = FAUDIO_FORMAT_EXTENSIBLE;
@@ -306,7 +306,7 @@ uint32_t FAudio_CreateSourceVoice(
      fmtex->Format.nAvgBytesPerSec = pSourceFormat->nAvgBytesPerSec;
      fmtex->Format.nBlockAlign = pSourceFormat->nBlockAlign;
      fmtex->Format.wBitsPerSample = pSourceFormat->wBitsPerSample;
-     fmtex->Format.cbSize = sizeof(FAudioWaveFormatExtensible) - sizeof(FAudioWaveFormatEx);
+     fmtex->Format.cbSize = sizeof(FAudioWaveFormatExtensible) - sizeof(FAudioWaveFormatEx) + pSourceFormat->cbSize;
      fmtex->Samples.wValidBitsPerSample = pSourceFormat->wBitsPerSample;
      fmtex->dwChannelMask = 0;
      if (pSourceFormat->wFormatTag == FAUDIO_FORMAT_PCM)
@@ -325,6 +325,7 @@ uint32_t FAudio_CreateSourceVoice(
      {
         FAudio_memcpy(&fmtex->SubFormat, &DATAFORMAT_SUBTYPE_WMAUDIO3, sizeof(FAudioGUID));
      }
+     FAudio_memcpy(&fmtex[1], &pSourceFormat[1], pSourceFormat->cbSize);
      (*ppSourceVoice)->src.format = &fmtex->Format;
   }
   else if (pSourceFormat->wFormatTag == FAUDIO_FORMAT_MSADPCM)

(this bit seems to be missing in case the game / software actually passes any extra data past the format header)

But looks like we have to create a fake codec data for WMA3 too.

This makes it so that the passed data to Media Foundation is a correct WMA and can be played (after dumping into a file) both by Windows and by FFMPEG.

@flibitijibibo flibitijibibo merged commit 5501da9 into FNA-XNA:master Dec 25, 2023
5 checks passed
Plagman pushed a commit to ValveSoftware/wine that referenced this pull request Dec 29, 2023
Already upstreamed, can be dropped the next bump.

Link: FNA-XNA/FAudio#327
Plagman pushed a commit to ValveSoftware/wine that referenced this pull request Feb 26, 2024
Already upstreamed, can be dropped the next bump.

Link: FNA-XNA/FAudio#327
Plagman pushed a commit to ValveSoftware/wine that referenced this pull request May 3, 2024
Already upstreamed, can be dropped the next bump.

Link: FNA-XNA/FAudio#327
Plagman pushed a commit to ValveSoftware/wine that referenced this pull request Jun 6, 2024
Already upstreamed, can be dropped the next bump.

Link: FNA-XNA/FAudio#327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants