Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectShow Init

This topic is 6099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Inspired by one of the DirectX samples I descided to add some mp3 sound to my game. After some problems I finally got my class compiled and linked, but does it work? NO. The problem lies in the coCreateIntance call to create the main GraphBuilder. When my game runs this code it fails: if (FAILED( hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, reinterpret_cast(&m_GraphBuilder)))) or if (FAILED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,IID_IGraphBuilder, (void **)&m_GraphBuilder))) This code is in a class that is called/created in my game, can this be the error? if yes, how sould I do it? Thanks all. Let me know if you want me to post more code. Endre

Share this post


Link to post
Share on other sites
Advertisement
What error code is returned? Maybe DirectShow8 isn''t installed or properly registered on your PC? The pointer, m_GraphBuilder needs to be null...

  
CComPtr<IGraphBuilder> m_spGraphBuilder;
CComPtr<IMediaControl> m_spMediaControl;

TESTHR(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void**)&m_spGraphBuilder));
TESTHR(m_spGraphBuilder->QueryInterface(IID_IMediaControl, (void**)&m_spMediaControl));

//This is all it should take to play an mp3

_bstr_t bstrFilename_ = L"blah.mp3";
TESTHR(m_spGraphBuilder->RenderFile(bstrFilename_, NULL));
TESTHR(m_spMediaControl->Run());


Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Thanks for trying, but DirectShow is installed properly. I can compile and run all the examples.

I have some trouble with the debuging. I''m not very experienced in c++ yet, and don''t knw how I sould get the error code og HRESULT out. Any sugestions? Should I write it to a file or is there a command to write to the debug window when something happends?


Thanks again


Endre

Share this post


Link to post
Share on other sites
Oh yeah, here''s my TESTHR macro:

  
#ifdef _DEBUG
#define TESTHR(Test_) \
if(S_OK!=(hr=Test_))\
{\
char szError[256];\
if(FAILED(hr))\
{\
sprintf(szError, "FAILED 0x%x\n%s\nOn line %i in %s\n\0", hr, #Test_, __LINE__, __FILE__);\
OutputDebugString("*****************\n");\
OutputDebugString(szError);\
OutputDebugString("*****************\n");\
return(hr);\
}\
else\
{\
sprintf(szError, "WARNING 0x%x\n%s\nOn line %i in %s\n\0", hr, #Test_, __LINE__, __FILE__);\
OutputDebugString("*****************\n");\
OutputDebugString(szError);\
OutputDebugString("*****************\n");\
}\
}
#else
#define TESTHR(Test_) if(FAILED(hr=Test_)) return(hr);
#endif


OutputDebugString will spew stuff to the watch window of the debugger in you''re running in the environment, OR it will spew stuff to a connected Windbg machine (you use a null modem cable) if you run Windows in debug mode.



Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Hello again, and thanks Magmai Kai Holmlor for the code.

I still don''t know whats wrong, but I get the following error no. 0x80070057

If I do a search for this in the help file, it only returns something for DirectMusic and DirectSound.

The error code is one of the following:
E_FAIL
E_INVALIDARG
or E_INVALIDPARAM

So my guess is that since this is in a separate class, I need to do something with the IGraphBuilder object before the CoCreateInstance call, but I don''t know what?

I have the members I need (like m_GraphBuilder) in an .h file. Here I can''t set the object to NULL. If I do my compiler wont compile the game.
If I create the GraphBuilder object in the function, everything works fine, but then I can''t access the object for other functions. Any Idee?
I''m pretty sure this is a result of my lacking C++ skills and not a DirectX problem.

Well, thanks again

Endre

Share this post


Link to post
Share on other sites
To Magmai Kai Holmlor and everybody else.

I''ve found the problem. I had not used the _new_ keyword when declearing the class in my game.

I''m sorry for wasting your time but thanks for trying to help out. Thanks to this problem I''ve leanr new things about debuging and macros.


Endre

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!