| Summary: | SDL_Create and SDL_Destroy | ||
|---|---|---|---|
| Product: | SDL | Reporter: | SweetLover <sweetloverft> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | CLOSED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | CC: | gabomdq, ngolbaz |
| Version: | 2.0.0 | ||
| Hardware: | x86 | ||
| OS: | Windows 7 | ||
|
Description
SweetLover
2014-01-26 10:11:01 UTC
Yesterday, I have submitted the MFC test project to you.
Now, detail Steps:
1.Initialize the SDL and FFMPEG decoding for video.
2.Create the window by calling[Detail]:
// Symbol "m_hWnd" is a static picture control handle in MFC
SDL_Window *win = SDL_CreateWindowFrom(m_hWnd);
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED |
SDL_RENDERER_TARGETTEXTURE);
// symbol "rect" is SDL_Rect.
SDL_Texture *tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, rect.w, rect.h);
3.Start decoding video thread, work well. SDL show the video.
4.SuspendThread decoding thread, release the window by calling[Detail]:
SDL_DestroyTexture(tex);
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
5.Then create the window again as step 2.
6.Resume decoding video thread, BUG: THE VIDEO DISAPPEARED! IT DISPLAYS NOTHING!
I hope that you can tell me the result whether it's my fault or not soon, thank you.
Can you post a test case to reproduce? (In reply to Gabriel Jacobo from comment #2) > Can you post a test case to reproduce? Unfortunately, I can write a minimal test case without MFC, but I cannot write it to reproduce the bug without video decoding, because the SDL cannot decode video, so I give the error code in following(I can make sure my video decoding works fine, it can display well by Windows GDI, I have tested it): RECT rt; SDL_Rect rect; HWND g_hWnd = GetDlgItem(IDC_PICTURE1)->m_hWnd; GetClientRect(g_hWnd, &rt); rect.x =0; rect.y =0; rect.w = rt.right - rt.left; rect.h = rt.bottom - rt.top; // Create it SDL_Window *win = SDL_CreateWindowFrom(g_hWnd); SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); SDL_Texture *tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, rect.w, rect.h); /* bug begin*/ // Release it SDL_DestroyTexture(tex); SDL_DestroyRenderer(ren); SDL_DestroyWindow(win); // Create it again win = SDL_CreateWindowFrom(g_hWnd); ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); tex = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, rect.w, rect.h); /* bug end */ // Display the video, but show blank /* ffmpeg decoding.. */ SDL_RenderClear(ren); SDL_UpdateTexture(tex, &rect, pFrameRGB->data[0], pFrameRGB->linesize[0]); SDL_RenderCopy(ren, tex, NULL, &rect); SDL_RenderPresent(ren); if delete code between "bug begin" and "bug end", the video display well, otherwise show blank. SDL_DestroyWindow hides the window. You should add SDL_ShowWindow after SDL_CreateWindowFrom. The user reported via email that the solution suggested by Nader Golbaz solves the issue. Thanks a lot. It's my fault that I forget to call SDL_ShowWindow after create it, the truth is that if you call SDL_Destroy, the windows will be hide, so we cannot see it after call SDL_Create again before function SDL_Destroy called. |