コード例 #1
0
 private string getName(IPin pin)
 {
     string str = "Unknown pin";
     PinInfo pInfo = new PinInfo();
     int errorCode = pin.QueryPinInfo(out pInfo);
     if (errorCode == 0)
     {
         str = pInfo.name ?? "";
     }
     else
     {
         Marshal.ThrowExceptionForHR(errorCode);
     }
     if (pInfo.filter != null)
     {
         Marshal.ReleaseComObject(pInfo.filter);
     }
     pInfo.filter = null;
     return str;
 }
コード例 #2
0
ファイル: AudioSource.cs プロジェクト: iManbot/monoslam
		// --------------------------- Private methods ----------------------------

		/// <summary> Retrieve the friendly name of a connectorType. </summary>
		private string getName( IPin pin )
		{
			string s = "Unknown pin";
			PinInfo pinInfo = new PinInfo();

			// Direction matches, so add pin name to listbox
			int hr = pin.QueryPinInfo( out pinInfo);
			if ( hr == 0 )
			{ 
				s = pinInfo.name + "";
			}
			else
				Marshal.ThrowExceptionForHR( hr );

			// The pininfo structure contains a reference to an IBaseFilter,
			// so you must release its reference to prevent resource a leak.
			if ( pinInfo.filter != null )
				Marshal.ReleaseComObject( pinInfo.filter  );  pinInfo.filter  = null;

			return( s );
		}
コード例 #3
0
ファイル: Capture.cs プロジェクト: alienwow/CSharpProjects
 protected void removeDownstream(IBaseFilter filter, bool removeFirstFilter)
 {
     IEnumPins pins;
     int num = filter.EnumPins(out pins);
     pins.Reset();
     if ((num == 0) && (pins != null))
     {
         IPin[] ppPins = new IPin[1];
         do
         {
             int num2;
             num = pins.Next(1, ppPins, out num2);
             if ((num == 0) && (ppPins[0] != null))
             {
                 IPin ppPin = null;
                 ppPins[0].ConnectedTo(out ppPin);
                 if (ppPin != null)
                 {
                     PinInfo pInfo = new PinInfo();
                     num = ppPin.QueryPinInfo(out pInfo);
                     if ((num == 0) && (pInfo.dir == PinDirection.Input))
                     {
                         this.removeDownstream(pInfo.filter, true);
                         this.graphBuilder.Disconnect(ppPin);
                         this.graphBuilder.Disconnect(ppPins[0]);
                         if ((pInfo.filter != this.videoCompressorFilter) && (pInfo.filter != this.audioCompressorFilter))
                         {
                             this.graphBuilder.RemoveFilter(pInfo.filter);
                         }
                     }
                     Marshal.ReleaseComObject(pInfo.filter);
                     Marshal.ReleaseComObject(ppPin);
                 }
                 Marshal.ReleaseComObject(ppPins[0]);
             }
         }
         while (num == 0);
         Marshal.ReleaseComObject(pins);
         pins = null;
     }
 }
コード例 #4
0
ファイル: Capture.cs プロジェクト: iManbot/monoslam
		/// <summary>
		///  Removes all filters downstream from a filter from the graph.
		///  This is called only by derenderGraph() to remove everything
		///  from the graph except the devices and compressors. The parameter
		///  "removeFirstFilter" is used to keep a compressor (that should
		///  be immediately downstream of the device) if one is begin used.
		/// </summary>
		protected void removeDownstream( IBaseFilter filter, bool removeFirstFilter )
		{
			// Get a pin enumerator off the filter
			IEnumPins pinEnum;
			int hr = filter.EnumPins( out pinEnum );
			pinEnum.Reset();
			if( (hr == 0) && (pinEnum != null) )
			{
				// Loop through each pin
				IPin[] pins = new IPin[1];
				int f;
				do
				{
					// Get the next pin
					hr = pinEnum.Next( 1, pins, out f );
					if( (hr == 0) && (pins[0] != null) )
					{
						// Get the pin it is connected to
						IPin pinTo = null;
						pins[0].ConnectedTo( out pinTo );
						if ( pinTo != null )
						{
							// Is this an input pin?
							PinInfo info = new PinInfo();
							hr = pinTo.QueryPinInfo( out info );
							if( (hr == 0) && (info.dir == (PinDirection.Input)) )
							{
								// Recurse down this branch
								removeDownstream( info.filter, true );

								// Disconnect 
								graphBuilder.Disconnect( pinTo );
								graphBuilder.Disconnect( pins[0] );

								// Remove this filter
								// but don't remove the video or audio compressors
								if ( ( info.filter != videoCompressorFilter ) &&
									( info.filter != audioCompressorFilter ) )
									graphBuilder.RemoveFilter( info.filter );
							}
							Marshal.ReleaseComObject( info.filter );
							Marshal.ReleaseComObject( pinTo );
						}
						Marshal.ReleaseComObject( pins[0] );
					}
				}
				while( hr == 0 );

				Marshal.ReleaseComObject( pinEnum ); pinEnum = null;
			}
		}