Re: DirectShow Insanity

From: Phil Taylor (phil_at_private-citizen.com)
Date: 01/21/05


Date: Thu, 20 Jan 2005 20:07:38 -0800


"Roulette" <Roulette@Roulette.com> wrote in message
news:uOVP5N1$EHA.2608@TK2MSFTNGP10.phx.gbl...
> I definitely appreciate the desire to help, but I am repeating myself
> on much of this information.
>
> If "test.wma" were not being found, then it wouldn't be playing any
> music (which I stated is happening.) Also as mentioned, the entire song
> plays in the full application, I get my callback as expected when the
> music finishes (at which point I reset the pointer to loop the music),
> etc.. Hence, it is not "only fail(ing) in this little test app." I built
> this little test application to demonstrate the problem happening in the
> full application.
>
> My response to your first email already stated that "No error is
> returned from pMediaControl->Run()" - I'm therefore unsure why you are
> again asking, "Is there a non-error return code othen than S_OK returned
> from Run()."

sometimes the FAILED macro does not detect a non-failure return code.

its a simple question.

>
> One of the first things I tried with this problem was turning the debug
> level to the highest setting - 5. No more information was returned.
>
> I obviously get that a NULL pointer is being accessed, but it's not in
> my code.
>
> I compiled the DirectShow Jukebox SDK example and noticed that it also
> generates a number of identical error messages for different sample media
> provided by Microsoft. This lends further credence to the theory that
> this is simply normal behavior (albeit bizarre) for DirectShow. I simply
> built the Jukebox demo program (with the Windows Media Player 10 SDK) and
> started clicking on the sample media displayed...some of them generate
> exceptions exactly as I'm seeing in my test application...other ones do
> not.
>
> - Roulette
>
>
> "Phil Taylor" <phil@private-citizen.com> wrote in message
> news:Opl0Yi0$EHA.3708@TK2MSFTNGP14.phx.gbl...
>> its a strange one, but since it only fails in this little test app, it
>> must be something that is being done differently.
>>
>> does it vary based on the file chosen? is "test.wma" really being found?
>> what about other formats?
>>
>> is there a non-error return code other than S_OK returned from Run()?
>>
>> what if you turn debug level on high ( 5 ) is more information returned?
>> somewhere there is a null pointer...
>>
>> "Roulette" <Roulette@Roulette.com> wrote in message
>> news:%234W$cA0$EHA.2600@TK2MSFTNGP09.phx.gbl...
>>> The exception happens immediately upon executing the
>>> "pMediaControl->Run()" line...hence, waiting for completion of the
>>> program would not affect it. (In addition, as mentioned, the normal
>>> application that executes this code does not terminate...it later
>>> receives a callback when it's time to reset the pointer to loop the
>>> music, etc..)
>>>
>>> No error is returned from pMediaControl->Run().
>>>
>>> The specific debug message seen is: "First-chance exception at
>>> 0x086c9324 in Test.exe 0xC0000005: Access violation writing location
>>> 0x00000000." Four of these messages are displayed - all at once when
>>> pMediaControl->Run() is called - with different addresses (the first
>>> hexadecimal value.) The other information remains the same in each
>>> message.
>>>
>>> - Roulette
>>>
>>> "Phil Taylor" <phil@private-citizen.com> wrote in message
>>> news:usbUC3x$EHA.3120@TK2MSFTNGP12.phx.gbl...
>>>> and what exactly is shown in the debug output window?
>>>>
>>>> what is the return value from MediaControl->Run?
>>>>
>>>> what happens if you wait for completion befor exiting the program?
>>>>
>>>> some operations require the thread that started to remain alive until
>>>> the operation completes. the sample code does this, so perhaps thats
>>>> the issue.
>>>>
>>>> "Roulette" <Roulette@Roulette.com> wrote in message
>>>> news:%23UoVy5p$EHA.1408@TK2MSFTNGP10.phx.gbl...
>>>>> Can someone tell me why the following small snippet of DirectShow
>>>>> code causes a number of "First-chance exception"s to occur? The code
>>>>> actually seems to work fine - the music plays for a couple of seconds
>>>>> before exiting. In the full application, the music plays fine, I
>>>>> receive a callback (after setting it up) and reset the music to loop
>>>>> when its finished, etc..
>>>>>
>>>>> In other words...as far as I can tell on my machine, the code
>>>>> works exactly like it should, but those exceptions (that you can see
>>>>> in the Debug window when running the program from MSDEV) are making me
>>>>> worry that there might be a problem on some other machine.
>>>>>
>>>>> Thanks in advance for any help....
>>>>>
>>>>> - Roulette
>>>>>
>>>>>
>>>>>
>>>>> int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR
>>>>> lpcmdline,int ncmdshow)
>>>>> {
>>>>> // No clean-up is done since this code is just demonstrating a
>>>>> problem.
>>>>>
>>>>> CoInitialize(NULL);
>>>>> IGraphBuilder *pGraph=NULL;
>>>>> IMediaControl *pMediaControl=NULL;
>>>>> const char *filename="Test.wma";
>>>>>
>>>>> HRESULT
>>>>> returnValue=CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder,(void
>>>>> **)&pGraph);
>>>>>
>>>>> if (FAILED(returnValue))
>>>>> return 0;
>>>>>
>>>>> if (pGraph)
>>>>> {
>>>>> pGraph->QueryInterface(IID_IMediaControl,(void **)&pMediaControl);
>>>>>
>>>>> if (pMediaControl)
>>>>> {
>>>>> WCHAR *wfile;
>>>>> int length;
>>>>> length=strlen(filename)+1;
>>>>> wfile=new WCHAR[length];
>>>>> MultiByteToWideChar(CP_ACP,0,filename,-1,wfile,length);
>>>>>
>>>>> returnValue=pGraph->RenderFile(wfile,NULL);
>>>>>
>>>>> if (FAILED(returnValue))
>>>>> return 0;
>>>>>
>>>>> pMediaControl->Run(); // This line causes several exceptions to
>>>>> occur - you can see the debug output when running in MSDEV.
>>>>>
>>>>> Sleep(2000); // Give the music a chance to play for a couple of
>>>>> seconds before exiting the program.
>>>>> }
>>>>> }
>>>>>
>>>>> return 0;
>>>>> }
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>