DxTuner audio with Hauppauge

Eric
2013-04-16
2013-04-17
  • Eric
    Eric
    2013-04-16

    Hello.
    I am modifying the DxTuner sample to make it play audio as well as video.

    The problem lies when I try to connect the pins with this code:

    //...
    hr = captureGraphBuilder.RenderStream(null, MediaType.Audio, theDevice, null, null);
    DsError.ThrowExceptionForHR(hr);
    //...
    
    tuner = null;
    crossbar = null;
    
    hr = captureGraphBuilder.FindInterface(null, null, theDevice, typeof(IAMTVTuner).GUID, out o);
    if (hr >= 0)
    {
        tuner = (IAMTVTuner)o;
        o = null;
    
        hr = captureGraphBuilder.FindInterface(null, null, theDevice, typeof(IAMCrossbar).GUID, out o);
        if (hr >= 0)
        {
            crossbar = (IBaseFilter)o;
            o = null;
        }
    
        IPin sourcePin, destPin, xPin;
        sourcePin = DsFindPin.ByName(crossbar,"1: Audio Decoder Out" );//
        destPin = DsFindPin.ByName(crossbar, "5: Audio Tuner In");
        hr = sourcePin.Disconnect();
        hr = sourcePin.Connect(destPin, null);//returns error code: The filter graph is circular.
        DsError.ThrowExceptionForHR(hr);
    }
    

    I can get the control to have audio when the crossbar option link related streams is checked. This must be done with node but I have tried connecting combinations of pins and always get "The filter graph is circular."

    I based the code off this thread:

    https://sourceforge.net/p/directshownet/discussion/460697/thread/a3242cd4/

    How can I "link related streams" using code?

    These are the available pins:

    Input:
    -1: Mute In
    0: Video Tuner In
    (0-4 are irrelevant e.g svideo)
    5: Audio Tuner In
    6: Audio Line In
    7: Audio Line In

    Output:
    0: Video Decoder Out
    1: Audio Decoder Out

    I am not well versed in video programming. Any insight is greatly appreciated.
    As a sign of gratitude, I'll gift any of this steam games to whoever successfully helps me get the audio working: borderlands 2, worms revolution, serious sam 2 or iron brigade.

    Thanks and have a nice day.

     
  • snarfle
    snarfle
    2013-04-17

    You are trying to connect the output pins of a filter to it's own input pins. That's the most extreme possible example of a circular graph, which (as you have seen) is an error.

    I will say to you the same things I said last time:

    What about capturetest (http://www.LimeGreenSocks.com/DShow)?
    If you wish to continue using your current code, you should use IAMCrossbar.Route. See the docs (http://msdn.microsoft.com/en-us/library/windows/desktop/dd389171%28v=vs.85%29.aspx).

     
  • Eric
    Eric
    2013-04-17

    OK, got it working using some code from the Capture test you suggested. It's a dirty hack but it will suffice for this exercise.

    //...
    
    if (hr >= 0)
    {
        tuner = (IAMTVTuner)o;
        o = null;
    
        hr = captureGraphBuilder.FindInterface(null, null, theDevice,typeof(IAMCrossbar).GUID, out o);
        if (hr >= 0)
        {
            crossbar = (IBaseFilter)o;
            o = null;
        }
    
        ArrayList crossbars = findCrossbars( captureGraphBuilder, theDevice);
    
        foreach (IAMCrossbar cBar in crossbars)
        {
            cBar.Route(1, 5);//1 is the number of the "Audio Decoder Out" and 5 is "Audio Tuner In"
        }
    }
    
    //Added this method to the class:
    
    protected ArrayList findCrossbars(ICaptureGraphBuilder2 graphBuilder, IBaseFilter deviceFilter)
    {
        ArrayList crossbars = new ArrayList();
    
        Guid category = FindDirection.UpstreamOnly;
        Guid type = new Guid();
        Guid riid = typeof(IAMCrossbar).GUID;
        int hr;
    
        object comObj = null;
        object comObjNext = null;
    
        // Find the first interface, look upstream from the selected device
        hr = graphBuilder.FindInterface(category, type, deviceFilter, riid, out comObj);
        while ((hr == 0) && (comObj != null))
        {
            // If found, add to the list
            if (comObj is IAMCrossbar)
            {
                crossbars.Add(comObj as IAMCrossbar);
    
                // Find the second interface, look upstream from the next found crossbar
                hr = graphBuilder.FindInterface(category, type, comObj as IBaseFilter, riid, out comObjNext);
                comObj = comObjNext;
            }
            else
                comObj = null;
        }
    
        return (crossbars);
    }
    
    //...
    

    Thank you for your help snarfle. E-Mail me at eralmo -at- dynalmo dot com and I'll send the game you'd like from the list.

     
    Last edit: Eric 2013-04-17