[SDL] Renderer freeze when lock screen and login again

lbblscy lbblscy at gmail.com
Fri Jan 22 18:50:58 PST 2016


I'm using SDL-2.0.4 for rndering YUV frame, the program works fine except when lock the screen (Win+L) and login again.

The renderer type is direct3d, I guess when locking screen, the D3D device lost.

I'm trying to handle SDL_RENDER_DEVICE_RESET event, but it never triggered.

Sample codes:


Code:

    // Create window, renderer and texture
    m_sdl_window = SDL_CreateWindow("RTMP Player",
                                    SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                                    m_output_width, m_output_height,
                                    SDL_WINDOW_OPENGL);
    ...
    m_sdl_renderer = SDL_CreateRenderer(m_sdl_window, -1, 0);
    m_sdl_texture = SDL_CreateTexture(m_sdl_renderer,
                                      SDL_PIXELFORMAT_IYUV,
                                      SDL_TEXTUREACCESS_STREAMING,
                                      m_output_width,
                                      m_output_height);
    
    // Display yuv frame
    do {
        m_output_frame = try_to_get_a_frame(...)

        // Update texture
        ret = SDL_UpdateYUVTexture(m_sdl_texture, &m_sdl_rect,
                                   m_output_frame->data[0], m_output_frame->linesize[0],
                                   m_output_frame->data[1], m_output_frame->linesize[1],
                                   m_output_frame->data[2], m_output_frame->linesize[2]);
        if (0 != ret) {
            _error("SDL_UpdateYUVTexture failed! - err: %d", ret);
        }

        ret = SDL_RenderClear(m_sdl_renderer);
        if (0 != ret) {
            _error("SDL_RenderClear failed! - err: %d", ret);
        }

        ret = SDL_RenderCopy(m_sdl_renderer, m_sdl_texture, NULL, &m_sdl_rect);
        if (0 != ret) {
            _error("SDL_RenderCopy failed! - err: %d", ret);
        }

        SDL_RenderPresent(m_sdl_renderer);
    } while (1);






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20160123/feedb70e/attachment-0001.htm>


More information about the SDL mailing list