Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion External/libajantv2
16 changes: 9 additions & 7 deletions Source/AJADevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,18 +1071,20 @@ bool AJADevice::AcquireDevice()
if (GetStreamingApplication(curAppFourCC, curPid))
{
if (curPid == nosPid)
return true;
auto curApp = FourCCToString(curAppFourCC);
if (curPid != 0)
nosEngine.LogW("Device %s is already acquired by application %s (PID %d). Trying to reclaim it.", GetDisplayName().c_str(), curApp.c_str(), curPid);
{
auto curApp = FourCCToString(curAppFourCC);
if (curPid != 0)
nosEngine.LogW("Device %s is already acquired by application %s (PID %d). Trying to reclaim it.", GetDisplayName().c_str(), curApp.c_str(), curPid);
}
}

if (!AcquireStreamForApplication(NOS_FOURCC, nosPid))
if (!AcquireStreamForApplicationWithReference(NOS_FOURCC, nosPid))
{
nosEngine.LogE("Failed to acquire device %s for Nodos.", GetDisplayName().c_str());
return false;
}
nosEngine.LogD("Device %s acquired by Nodos.", GetDisplayName().c_str());
if(nosPid != curPid)
Comment thread
caner-milko marked this conversation as resolved.
nosEngine.LogD("Device %s acquired by Nodos.", GetDisplayName().c_str());
Comment on lines 1071 to +1087
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curPid is now used in if(nosPid != curPid) even when GetStreamingApplication(...) returns false. If curPid isn't initialized before the GetStreamingApplication call, this becomes an undefined read and can cause incorrect logging/behavior. Initialize curPid (and any related state) to a known value before the call, or restructure so the comparison/logging only happens when curPid is known to be set.

Copilot uses AI. Check for mistakes.
return true;
}

Expand All @@ -1106,7 +1108,7 @@ void AJADevice::ReleaseDevice()
return;
}

if (ReleaseStreamForApplication(NOS_FOURCC, nosPid))
if (ReleaseStreamForApplicationWithReference(NOS_FOURCC, nosPid))
nosEngine.LogD("Device %s released by Nodos", GetDisplayName().c_str());
else
nosEngine.LogE("Failed to release device %s", GetDisplayName().c_str());
Expand Down
Loading