Your opinion on returning s_false from imediacontrol: Run ()

Source: Internet
Author: User

During this time, I learned about DirectShow and wrote some weird code. When I learned how to collect audio in the past few days, I encountered this problem again.

When my program runs the imediacontrol: Run () function, s_false is returned every time. I think many people will certainly encounter this problem, but it sometimes does not affect the running of our program. This is why. Let's take a look at what msdn says.

TheRunMethod runs all the filters in the filter graph. While the graph is running, data moves through he graph and is rendered.

 

It can be seen from the above that sometimes it returns s_false because some filters have not changed to the running status, and may be in the running status after a period of time, this may not affect the running of our program.

To prove my understanding, I did the following experiments. Let's take a look at some comments on msdn about the returned s_false by the imediacontrol: Run () function.

If the return value is s_false, you can wait for the transition to complete by callingImediacontrol: getstateMethod. If the method fails, some filters might be in a running state. In a multistream graph, entire streams might be playing successfully. The application must determine whether to stop the graph.

So I made some modifications to my code, as shown below:

Hresult augraph: audiorun ()

{

Hresult hR = noerror;

If (m_pmc)

{

OA filterstate PFS;

HR = m_pmc-> getstate (100, & PFS); // before testing run

 

HR = m_pmc-> Run ();

 

HR = m_pmc-> getstate (100, & PFS); // after the test run

 

If (s_false = HR)

{

....

Return hr;

}

M_biscapture = true;

}

Return hr;

}

 

The test results are as follows:

After hR = m_pmc-> getstate (100, & PFS) is executed for the first time, s_ OK is returned. The PFS value is 0, it indicates that all our filters are in the stopped state (for the significance of PFS value and the usage of getstate (), you can view msdn on your own ).

After hR = m_pmc-> getstate (100, & PFS) is executed for the second time, s_ OK is returned. The PFS value is 2, indicating that all filters are in the running state.

Therefore, we can see from the above test results that sometimes it returns s_false without affecting the running of our program. However, this cannot be too absolute. You need to take a specific look at the problem.

Of course, why does my code look like this? I will share it with you after I find the reason.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.