Only convert upon successful capture

This commit is contained in:
capitalistspz 2024-09-05 16:44:27 +01:00
parent 277c3efacd
commit 6093ee03a5

View file

@ -158,14 +158,17 @@ namespace camera
{ {
if (!m_opened) if (!m_opened)
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(2)); std::this_thread::sleep_for(std::chrono::milliseconds(20));
std::this_thread::yield(); std::this_thread::yield();
continue; continue;
} }
Cap_captureFrame(m_capCtx, stream, rgbBuffer.get(), rgbBufferSize); auto res = Cap_captureFrame(m_capCtx, stream, rgbBuffer.get(), rgbBufferSize);
if (res == CAPRESULT_OK)
{
std::scoped_lock lock(m_callbackMutex); std::scoped_lock lock(m_callbackMutex);
Rgb2Nv12(rgbBuffer.get(), g_width, g_height, m_capNv12Buffer.get(), g_pitch); Rgb2Nv12(rgbBuffer.get(), g_width, g_height, m_capNv12Buffer.get(), g_pitch);
} }
}
Cap_closeStream(m_capCtx, stream); Cap_closeStream(m_capCtx, stream);
} }
@ -209,7 +212,7 @@ namespace camera
return CAMError::NotReady; return CAMError::NotReady;
if (!m_targetSurfaceQueue.Push(surface)) if (!m_targetSurfaceQueue.Push(surface))
return CAMError::SurfaceQueueFull; return CAMError::SurfaceQueueFull;
cemuLog_logDebug(LogType::Force, "camera: surface submitted"); cemuLog_logDebug(LogType::Force, "camera: surface {} submitted", surface->surfacePtr);
return CAMError::Success; return CAMError::Success;
} }