fix: use IDeckLinkVideoBuffer::GetBytes for frame access

On Linux, GetBytes lives on IDeckLinkVideoBuffer (via QueryInterface),
not directly on IDeckLinkVideoInputFrame. Also restores StartAccess/
EndAccess around the copy for correct buffer lifecycle management.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
JohannesItten
2026-07-06 01:42:32 +03:00
parent e335461aac
commit 7847a8b70d
+15 -8
View File
@@ -142,16 +142,20 @@ private:
IDeckLinkAudioInputPacket* /*audio_packet*/) override IDeckLinkAudioInputPacket* /*audio_packet*/) override
{ {
if (!video_frame) return S_OK; if (!video_frame) return S_OK;
IDeckLinkVideoBuffer* buf = nullptr;
if (video_frame->QueryInterface(IID_IDeckLinkVideoBuffer, (void**)&buf) != S_OK)
return S_OK;
buf->StartAccess(bmdBufferAccessRead);
void* src = nullptr; void* src = nullptr;
video_frame->GetBytes(&src); buf->GetBytes(&src);
if (!src) return S_OK;
const uint32_t row_bytes = static_cast<uint32_t>(video_frame->GetRowBytes()); if (src) {
const int fw = static_cast<int>(video_frame->GetWidth()); const uint32_t row_bytes = static_cast<uint32_t>(video_frame->GetRowBytes());
const int fh = static_cast<int>(video_frame->GetHeight()); const int fw = static_cast<int>(video_frame->GetWidth());
const size_t sz = static_cast<size_t>(row_bytes) * static_cast<size_t>(fh); const int fh = static_cast<int>(video_frame->GetHeight());
const size_t sz = static_cast<size_t>(row_bytes) * static_cast<size_t>(fh);
{
std::lock_guard<std::mutex> lk(owner.mutex); std::lock_guard<std::mutex> lk(owner.mutex);
if (owner.frame_buffer.size() < sz) owner.frame_buffer.resize(sz); if (owner.frame_buffer.size() < sz) owner.frame_buffer.resize(sz);
std::memcpy(owner.frame_buffer.data(), src, sz); std::memcpy(owner.frame_buffer.data(), src, sz);
@@ -160,7 +164,10 @@ private:
owner.frame_height = fh; owner.frame_height = fh;
owner.frame_ready = true; owner.frame_ready = true;
} }
owner.frame_cv.notify_one();
buf->EndAccess(bmdBufferAccessRead);
buf->Release();
if (src) owner.frame_cv.notify_one();
return S_OK; return S_OK;
} }