コード例 #1
0
ファイル: AudioFileWriter.cs プロジェクト: yazici/Screna
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            using (_writer)
                Flush();

            _encoder?.Dispose();
        }
コード例 #2
0
ファイル: AudioRecorderWPF.cs プロジェクト: tomaszlt/Spixi
    public void stop()
    {
        if (!running)
        {
            return;
        }
        running = false;

        if (audioRecorder != null)
        {
            try
            {
                audioRecorder.StopRecording();
            }
            catch (Exception)
            {
            }
            audioRecorder.Dispose();
            audioRecorder = null;
        }

        if (audioEncoder != null)
        {
            audioEncoder.stop();
            audioEncoder.Dispose();
            audioEncoder = null;
        }

        lock (outputBuffers)
        {
            outputBuffers.Clear();
        }
    }
コード例 #3
0
    public void stop()
    {
        if (!running)
        {
            return;
        }
        running = false;

        AVAudioSession.SharedInstance().SetActive(false);

        if (audioRecorder != null)
        {
            try
            {
                audioRecorder.InputNode.RemoveTapOnBus(0);
                audioRecorder.Stop();
                audioRecorder.Reset();
            }
            catch (Exception)
            {
            }
            audioRecorder.Dispose();
            audioRecorder = null;
        }

        if (audioEncoder != null)
        {
            audioEncoder.stop();
            audioEncoder.Dispose();
            audioEncoder = null;
        }

        lock (outputBuffers)
        {
            outputBuffers.Clear();
        }
    }
コード例 #4
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     _audioProvider.Dispose();
     _audioEncoder.Dispose();
 }
コード例 #5
0
    public void stop()
    {
        if (!running)
        {
            return;
        }
        running = false;

        if (echoCanceller != null)
        {
            try
            {
                echoCanceller.Release();
                echoCanceller.Dispose();
            }
            catch (Exception)
            {
            }
            echoCanceller = null;
        }

        if (noiseSuppressor != null)
        {
            try
            {
                noiseSuppressor.Release();
                noiseSuppressor.Dispose();
            }
            catch (Exception)
            {
            }
            noiseSuppressor = null;
        }

        if (audioRecorder != null)
        {
            try
            {
                audioRecorder.Stop();
                audioRecorder.Release();
            }
            catch (Exception)
            {
            }
            audioRecorder.Dispose();
            audioRecorder = null;
        }

        if (audioEncoder != null)
        {
            audioEncoder.stop();
            audioEncoder.Dispose();
            audioEncoder = null;
        }

        buffer       = null;
        shortsBuffer = null;
        bufferSize   = 0;
        lock (outputBuffers)
        {
            outputBuffers.Clear();
        }


        AudioManager am = (AudioManager)MainActivity.Instance.GetSystemService(Context.AudioService);

        if (Build.VERSION.SdkInt < BuildVersionCodes.O)
        {
            if (focusListener != null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                am.AbandonAudioFocus(focusListener);
#pragma warning restore CS0618 // Type or member is obsolete
                focusListener.Dispose();
                focusListener = null;
            }
        }
        else
        {
            if (focusListener != null)
            {
                if (focusRequest != null)
                {
                    am.AbandonAudioFocusRequest(focusRequest);
                    focusRequest.Dispose();
                    focusRequest = null;
                }
                focusListener.Dispose();
                focusListener = null;
            }
        }
    }