From 1e4f96486fe4038d39b5e8e9c663d2c1e97be936 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 17 Nov 2025 09:58:08 -0800 Subject: [PATCH] Fix audio playback bug from video on Xbox --- Source/Engine/Video/MF/VideoBackendMF.cpp | 11 ++++++++++- Source/Engine/Video/Video.Build.cs | 11 +++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Video/MF/VideoBackendMF.cpp b/Source/Engine/Video/MF/VideoBackendMF.cpp index b8ef7ee4e..df24f5eed 100644 --- a/Source/Engine/Video/MF/VideoBackendMF.cpp +++ b/Source/Engine/Video/MF/VideoBackendMF.cpp @@ -12,6 +12,12 @@ #if USE_EDITOR #include "Editor/Editor.h" #endif +#if PLATFORM_XBOX_ONE || PLATFORM_XBOX_SCARLETT +#define USE_STOCKD3D 0 +#include +#include +#include +#else #include #if WINVER >= _WIN32_WINNT_WINBLUE && WINVER < _WIN32_WINNT_WIN10 // Fix compilation for Windows 8.1 on the latest Windows SDK @@ -24,6 +30,7 @@ typedef enum _MFVideoSphericalFormat { } MFVideoSphericalFormat; #include #include #include +#endif #define VIDEO_API_MF_ERROR(api, err) LOG(Warning, "[VideoBackendMF] {} failed with error 0x{:x}", TEXT(#api), (uint64)err) @@ -111,7 +118,7 @@ namespace MF player.Format = PixelFormat::NV12; else if (subtype == MFVideoFormat_YUY2) player.Format = PixelFormat::YUY2; -#if (WDK_NTDDI_VERSION >= NTDDI_WIN10) +#if (WDK_NTDDI_VERSION >= NTDDI_WIN10) && PLATFORM_WINDOWS else if (subtype == MFVideoFormat_A2R10G10B10) player.Format = PixelFormat::R10G10B10A2_UNorm; else if (subtype == MFVideoFormat_A16B16G16R16F) @@ -150,6 +157,7 @@ namespace MF } else if (majorType == MFMediaType_Audio) { +#if !(PLATFORM_XBOX_ONE || PLATFORM_XBOX_SCARLETT) // TODO: fix missing MFAudioFormat_PCM/MFAudioFormat_Float convertion on Xbox (bug?) player.AudioInfo.SampleRate = MFGetAttributeUINT32(mediaType, MF_MT_AUDIO_SAMPLES_PER_SECOND, 0); player.AudioInfo.NumChannels = MFGetAttributeUINT32(mediaType, MF_MT_AUDIO_NUM_CHANNELS, 0); player.AudioInfo.BitDepth = MFGetAttributeUINT32(mediaType, MF_MT_AUDIO_BITS_PER_SAMPLE, 16); @@ -173,6 +181,7 @@ namespace MF } customType->Release(); } +#endif } result = false; diff --git a/Source/Engine/Video/Video.Build.cs b/Source/Engine/Video/Video.Build.cs index fe99c1433..3975480ee 100644 --- a/Source/Engine/Video/Video.Build.cs +++ b/Source/Engine/Video/Video.Build.cs @@ -22,8 +22,6 @@ public class Video : EngineModule { case TargetPlatform.Windows: case TargetPlatform.UWP: - case TargetPlatform.XboxOne: - case TargetPlatform.XboxScarlett: // Media Foundation options.SourcePaths.Add(Path.Combine(FolderPath, "MF")); options.CompileEnv.PreprocessorDefinitions.Add("VIDEO_API_MF"); @@ -34,6 +32,15 @@ public class Video : EngineModule options.OutputFiles.Add("mfreadwrite.lib"); options.OutputFiles.Add("mfuuid.lib"); break; + case TargetPlatform.XboxOne: + case TargetPlatform.XboxScarlett: + // Media Foundation + options.SourcePaths.Add(Path.Combine(FolderPath, "MF")); + options.CompileEnv.PreprocessorDefinitions.Add("VIDEO_API_MF"); + options.OutputFiles.Add("mfplat.lib"); + options.OutputFiles.Add("mfreadwrite.lib"); + options.OutputFiles.Add("mfuuid.lib"); + break; case TargetPlatform.Mac: case TargetPlatform.iOS: // AVFoundation