Skip to content

Commit 6ec312c

Browse files
committed
Added support for new audio device API
1 parent 3d814dc commit 6ec312c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,16 @@ struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
118118
UGameViewportClient::OnViewportCreated().AddRaw(this, &FInEditorMultiCapture::OnStart);
119119
FEditorDelegates::EndPIE.AddRaw(this, &FInEditorMultiCapture::OnEndPIE);
120120

121-
FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice();
122-
if (AudioDevice != nullptr)
121+
//Use auto because UE4.25 changed type, but type has same interface
122+
auto AudioDevice = GEngine->GetMainAudioDevice();
123+
124+
#if ENGINE_MINOR_VERSION >= 25
125+
bool bIsDeviceValid = AudioDevice.IsValid();
126+
#else
127+
bool bIsDeviceValid = (AudioDevice != nullptr);
128+
#endif
129+
130+
if (bIsDeviceValid)
123131
{
124132
TransientMasterVolume = AudioDevice->GetTransientMasterVolume();
125133
AudioDevice->SetTransientMasterVolume(0.0f);
@@ -278,8 +286,16 @@ struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
278286

279287
FObjectReader(GetMutableDefault<ULevelEditorPlaySettings>(), BackedUpPlaySettings);
280288

281-
FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice();
282-
if (AudioDevice != nullptr)
289+
//Use auto because UE4.25 changed type, but type has same interface
290+
auto AudioDevice = GEngine->GetMainAudioDevice();
291+
292+
#if ENGINE_MINOR_VERSION >= 25
293+
bool bIsDeviceValid = AudioDevice.IsValid();
294+
#else
295+
bool bIsDeviceValid = (AudioDevice != nullptr);
296+
#endif
297+
298+
if (bIsDeviceValid)
283299
{
284300
AudioDevice->SetTransientMasterVolume(TransientMasterVolume);
285301
}

0 commit comments

Comments
 (0)