WIP SDL3 compatibility
This commit is contained in:
@@ -666,7 +666,7 @@ void D3D11VARenderer::renderFrame(AVFrame* frame)
|
||||
|
||||
// The card may have been removed or crashed. Reset the decoder.
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ void DrmRenderer::prepareToRender()
|
||||
// operation that the KMSDRM backend keeps pending until the next
|
||||
// time we swap buffers. We have to do this before we enumerate
|
||||
// CRTC modes below.
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(m_Window, -1, SDL_RENDERER_SOFTWARE);
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(m_Window, SDLC_DEFAULT_RENDER_DRIVER, SDL_RENDERER_SOFTWARE);
|
||||
if (renderer != nullptr) {
|
||||
// SDL_CreateRenderer() can end up having to recreate our window (SDL_RecreateWindow())
|
||||
// to ensure it's compatible with the renderer's OpenGL context. If that happens, we
|
||||
|
||||
@@ -1112,7 +1112,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||
"Clear() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||
"BeginScene() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
@@ -1149,7 +1149,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||
"StretchRect() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
@@ -1166,7 +1166,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||
"EndScene() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
@@ -1184,7 +1184,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||
"PresentEx() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void EGLRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
|
||||
if (!Session::get()->getOverlayManager().isOverlayEnabled(type)) {
|
||||
// If the overlay has been disabled, mark the data as invalid/stale.
|
||||
SDL_AtomicSet(&m_OverlayHasValidData[type], 0);
|
||||
SDL_SetAtomicInt(&m_OverlayHasValidData[type], 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type, int viewportWidth, in
|
||||
// we must allocate a tightly packed buffer and copy our pixels there.
|
||||
packedPixelData = malloc(newSurface->w * newSurface->h * newSurface->format->BytesPerPixel);
|
||||
if (!packedPixelData) {
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type, int viewportWidth, in
|
||||
overlayRect.w = newSurface->w;
|
||||
overlayRect.h = newSurface->h;
|
||||
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
|
||||
// Convert screen space to normalized device coordinates
|
||||
StreamUtils::screenSpaceToNormalizedDeviceCoords(&overlayRect, viewportWidth, viewportHeight);
|
||||
@@ -265,10 +265,10 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type, int viewportWidth, in
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_OverlayVbos[type]);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
|
||||
|
||||
SDL_AtomicSet(&m_OverlayHasValidData[type], 1);
|
||||
SDL_SetAtomicInt(&m_OverlayHasValidData[type], 1);
|
||||
}
|
||||
|
||||
if (!SDL_AtomicGet(&m_OverlayHasValidData[type])) {
|
||||
if (!SDL_GetAtomicInt(&m_OverlayHasValidData[type])) {
|
||||
// If the overlay is not populated yet or is stale, don't render it.
|
||||
return;
|
||||
}
|
||||
@@ -435,6 +435,9 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
m_DummyRenderer = SDL_CreateRenderer(m_Window, "opengles2", SDL_RENDERER_ACCELERATED);
|
||||
#else
|
||||
int renderIndex;
|
||||
int maxRenderers = SDL_GetNumRenderDrivers();
|
||||
SDL_assert(maxRenderers >= 0);
|
||||
@@ -454,6 +457,7 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
}
|
||||
|
||||
m_DummyRenderer = SDL_CreateRenderer(m_Window, renderIndex, SDL_RENDERER_ACCELERATED);
|
||||
#endif
|
||||
if (!m_DummyRenderer) {
|
||||
// Print the error here (before it gets clobbered), but ensure that we flush window
|
||||
// events just in case SDL re-created the window before eventually failing.
|
||||
@@ -638,7 +642,7 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
// If we got a working GL implementation via EGL, avoid using GLX from now on.
|
||||
// GLX will cause problems if we later want to use EGL again on this window.
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "EGL passed preflight checks. Using EGL for GL context creation.");
|
||||
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
|
||||
SDL_SetHint(SDL_HINT_VIDEO_FORCE_EGL, "1");
|
||||
}
|
||||
|
||||
return err == GL_NO_ERROR;
|
||||
@@ -822,7 +826,7 @@ void EGLRenderer::renderFrame(AVFrame* frame)
|
||||
// XWayland. Other strategies like calling glGetError() don't seem
|
||||
// to be able to detect this situation for some reason.
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
event.type = SDL_EVENT_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
return;
|
||||
@@ -841,7 +845,11 @@ void EGLRenderer::renderFrame(AVFrame* frame)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
int drawableWidth, drawableHeight;
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
SDL_GetWindowSizeInPixels(m_Window, &drawableWidth, &drawableHeight);
|
||||
#else
|
||||
SDL_GL_GetDrawableSize(m_Window, &drawableWidth, &drawableHeight);
|
||||
#endif
|
||||
|
||||
// Set the viewport to the size of the aspect-ratio-scaled video
|
||||
SDL_Rect src, dst;
|
||||
|
||||
@@ -56,7 +56,7 @@ void MmalRenderer::prepareToRender()
|
||||
{
|
||||
// Create a renderer and draw a black background for the area not covered by the MMAL overlay.
|
||||
// On the KMSDRM backend, this triggers the modeset that puts the CRTC into the mode we selected.
|
||||
m_BackgroundRenderer = SDL_CreateRenderer(m_Window, -1, SDL_RENDERER_SOFTWARE);
|
||||
m_BackgroundRenderer = SDL_CreateRenderer(m_Window, SDLC_DEFAULT_RENDER_DRIVER, SDL_RENDERER_SOFTWARE);
|
||||
if (m_BackgroundRenderer == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_CreateRenderer() failed: %s",
|
||||
|
||||
@@ -98,11 +98,7 @@ int Pacer::vsyncThread(void *context)
|
||||
{
|
||||
Pacer* me = reinterpret_cast<Pacer*>(context);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
#else
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
#endif
|
||||
SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
|
||||
bool async = me->m_VsyncSource->isAsync();
|
||||
while (!me->m_Stopping) {
|
||||
@@ -131,7 +127,7 @@ int Pacer::renderThread(void* context)
|
||||
{
|
||||
Pacer* me = reinterpret_cast<Pacer*>(context);
|
||||
|
||||
if (SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH) < 0) {
|
||||
if (!SDL_SetCurrentThreadPriority(SDL_THREAD_PRIORITY_HIGH)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to set render thread to high priority: %s",
|
||||
SDL_GetError());
|
||||
@@ -183,7 +179,7 @@ void Pacer::enqueueFrameForRenderingAndUnlock(AVFrame *frame)
|
||||
SDL_Event event;
|
||||
|
||||
// For main thread rendering, we'll push an event to trigger a callback
|
||||
event.type = SDL_USEREVENT;
|
||||
event.type = SDL_EVENT_USER;
|
||||
event.user.code = SDL_CODE_FRAME_READY;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ void PlVkRenderer::unlockQueue(struct AVHWDeviceContext *dev_ctx, uint32_t queue
|
||||
|
||||
void PlVkRenderer::overlayUploadComplete(void* opaque)
|
||||
{
|
||||
SDL_FreeSurface((SDL_Surface*)opaque);
|
||||
SDL_DestroySurface((SDL_Surface*)opaque);
|
||||
}
|
||||
|
||||
PlVkRenderer::PlVkRenderer(bool hwaccel, IFFmpegRenderer *backendRenderer) :
|
||||
@@ -362,7 +362,11 @@ bool PlVkRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
m_Window = params->window;
|
||||
|
||||
unsigned int instanceExtensionCount = 0;
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(&instanceExtensionCount, nullptr)) {
|
||||
#else
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(params->window, &instanceExtensionCount, nullptr)) {
|
||||
#endif
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_Vulkan_GetInstanceExtensions() #1 failed: %s",
|
||||
SDL_GetError());
|
||||
@@ -370,7 +374,11 @@ bool PlVkRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
}
|
||||
|
||||
std::vector<const char*> instanceExtensions(instanceExtensionCount);
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(&instanceExtensionCount, instanceExtensions.data())) {
|
||||
#else
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(params->window, &instanceExtensionCount, instanceExtensions.data())) {
|
||||
#endif
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_Vulkan_GetInstanceExtensions() #2 failed: %s",
|
||||
SDL_GetError());
|
||||
@@ -402,7 +410,11 @@ bool PlVkRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
POPULATE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR);
|
||||
POPULATE_FUNCTION(vkEnumerateDeviceExtensionProperties);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
if (!SDL_Vulkan_CreateSurface(params->window, m_PlVkInstance->instance, NULL, &m_VkSurface)) {
|
||||
#else
|
||||
if (!SDL_Vulkan_CreateSurface(params->window, m_PlVkInstance->instance, &m_VkSurface)) {
|
||||
#endif
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_Vulkan_CreateSurface() failed: %s",
|
||||
SDL_GetError());
|
||||
@@ -703,7 +715,7 @@ void PlVkRenderer::waitToRender()
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"GPU is in failed state. Recreating renderer.");
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
event.type = SDL_EVENT_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
@@ -721,7 +733,11 @@ void PlVkRenderer::waitToRender()
|
||||
|
||||
// Handle the swapchain being resized
|
||||
int vkDrawableW, vkDrawableH;
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
SDL_GetWindowSizeInPixels(m_Window, &vkDrawableW, &vkDrawableH);
|
||||
#else
|
||||
SDL_Vulkan_GetDrawableSize(m_Window, &vkDrawableW, &vkDrawableH);
|
||||
#endif
|
||||
if (!pl_swapchain_resize(m_Swapchain, &vkDrawableW, &vkDrawableH)) {
|
||||
// Swapchain (re)creation can fail if the window is occluded
|
||||
return;
|
||||
@@ -905,12 +921,12 @@ void PlVkRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_AtomicLock(&m_OverlayLock);
|
||||
SDL_LockSpinlock(&m_OverlayLock);
|
||||
// We want to clear the staging overlay flag even if a staging overlay is still present,
|
||||
// since this ensures the render thread will not read from a partially initialized pl_tex
|
||||
// as we modify or recreate the staging overlay texture outside the overlay lock.
|
||||
m_Overlays[type].hasStagingOverlay = false;
|
||||
SDL_AtomicUnlock(&m_OverlayLock);
|
||||
SDL_UnlockSpinlock(&m_OverlayLock);
|
||||
|
||||
// If there's no new staging overlay, free the old staging overlay texture.
|
||||
// NB: This is safe to do outside the overlay lock because we're guaranteed
|
||||
@@ -925,7 +941,7 @@ void PlVkRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
SDL_assert(newSurface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
pl_fmt texFormat = pl_find_named_fmt(m_Vulkan->gpu, "bgra8");
|
||||
if (!texFormat) {
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"pl_find_named_fmt(bgra8) failed");
|
||||
return;
|
||||
@@ -945,7 +961,7 @@ void PlVkRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
if (!pl_tex_recreate(m_Vulkan->gpu, &m_Overlays[type].stagingOverlay.tex, &texParams)) {
|
||||
pl_tex_destroy(m_Vulkan->gpu, &m_Overlays[type].stagingOverlay.tex);
|
||||
SDL_zero(m_Overlays[type].stagingOverlay);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"pl_tex_recreate() failed");
|
||||
return;
|
||||
@@ -962,7 +978,7 @@ void PlVkRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
if (!pl_tex_upload(m_Vulkan->gpu, &xferParams)) {
|
||||
pl_tex_destroy(m_Vulkan->gpu, &m_Overlays[type].stagingOverlay.tex);
|
||||
SDL_zero(m_Overlays[type].stagingOverlay);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"pl_tex_upload() failed");
|
||||
return;
|
||||
@@ -978,10 +994,10 @@ void PlVkRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
m_Overlays[type].stagingOverlay.color = pl_color_space_srgb;
|
||||
|
||||
// Make this staging overlay visible to the render thread
|
||||
SDL_AtomicLock(&m_OverlayLock);
|
||||
SDL_LockSpinlock(&m_OverlayLock);
|
||||
SDL_assert(!m_Overlays[type].hasStagingOverlay);
|
||||
m_Overlays[type].hasStagingOverlay = true;
|
||||
SDL_AtomicUnlock(&m_OverlayLock);
|
||||
SDL_UnlockSpinlock(&m_OverlayLock);
|
||||
}
|
||||
|
||||
bool PlVkRenderer::notifyWindowChanged(PWINDOW_STATE_CHANGE_INFO info)
|
||||
|
||||
@@ -169,7 +169,7 @@ bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
SDL_SetHintWithPriority(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, "1", SDL_HINT_OVERRIDE);
|
||||
#endif
|
||||
|
||||
m_Renderer = SDL_CreateRenderer(params->window, -1, rendererFlags);
|
||||
m_Renderer = SDL_CreateRenderer(params->window, SDLC_DEFAULT_RENDER_DRIVER, rendererFlags);
|
||||
if (!m_Renderer) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_CreateRenderer() failed: %s",
|
||||
@@ -221,7 +221,7 @@ void SdlRenderer::renderOverlay(Overlay::OverlayType type)
|
||||
if (type == Overlay::OverlayStatusUpdate) {
|
||||
// Bottom Left
|
||||
SDL_Rect viewportRect;
|
||||
SDL_RenderGetViewport(m_Renderer, &viewportRect);
|
||||
SDL_GetRenderViewport(m_Renderer, &viewportRect);
|
||||
m_OverlayRects[type].x = 0;
|
||||
m_OverlayRects[type].y = viewportRect.h - newSurface->h;
|
||||
}
|
||||
@@ -235,12 +235,12 @@ void SdlRenderer::renderOverlay(Overlay::OverlayType type)
|
||||
m_OverlayRects[type].h = newSurface->h;
|
||||
|
||||
m_OverlayTextures[type] = SDL_CreateTextureFromSurface(m_Renderer, newSurface);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
}
|
||||
|
||||
// If we have an overlay texture, render it too
|
||||
if (m_OverlayTextures[type] != nullptr) {
|
||||
SDL_RenderCopy(m_Renderer, m_OverlayTextures[type], nullptr, &m_OverlayRects[type]);
|
||||
SDL_RenderTexture(m_Renderer, m_OverlayTextures[type], nullptr, &m_OverlayRects[type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,7 +659,7 @@ void VAAPIRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
}
|
||||
|
||||
if (!overlayEnabled) {
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -673,7 +673,7 @@ void VAAPIRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"vaCreateImage() failed: %d",
|
||||
status);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ void VAAPIRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"vaMapBuffer() failed: %d",
|
||||
status);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
vaDestroyImage(vaDeviceContext->display, newImage.image_id);
|
||||
return;
|
||||
}
|
||||
@@ -698,7 +698,7 @@ void VAAPIRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"vaUnmapBuffer() failed: %d",
|
||||
status);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
vaDestroyImage(vaDeviceContext->display, newImage.image_id);
|
||||
return;
|
||||
}
|
||||
@@ -720,7 +720,7 @@ void VAAPIRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
overlayRect.h = newSurface->h;
|
||||
|
||||
// Surface data is no longer needed
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
|
||||
VASubpictureID newSubpicture;
|
||||
status = vaCreateSubpicture(vaDeviceContext->display, newImage.image_id, &newSubpicture);
|
||||
|
||||
@@ -374,7 +374,7 @@ void VDPAURenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
}
|
||||
|
||||
if (!overlayEnabled) {
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ void VDPAURenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"VdpBitmapSurfaceCreate() failed: %s",
|
||||
m_VdpGetErrorString(status));
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ void VDPAURenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
"VdpBitmapSurfacePutBitsNative() failed: %s",
|
||||
m_VdpGetErrorString(status));
|
||||
m_VdpBitmapSurfaceDestroy(newBitmapSurface);
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ void VDPAURenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
overlayRect.y1 = overlayRect.y0 + newSurface->h;
|
||||
|
||||
// Surface data is no longer needed
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
|
||||
SDL_LockMutex(m_OverlayMutex);
|
||||
m_OverlaySurface[type] = newBitmapSurface;
|
||||
@@ -467,7 +467,7 @@ void VDPAURenderer::renderOverlay(VdpOutputSurface destination, Overlay::Overlay
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_TryLockMutex(m_OverlayMutex) != 0) {
|
||||
if (!SDL_TryLockMutex(m_OverlayMutex)) {
|
||||
// If the overlay is currently being updated, skip rendering it this frame.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ int FFmpegVideoDecoder::getDecoderCapabilities()
|
||||
|
||||
if (!isHardwareAccelerated()) {
|
||||
// Slice up to 4 times for parallel CPU decoding, once slice per core
|
||||
int slices = qMin(MAX_SLICES, SDL_GetCPUCount());
|
||||
int slices = qMin(MAX_SLICES, SDL_GetNumLogicalCPUCores());
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Encoder configured for %d slices per frame",
|
||||
slices);
|
||||
@@ -269,10 +269,10 @@ void FFmpegVideoDecoder::reset()
|
||||
// Terminate the decoder thread before doing anything else.
|
||||
// It might be touching things we're about to free.
|
||||
if (m_DecoderThread != nullptr) {
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 1);
|
||||
LiWakeWaitForVideoFrame();
|
||||
SDL_WaitThread(m_DecoderThread, NULL);
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 0);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 0);
|
||||
m_DecoderThread = nullptr;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ bool FFmpegVideoDecoder::completeInitialization(const AVCodec* decoder, enum AVP
|
||||
// Enable slice multi-threading for software decoding
|
||||
if (!isHardwareAccelerated()) {
|
||||
m_VideoDecoderCtx->thread_type = FF_THREAD_SLICE;
|
||||
m_VideoDecoderCtx->thread_count = qMin(MAX_SLICES, SDL_GetCPUCount());
|
||||
m_VideoDecoderCtx->thread_count = qMin(MAX_SLICES, SDL_GetNumLogicalCPUCores());
|
||||
}
|
||||
else {
|
||||
// No threading for HW decode
|
||||
@@ -1608,7 +1608,7 @@ int FFmpegVideoDecoder::decoderThreadProcThunk(void *context)
|
||||
|
||||
void FFmpegVideoDecoder::decoderThreadProc()
|
||||
{
|
||||
while (!SDL_AtomicGet(&m_DecoderThreadShouldQuit)) {
|
||||
while (!SDL_GetAtomicInt(&m_DecoderThreadShouldQuit)) {
|
||||
if (m_FramesIn == m_FramesOut) {
|
||||
VIDEO_FRAME_HANDLE handle;
|
||||
PDECODE_UNIT du;
|
||||
@@ -1736,18 +1736,18 @@ void FFmpegVideoDecoder::decoderThreadProc()
|
||||
"Resetting decoder due to consistent failure");
|
||||
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
event.type = SDL_EVENT_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
// Don't consume any additional data
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 1);
|
||||
}
|
||||
|
||||
// Just in case the error resulted in the loss of the frame,
|
||||
// request an IDR frame to reset our decoder state.
|
||||
LiRequestIdrFrame();
|
||||
}
|
||||
} while (err == AVERROR(EAGAIN) && !SDL_AtomicGet(&m_DecoderThreadShouldQuit));
|
||||
} while (err == AVERROR(EAGAIN) && !SDL_GetAtomicInt(&m_DecoderThreadShouldQuit));
|
||||
|
||||
if (err != 0) {
|
||||
// Free the frame if we failed to submit it
|
||||
@@ -1862,11 +1862,11 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
"Resetting decoder due to consistent failure");
|
||||
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_DEVICE_RESET;
|
||||
event.type = SDL_EVENT_RENDER_DEVICE_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
// Don't consume any additional data
|
||||
SDL_AtomicSet(&m_DecoderThreadShouldQuit, 1);
|
||||
SDL_SetAtomicInt(&m_DecoderThreadShouldQuit, 1);
|
||||
}
|
||||
|
||||
return DR_NEED_IDR;
|
||||
|
||||
@@ -133,7 +133,7 @@ void OverlayManager::notifyOverlayUpdated(OverlayType type)
|
||||
}
|
||||
|
||||
// m_FontData must stay around until the font is closed
|
||||
m_Overlays[type].font = TTF_OpenFontRW(SDL_RWFromConstMem(m_FontData.constData(), m_FontData.size()),
|
||||
m_Overlays[type].font = TTF_OpenFontRW(SDL_IOFromConstMem(m_FontData.constData(), m_FontData.size()),
|
||||
1,
|
||||
m_Overlays[type].fontSize);
|
||||
if (m_Overlays[type].font == nullptr) {
|
||||
@@ -146,11 +146,11 @@ void OverlayManager::notifyOverlayUpdated(OverlayType type)
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface* oldSurface = (SDL_Surface*)SDL_AtomicSetPtr((void**)&m_Overlays[type].surface, nullptr);
|
||||
SDL_Surface* oldSurface = (SDL_Surface*) SDL_SetAtomicPointer((void**)&m_Overlays[type].surface, nullptr);
|
||||
|
||||
// Free the old surface
|
||||
if (oldSurface != nullptr) {
|
||||
SDL_FreeSurface(oldSurface);
|
||||
SDL_DestroySurface(oldSurface);
|
||||
}
|
||||
|
||||
if (m_Overlays[type].enabled) {
|
||||
@@ -159,7 +159,7 @@ void OverlayManager::notifyOverlayUpdated(OverlayType type)
|
||||
m_Overlays[type].text,
|
||||
m_Overlays[type].color,
|
||||
1024);
|
||||
SDL_AtomicSetPtr((void**)&m_Overlays[type].surface, surface);
|
||||
SDL_SetAtomicPointer((void**)&m_Overlays[type].surface, surface);
|
||||
}
|
||||
|
||||
// Notify the renderer
|
||||
|
||||
@@ -195,7 +195,7 @@ void SLVideoDecoder::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
}
|
||||
|
||||
if (!overlayEnabled) {
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ void SLVideoDecoder::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
if (m_Overlay == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SLVideo_CreateOverlay() failed");
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void SLVideoDecoder::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
SLVideo_SetOverlayDisplayArea(m_Overlay, 0.0f, 1.0f - flHeight, flWidth, flHeight);
|
||||
|
||||
// We're done with the surface now
|
||||
SDL_FreeSurface(newSurface);
|
||||
SDL_DestroySurface(newSurface);
|
||||
|
||||
// Show the overlay
|
||||
SLVideo_ShowOverlay(m_Overlay);
|
||||
|
||||
Reference in New Issue
Block a user