IWantKnowWhy 96 Reputation points

I previously edited a simple video playback function
video () ;
this function was originally no problem, can run properly,
until the use of
int main()
std: : Thread t (video) ;
return 0;

concurrent opened video () function, one window is normal, another white screen, maximize the white screen will get a full screen shot, can be moved, resize, cropped parts will become black screen. Even back to single-threaded, the first renderfile created by the video player is also bound to white screen. I could really use some help
void video()
pGraph->RenderFile(L"D:\Downloads\movie.avi", NULL);//WHITE SCREEN
pGraph->RenderFile(L"D:\Downloads\movie1.avi", NULL);//normal
pGraph->RenderFile(L"D:\Downloads\movie2.avi", NULL);//normal
pCtrl->Run();//create 3 windows for play;

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,448 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,562 questions
{count} votes

Accepted answer
  1. IWantKnowWhy 96 Reputation points

    Thank you for your reply.

    I reinstalled the system and fixed the bug. In order to reproduce this bug, I built a virtual machine of windows 10.

    Test record

    Test 1: single thread, normal operation, simple program

    Test 2: dual thread, normal operation, simple program

    Test 3: single thread, normal operation, simple program

    It proves that the source of the bug does not start a simple video player for multithreading.

    Sorry, this is my misunderstanding of the cause of the bug.

    Therefore, I further tried to reproduce the bug with the original video player.

    The header file of EasyX. H is attached

    Test 4: single thread, normal operation, original program

    Test 5: dual thread, simple program and original program. normal operation

    Test 6: single thread, original program, normal operation

    Test 7: dual thread, original program, normal operation

    Test 8: single thread, original program, normal operation

    Test 9: single thread, simple program, normal operation

    Test 10: single thread, enable render (PIN) of the original program, and display normally

    Test 11: dual thread, one side of the simple program, one side of the original program, normal operation.

    Test 12: dual thread, original program, normal operation.

    Test 13: single thread, the original program, enable render and renderfile at the same time, and run normally

    Test 14: dual thread, the original program, renderfile are all displayed normally, and render is displayed normally

    Test 15: single thread, simple program, normal operation.

    After several possible tests, sorry, I can't reproduce the bug in the virtual machine at present.

    The only details I can provide now:

    During the existence of the bug, the playback task of calling renderfile or render for the first time will not play the picture, but the subsequent playback tasks will display normally,

    The exception window created by renderfile will occur when the window is moved in debug mode

    Nvd3dum. H (x86) / nvd3dumx. H (x64) / access conflict exception of c0000005 accessing 00000000 (1player only) / 0000011e (when2players) / 0000000000000000 (x64) / at position.

    This problem may be a bug caused by a system error with a small probability. I would appreciate it if someone could explain it in detail. All tests are run on the virtual machine, which may be different from the physical host.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,581 Reputation points Microsoft Vendor

    After running the following code based on the code, I cannot reproduce it.

    #include <iostream>
    #include <windows.h>
    #include <Dshow.h>
    #include <thread>
    //#include "qedit.h"
    //#include "atlbase.h"
    using namespace std;
    void main1()
     int option;
        IGraphBuilder *pGraph = NULL;  //Creem l'apuntador al graf de filtres
     IMediaControl *pControl = NULL; //creem l'apuntador a un controlador per ayurar i iniciar el graf 
     IMediaEvent *pEvent = NULL; // apunta a l'objecte necessari per obtenir events del filter graph manager
     //IBaseFilter *pGrabberF = NULL;
        //ISampleGrabber *pGrabber = NULL;
     HRESULT hr = CoInitialize(NULL); // Inicialitzem la llibreria COM
     if ( FAILED(hr) ){
     printf("ERROR - Could not initialize COM library");
     // Create the filter graph manager and query for interfaces.
        hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
        if (FAILED(hr))
            printf("ERROR - Could not create the Filter Graph Manager.");
        hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
        hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
        // Build the graph. IMPORTANT: Change this string to a file on your system.
     cout<<"introduce 1:chicken 2:futbol 3: video futbol audio chicken: \n";
     case 1: hr = pGraph->RenderFile(L"C:\\Users\\Downloads\\file_example.avi", NULL);
     case 2: hr = pGraph->RenderFile(L"C:\\Users\\Downloads\\futbol.mpg", NULL);
     case 3:  // Create the Sample Grabber filter.
        if (SUCCEEDED(hr))
            // Run the graph.
            hr = pControl->Run();
            if (SUCCEEDED(hr))
                // Wait for completion.
                long evCode;
                pEvent->WaitForCompletion(INFINITE, &evCode);
                // Note: Do not use INFINITE in a real application, because it
                // can block indefinitely.
    void main()
        thread t(main1);
    0 comments No comments