Skip to content
Permalink
Browse files

Android: minor preparation for bug 4142 (concurrency issues)

  • Loading branch information
1bsyl committed Jan 3, 2019
1 parent 5dc25fe commit d11f7615fa4da05b554361c9f0c1035b888c5ae3
Showing with 15 additions and 10 deletions.
  1. +15 −10 src/video/android/SDL_androidwindow.c
@@ -40,9 +40,11 @@ int
Android_CreateWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data;
int retval = 0;

if (Android_Window) {
return SDL_SetError("Android only supports one window");
retval = SDL_SetError("Android only supports one window");
goto endfunction;
}

Android_PauseSem = SDL_CreateSemaphore(0);
@@ -68,14 +70,16 @@ Android_CreateWindow(_THIS, SDL_Window * window)

data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
if (!data) {
return SDL_OutOfMemory();
retval = SDL_OutOfMemory();
goto endfunction;
}

data->native_window = Android_JNI_GetNativeWindow();

if (!data->native_window) {
SDL_free(data);
return SDL_SetError("Could not fetch native window");
retval = SDL_SetError("Could not fetch native window");
goto endfunction;
}

/* Do not create EGLSurface for Vulkan window since it will then make the window
@@ -86,14 +90,17 @@ Android_CreateWindow(_THIS, SDL_Window * window)
if (data->egl_surface == EGL_NO_SURFACE) {
ANativeWindow_release(data->native_window);
SDL_free(data);
return SDL_SetError("Could not create GLES window surface");
retval = SDL_SetError("Could not create GLES window surface");
goto endfunction;
}
}

window->driverdata = data;
Android_Window = window;

endfunction:

return 0;
return retval;
}

void
@@ -139,18 +146,16 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display

void
Android_DestroyWindow(_THIS, SDL_Window *window)
{
SDL_WindowData *data;

{
if (window == Android_Window) {
Android_Window = NULL;
if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem);
if (Android_ResumeSem) SDL_DestroySemaphore(Android_ResumeSem);
Android_PauseSem = NULL;
Android_ResumeSem = NULL;

if(window->driverdata) {
data = (SDL_WindowData *) window->driverdata;
if (window->driverdata) {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}

0 comments on commit d11f761

Please sign in to comment.