Exemplo n.º 1
0
        internal AudioDevice(IMFActivate dev)
        {
            Device = dev;

            int     cItems;
            HResult hr = dev.GetCount(out cItems);

            NativeHelpers.CheckHr(hr, "IMFActivate.GetCount");
            for (int j = 0; j < cItems; j++)
            {
                Guid key;
                using (PropVariant value = new PropVariant())
                {
                    hr = dev.GetItemByIndex(j, out key, value);
                    Debug.WriteLine("{0}={1}", key.ToString(), value.ToString());
                    if (key == MFAttributesClsid.MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME)
                    {
                        Name = value.ToString();
                    }
                    else if (key == MFAttributesClsid.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_SYMBOLIC_LINK)
                    {
                        SymbolicLink = value.ToString();
                    }
                    else if (key == MFAttributesClsid.MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_ENDPOINT_ID)
                    {
                        EndPointId = value.ToString();
                    }
                }
            }
        }
Exemplo n.º 2
0
 public AudioRecording StartRecording(string wavFileName, EventHandler <AudioSample> pcmHandler)
 {
     if (this.recording == null)
     {
         Guid    iid = typeof(IMFMediaSource).GUID;
         object  ppv;
         HResult hr = this.Device.ActivateObject(iid, out ppv);
         NativeHelpers.CheckHr(hr, "Activating audio device");
         this.source    = (IMFMediaSource)ppv;
         this.recording = new AudioRecording(this.source);
     }
     this.recording.Start(wavFileName, pcmHandler);
     return(this.recording);
 }