Page 1 of 1

Audio Outputs Enumetate

PostPosted: Sun Jan 21, 2018 9:34 am
by Anton Kotov
Hello.
I can enumerate audio inputs, but not outputs.
I try such
Code: Select all
IBMDSwitcherAudioMonitorOutputIterator audioOutIterator = null;
            IntPtr audioOutIteratorPtr;
            Guid audioOutIteratorIID = typeof(IBMDSwitcherAudioMonitorOutputIterator).GUID;

            m_audiomixer.CreateIterator(ref audioIteratorIID, out audioOutIteratorPtr);
            if (audioOutIteratorPtr != null)
            {
                audioOutIterator = (IBMDSwitcherAudioMonitorOutputIterator)Marshal.GetObjectForIUnknown(audioOutIteratorPtr);
            }
            if (audioOutIterator != null)
            {
                IBMDSwitcherAudioMonitorOutput output;
                audioOutIterator.Next(out output);
                while (output != null)
                {
                    //...
                    audioOutIterator.Next(out output);
                }
            }


but when
Code: Select all
audioOutIterator = (IBMDSwitcherAudioMonitorOutputIterator)Marshal.GetObjectForIUnknown(audioOutIteratorPtr);

I get
System.InvalidCastException:
It is impossible to bring a COM object of type "System .__ ComObject" to the interface type "BMDSwitcherAPI.IBMDSwitcherAudioMonitorOutputIterator". The operation failed because the QueryInterface COM component call for interface with IID "{C76BAC6A-DFEE-4F2F-B161-226B481D556A}" returned the following error: The interface is not supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Why "The interface is not supported"?
How can I enumerate audio outputs else?

Re: Audio Outputs Enumetate

PostPosted: Mon Jan 29, 2018 2:41 am
by Cameron Nichols
Hi Anton,

The ATEM Switcher API requires a multithreaded COM apartment. Please check that you are calling Marshal.GetObjectForIUnknown via thread contexts sharing the multi-threaded apartment. This is most common cause for HRESULT = E_NOINTERFACE for calls to IUnknown::QueryInterface()

More details on MTAThread attribute and the Thread.SetApartmentState() method can be found at: https://msdn.microsoft.com/en-us/library/system.mtathreadattribute(v=vs.110).aspx

Kind Regards
Cameron

Re: Audio Outputs Enumetate

PostPosted: Sun Feb 11, 2018 3:07 pm
by Anton Kotov
Thank you, Cameron.
Tell please how I can get one group with 2 channels at output, instead of 4 groups with 4 channels each as now?

Re: Audio Outputs Enumetate

PostPosted: Wed Feb 14, 2018 3:11 am
by Cameron Nichols
Hi Anton,

Which ATEM Switcher are you using? There should be one IBMDSwitcherAudioMonitorOutput instance for each SDI output

Regards
Cameron