static void DISPMANX_VideoQuit(_THIS) { /* Clear the lock mutex */ if ( hw_lock ) { SDL_DestroyMutex(hw_lock); hw_lock = NULL; } if (dispvars->pixmem != NULL){ int i; for (i=0; i < NUM_MODELISTS; ++i){ free(SDL_modelist[i]); SDL_modelist[i] = NULL; SDL_nummodes[i] = 0; } DISPMANX_FreeResources(); DISPMANX_FreeBackground(); vc_dispmanx_display_close( dispvars->display ); bcm_host_deinit(); } DISPMANX_CloseMouse(this); DISPMANX_CloseKeyboard(this); //MAC Set custom video mode block 2 //Reestablecemos el modo de video original /*if (dispvars->isResChanged){ int ret = vc_tv_hdmi_power_on_explicit_new(HDMI_MODE_HDMI, dispvars->original_tv_state->display.hdmi.group, dispvars->original_tv_state->display.hdmi.mode); printf ("\nRestaurando modo original...%s\n", ret == 0 ? "OK " : "FALLO"); }*/ #ifdef debug_mode fclose (fp); #endif exit (0); }
static void DISPMANX_VideoQuit(_THIS) { int i,j; if ( this->screen ) { /* Clear screen and tell SDL not to free the pixels */ const char *dontClearPixels = SDL_getenv("SDL_FBCON_DONT_CLEAR"); //En este caso sí tenemos que limpiar el framebuffer if ( !dontClearPixels && this->screen->pixels && DISPMANX_InGraphicsMode(this) ) { #if defined(__powerpc__) || defined(__ia64__) /* SIGBUS when using SDL_memset() ?? */ Uint8 *rowp = (Uint8 *)this->screen->pixels; int left = this->screen->pitch*this->screen->h; while ( left-- ) { *rowp++ = 0; } #else SDL_memset(this->screen->pixels,0, this->screen->h*this->screen->pitch); #endif } if ( ((char *)this->screen->pixels >= mapped_mem) && ( (char *)this->screen->pixels < (mapped_mem+mapped_memlen)) ) this->screen->pixels = NULL; } /* Clear the lock mutex */ if ( hw_lock ) { SDL_DestroyMutex(hw_lock); hw_lock = NULL; } /* Clean up defined video modes */ for ( i=0; i<NUM_MODELISTS; ++i ) { if ( SDL_modelist[i] != NULL ) { for ( j=0; SDL_modelist[i][j]; ++j ) { SDL_free(SDL_modelist[i][j]); } SDL_free(SDL_modelist[i]); SDL_modelist[i] = NULL; } } /* Clean up the memory bucket list */ DISPMANX_FreeHWSurfaces(this); /* Unmap the video framebuffer and I/O registers */ if ( mapped_mem ) { munmap(mapped_mem, mapped_memlen); mapped_mem = NULL; } if ( mapped_io ) { munmap(mapped_io, mapped_iolen); mapped_io = NULL; } //MAC liberamos lo relacionado con dispmanx printf ("\nDeleting dispmanx elements;\n"); dispvars->update = vc_dispmanx_update_start( 0 ); assert( dispvars->update ); vc_dispmanx_element_remove(dispvars->update, dispvars->element); vc_dispmanx_resource_delete( dispvars->resources[0] ); vc_dispmanx_resource_delete( dispvars->resources[1] ); vc_dispmanx_display_close( dispvars->display ); vc_dispmanx_update_submit_sync( dispvars->update ); bcm_host_deinit(); DISPMANX_CloseMouse(this); DISPMANX_CloseKeyboard(this); exit (0); }