- Posts: 2
- Joined: Tue Jul 14, 2015 4:19 pm
Hi,
I am having a crash in the BlackMagic Code below. The code is crashing in when i try to access the audioFramePtr but it works 85% of the time. I only see crash randomly. My questions are
1) Is there something wrong I am doing in the code
2) Could the code be crashing because the function is taking too long? I do some analysis on each frame and that could take time.
3) Am i missing any other code that should be included in this code?
Please let me know.
void IDeckLinkInputCallback.VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)
{
bool isVideoPresent = true;
if (videoFrame != null)
{
currentFrameWidth = videoFrame.GetWidth();
currentFrameHeight = videoFrame.GetHeight();
currentRowBytes = videoFrame.GetRowBytes();
frameBytesYUV = new byte[currentRowBytes * currentFrameHeight];
_BMDFrameFlags flags = videoFrame.GetFlags();
if (flags != _BMDFrameFlags.bmdFrameFlagDefault)
{
isVideoPresent = false;
}
videoFrame.GetBytes(out videoFramePtr);
Marshal.Copy(videoFramePtr, frameBytesYUV, 0, currentRowBytes * currentFrameHeight);
if (audioPacket != null)
{
currentAudioSampleCount = audioPacket.GetSampleFrameCount();
audioPacket.GetBytes(out audioFramePtr);
}
FrameArivedEvent(new FrameEventArgs(currentFrameWidth, currentFrameHeight, currentRowBytes, frameBytesYUV, videoFramePtr, audioFramePtr, currentAudioSampleCount, isVideoPresent));
Marshal.FinalReleaseComObject(videoFrame);
}
if (audioPacket != null)
{
Marshal.FinalReleaseComObject(audioPacket);
}
FrameCounter++;
}
I am having a crash in the BlackMagic Code below. The code is crashing in when i try to access the audioFramePtr but it works 85% of the time. I only see crash randomly. My questions are
1) Is there something wrong I am doing in the code
2) Could the code be crashing because the function is taking too long? I do some analysis on each frame and that could take time.
3) Am i missing any other code that should be included in this code?
Please let me know.
void IDeckLinkInputCallback.VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)
{
bool isVideoPresent = true;
if (videoFrame != null)
{
currentFrameWidth = videoFrame.GetWidth();
currentFrameHeight = videoFrame.GetHeight();
currentRowBytes = videoFrame.GetRowBytes();
frameBytesYUV = new byte[currentRowBytes * currentFrameHeight];
_BMDFrameFlags flags = videoFrame.GetFlags();
if (flags != _BMDFrameFlags.bmdFrameFlagDefault)
{
isVideoPresent = false;
}
videoFrame.GetBytes(out videoFramePtr);
Marshal.Copy(videoFramePtr, frameBytesYUV, 0, currentRowBytes * currentFrameHeight);
if (audioPacket != null)
{
currentAudioSampleCount = audioPacket.GetSampleFrameCount();
audioPacket.GetBytes(out audioFramePtr);
}
FrameArivedEvent(new FrameEventArgs(currentFrameWidth, currentFrameHeight, currentRowBytes, frameBytesYUV, videoFramePtr, audioFramePtr, currentAudioSampleCount, isVideoPresent));
Marshal.FinalReleaseComObject(videoFrame);
}
if (audioPacket != null)
{
Marshal.FinalReleaseComObject(audioPacket);
}
FrameCounter++;
}