public MainWindow() { InitializeComponent(); try { mCaptureManager = new CaptureManager("CaptureManager.dll"); } catch (Exception) { mCaptureManager = new CaptureManager(); } LogManager.getInstance().WriteDelegateEvent += MainWindow_WriteDelegateEvent; if (mCaptureManager == null) { return; } mSourceControl = mCaptureManager.createSourceControl(); if (mSourceControl == null) { return; } mSinkControl = mCaptureManager.createSinkControl(); if (mSinkControl == null) { return; } mISessionControl = mCaptureManager.createSessionControl(); if (mISessionControl == null) { return; } mISARVolumeControl = mCaptureManager.createSARVolumeControl(); if (mISARVolumeControl == null) { return; } mRVolume.ValueChanged += (s, ev) => { if (mSARSinkOutputNode != null) { mISARVolumeControl.setChannelVolume(mSARSinkOutputNode, 0, (float)ev.NewValue); } }; mLVolume.ValueChanged += (s, ev) => { if (mSARSinkOutputNode != null) { mISARVolumeControl.setChannelVolume(mSARSinkOutputNode, 1, (float)ev.NewValue); } }; XmlDataProvider lXmlDataProvider = (XmlDataProvider)this.Resources["XmlSources"]; if (lXmlDataProvider == null) { return; } XmlDocument doc = new XmlDocument(); string lxmldoc = ""; mCaptureManager.getCollectionOfSources(ref lxmldoc); doc.LoadXml(lxmldoc); lXmlDataProvider.Document = doc; mSinkControl.createSinkFactory(Guid.Empty, out mSARSinkFactory); }
private void Button_Click(object sender, RoutedEventArgs e) { if (mISession != null) { mISession.stopSession(); mISession.closeSession(); mISession = null; mTitleTxtBlk.Text = "Start playing"; return; } List <object> lSourceNodes = new List <object>(); object lSARSinkOutputNode = null; mSARSinkFactory.createOutputNode(out lSARSinkOutputNode); if (lSARSinkOutputNode == null) { return; } var l_AudioSourceXmlNode = m_AudioSourceComboBox.SelectedItem as XmlNode; if (l_AudioSourceXmlNode == null) { return; } var lNode = l_AudioSourceXmlNode.SelectSingleNode( "Source.Attributes/Attribute" + "[@Name='MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK']" + "/SingleValue/@Value"); if (lNode == null) { return; } string lSymbolicLink = lNode.Value; object lSourceNode = null; mSourceControl.createSourceNode( lSymbolicLink, 0, 0, lSARSinkOutputNode, out lSourceNode); if (lSourceNode == null) { return; } lSourceNodes.Add(lSourceNode); mISession = mISessionControl.createSession(lSourceNodes.ToArray()); if (mISession == null) { return; } if (mISession.startSession(0, Guid.Empty)) { mTitleTxtBlk.Text = "Stop playing"; uint lChannelCount = 0; mISARVolumeControl.getChannelCount(lSARSinkOutputNode, out lChannelCount); if (lChannelCount > 0) { float lLevel = 0; mISARVolumeControl.getChannelVolume(lSARSinkOutputNode, 0, out lLevel); mRVolume.ValueChanged += (s, ev) => { mISARVolumeControl.setChannelVolume(lSARSinkOutputNode, 0, (float)ev.NewValue); }; mRVolume.Value = lLevel; if (lChannelCount > 1) { lLevel = 0; mISARVolumeControl.getChannelVolume(lSARSinkOutputNode, 1, out lLevel); mLVolume.ValueChanged += (s, ev) => { mISARVolumeControl.setChannelVolume(lSARSinkOutputNode, 1, (float)ev.NewValue); }; mLVolume.Value = lLevel; } } } }