Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #407 from DolbyIO/disco_crash
Browse files Browse the repository at this point in the history
Ignore new frames instead of destroying SDK during subsystem deinitia…
  • Loading branch information
Kuba Audykowicz authored Sep 18, 2023
2 parents cb386de + d134cdf commit 0a1cd97
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion DolbyIO/Source/Private/DolbyIOSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ void UDolbyIOSubsystem::Initialize(FSubsystemCollectionBase& Collection)

void UDolbyIOSubsystem::Deinitialize()
{
Sdk.Reset(); // make sure Sdk is dead so it doesn't call handle_frame on VideoSink during game destruction
DLB_UE_LOG("Deinitializing");
for (auto& Sink : VideoSinks)
{
Sink.Value->Disable(); // ignore new frames now on
}

Super::Deinitialize();
}
Expand Down
10 changes: 10 additions & 0 deletions DolbyIO/Source/Private/DolbyIOVideoSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@ namespace DolbyIO
});
}

void FVideoSink::Disable()
{
bIsEnabled = false;
}

void FVideoSink::handle_frame(const video_frame& VideoFrame)
{
if (!bIsEnabled)
{
return;
}

!Texture ? CreateTexture(VideoFrame.width(), VideoFrame.height())
: ResizeTexture(VideoFrame.width(), VideoFrame.height());
Convert(VideoFrame);
Expand Down
2 changes: 2 additions & 0 deletions DolbyIO/Source/Private/DolbyIOVideoSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace DolbyIO
void BindMaterial(UMaterialInstanceDynamic* Material);
void UnbindMaterial(UMaterialInstanceDynamic* Material);
void UnbindAllMaterials();
void Disable();

private:
void handle_frame(const dolbyio::comms::video_frame&) override;
Expand All @@ -37,5 +38,6 @@ namespace DolbyIO
TSet<UMaterialInstanceDynamic*> Materials;
const FString VideoTrackID;
FOnTextureCreated OnTexCreated = [] {};
bool bIsEnabled = true;
};
}

0 comments on commit 0a1cd97

Please sign in to comment.