Exemplo n.º 1
0
 public void Stop()
 {
     if (_isStarted)
     {
         Marshal.ThrowExceptionForHR(_RealClient.Stop());
     }
     _isStarted = false;
 }
Exemplo n.º 2
0
 public override void UninitializeAudio()
 {
     if (null != _audioEndpointVolume)
     {
         _audioEndpointVolume.UnregisterControlChangeNotify(classCallBack);
     }
     if (null != _audioClient)
     {
         _audioClient.Stop();
     }
     if (null != _audioMeter)
     {
         //For wait audio meter thread stop. then release memory
         Thread.Sleep(100);
         Marshal.ReleaseComObject(_audioMeter);
         _audioMeter = null;
     }
     if (null != _audioClient)
     {
         Marshal.ReleaseComObject(_audioClient);
         _audioClient = null;
     }
     if (null != _audioEndpointVolume)
     {
         Marshal.ReleaseComObject(_audioEndpointVolume);
         _audioEndpointVolume = null;
     }
     if (null != waveFormat)
     {
         waveFormat = null;
     }
     base.UninitializeAudio();
 }
Exemplo n.º 3
0
 public override void Stop()
 {
     lock (this)
     {
         _IAudioClient.Stop();
         _Thread.Abort();
         _Thread = new System.Threading.Thread(Loop);
     }
 }
Exemplo n.º 4
0
        public void Stop()
        {
            int error = AudioClient.Stop();

            if (error != 0)
            {
                Win32Platform.CheckError($"Couldn't stop a layer context of device {Parent.Name}.", true);
            }
            Started = false;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Stops the audio stream.
 /// </summary>
 public void Stop()
 {
     try
     {
         audioClientInterface.Stop();
     }
     catch (COMException ex)
     {
         FeenPhone.Audio.AudioEvents.DeviceProbablyWentAway(this, ex);
     }
 }
Exemplo n.º 6
0
        public void Stop()
        {
            Thread thread;

            lock (mutex)
            {
                isStarted   = false;
                thread      = this.thread;
                this.thread = null;
                audioClient?.Stop();
            }
            if (thread != null)
            {
                if (thread.ManagedThreadId != Thread.CurrentThread.ManagedThreadId)
                {
                    thread.Join();
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Stops the audio stream.
 /// </summary>
 public void Stop()
 {
     audioClientInterface.Stop();
 }
Exemplo n.º 8
0
        public void recordingloop()
        {
            uint  packetLength;
            uint  numFramesAvailable;
            uint  flags;
            ulong junk1;
            ulong junk2;

            byte[]     pData;
            uint       AUDCLNT_BUFFERFLAGS_SILENT = 2;
            uint       bytespersample             = (uint)(waveformat.nChannels * waveformat.wBitsPerSample / 8);
            WaveFormat _wf        = new WaveFormat((int)waveformat.nSamplesPerSec, (int)waveformat.wBitsPerSample, (int)waveformat.nChannels);
            BE_CONFIG  _mp3config = new BE_CONFIG(_wf);
            Mp3Writer  _mp3writer = new Mp3Writer(memStream, _wf, _mp3config);

            int retVal = iAudioClient.Start();

            if (retVal != 0)
            {
                throw new Exception("IAudioClient.Start()");
            }
            keepgoing = true;
            while (keepgoing)
            {
                Thread.Sleep((int)(hnsActualDuration / 5000));
                retVal = iAudioCaptureClient.GetNextPacketSize(out packetLength);
                if (retVal != 0)
                {
                    throw new Exception("iAudioCaptureClient.GetNextPacketSize()");
                }
                while (packetLength != 0)
                {
                    IntPtr dataPtr = IntPtr.Zero;
                    retVal = iAudioCaptureClient.GetBuffer(out dataPtr, out numFramesAvailable, out flags, out junk1, out junk2);
                    if (retVal != 0)
                    {
                        throw new Exception("iAudioCaptureClient.GetBuffer()");
                    }
                    pData = new byte[bytespersample * numFramesAvailable];
                    if ((flags & AUDCLNT_BUFFERFLAGS_SILENT) != 0)
                    {
                        for (int i = 0; i < pData.Length; i++)
                        {
                            pData[i] = 0;
                        }
                    }
                    else
                    {
                        Marshal.Copy(dataPtr, pData, 0, (int)(bytespersample * numFramesAvailable));
                    }
                    retVal = iAudioCaptureClient.ReleaseBuffer(numFramesAvailable);
                    if (retVal != 0)
                    {
                        throw new Exception("iAudioCaptureClient.ReleaseBuffer()");
                    }

                    lock (synclock)
                    {
                        _mp3writer.Write(pData, 0, pData.Length);
                    }
                    if (notify != null)
                    {
                        notify();
                    }

                    retVal = iAudioCaptureClient.GetNextPacketSize(out packetLength);
                    if (retVal != 0)
                    {
                        throw new Exception("iAudioCaptureClient.GetNextPacketSize()");
                    }
                }
            }
            _mp3writer.Close();
            memStream.Close();
            memStream.Dispose();
            if (iAudioClient != null)
            {
                retVal = iAudioClient.Stop();
                if (retVal != 0)
                {
                    throw new Exception("iAudioClient.Stop()");
                }
            }
        }
Exemplo n.º 9
0
 public void Stop()
 {
     _realAudioClient.Stop();
 }