Infognition forum
August 01, 2010, 06:51:18 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Last GraphEditPlus version: 1.4.0   Last Video Enhancer version: 1.9.3
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Generated C# Code Can't Enumerate Pins  (Read 1699 times)
taylorwilken
Newbie
*

Karma: +0/-0
Posts: 3


View Profile
« on: October 07, 2008, 07:42:20 PM »

Hi, I just purchased GraphEdit Plus, great product, btw!

I'm doing some testing putting together a TV tuner app, and I'm having problems with the generated code being able to enumerate the pins using DirectShowLib. I'm trying to run a pristine version of the generated code from GraphEdit. The graph runs perfectly in the GraphEdit Plus.

I'm using VS2005 and XP pro, all updated with current patches, etc., along with the latest DirectShowLib from sourceforge. The Tuner card is a Hauppage PVR-150, a pretty basic tuner card.

The relevant code where the problem is happening is here (in red):

static IPin GetPin(IBaseFilter filter, string pinname)
        {
            IEnumPins epins;
            int hr = filter.EnumPins(out epins);
            checkHR(hr, "Can't enumerate pins");
            IntPtr fetched = Marshal.AllocCoTaskMem(4);
            IPin[] pins = new IPin[1];
            while (epins.Next(1, pins, fetched) == 0)
            {
                PinInfo pinfo;
                pins[0].QueryPinInfo(out pinfo);
                bool found = (pinfo.name == pinname);
                DsUtils.FreePinInfo(pinfo);
                if (found)
                    return pins[0];
            }
            checkHR(-1, "Pin not found");
            return null;
        }

I've tried the thread.sleep fix mentioned in another post, to no avail, even with a sleep time of 10 seconds. I've also tried moving all pin connections to after all the filters have been added to the graph. Here's an example of a failing line:

            //connect Hauppauge WinTV PVR PCI II TvTuner and Hauppauge WinTV PVR PCI II Crossbar
            hr = pGraph.ConnectDirect(GetPin(pHauppaugeWinTVPVRPCIIITvTuner, "Analog Video"), GetPin(pHauppaugeWinTVPVRPCIIICrossbar, "0: Video Tuner In"), null);
            checkHR(hr, "Can't connect Hauppauge WinTV PVR PCI II TvTuner and Hauppauge WinTV PVR PCI II Crossbar");

Obviously, the above is failing with invalid pointers as the GetPin method is failing.

I've commented out the thrown exceptions so it can run through all the pin connections to see if it's just one pin that's failing, but every pin connect method is failing. No pins are able to be enumerated from any of the filters.

Is there something obvious I'm missing in my setup or install, or with my version of the direct show lib? I'm thinking the most likely culprit is some kind of COM interop compatibility issue between this code and the directshow library.

I wanted to see if I'm missing something obvious before I go and try to rework the GetPin method.

Has anyone else run into anything like this?
Logged
Dee Mon
Administrator
Sr. Member
*****

Karma: +7/-0
Posts: 271



View Profile WWW
« Reply #1 on: October 08, 2008, 11:32:59 PM »

That's weird.
What does highlighted method return? 0 means S_OK or NOERROR, that's why it's checked for 0 there, but probably it returns something different in your case.

What version of DirectShowLib do you use? Is it the same one used in GraphEditPlus?
Logged
taylorwilken
Newbie
*

Karma: +0/-0
Posts: 3


View Profile
« Reply #2 on: October 09, 2008, 12:28:16 AM »

I just checked that, it's returning a 1. I tried allowing a 1 or a 0, no go, pins[0] is then null.

Dshow Lib Version is 2.0 (v 2.0 - Upgrade with breaking changes (2007-07-15))

I've done some playing around with timings and the order of loading filters and connecting them. Sometimes it will work, but it only works for the first pin queried. It will then fail for all subsequent pin queries.

Thanks for being available for these questions!
Logged
Dee Mon
Administrator
Sr. Member
*****

Karma: +7/-0
Posts: 271



View Profile WWW
« Reply #3 on: October 09, 2008, 03:13:59 AM »

Is your Windows 64 bit? What is the build target then?

Try generating C++ code for the same graph, building it as native app and running. This will tell if the problem is .NET/COM Interop related or it's with filters and DirectShow itself.
Logged
taylorwilken
Newbie
*

Karma: +0/-0
Posts: 3


View Profile
« Reply #4 on: October 09, 2008, 09:06:56 PM »

I think I have it now. I tried it on a different machine, and it's working, so I think there's something screwy on my dev system. I've got several SDKs and have had 5 or 6 capture and tuner boards in there over the last few months, so I'm not all that surprised, and should have tried that sooner.

Thanks for all your help.

T
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!