sipsorcery-org / SIPSorceryMedia.Windows

BSD 3-Clause "New" or "Revised" License
10 stars 22 forks source link

PauseAudio and ResumeAudio are only pausing waveIn #10

Closed finebytes closed 10 months ago

finebytes commented 1 year ago

PauseAudio() and ResumeAudio() are only pausing _waveInEvent in WindowsAudioEndPoint.

        public Task PauseAudio()
        {
            _isPaused = true;
            _waveInEvent?.StopRecording();
            return Task.CompletedTask;
        }

        public Task ResumeAudio()
        {
            _isPaused = false;
            _waveInEvent?.StartRecording();
            return Task.CompletedTask;
        }

What if I want to pause _waveOutEvent as well?

does it make sense to do a PR, adding an option for that (that defaults to the old behaviour)? like this:


        public Task PauseAudio(bool affectWaveOut = false)
        {
            _isPaused = true;
            _waveInEvent?.StopRecording();
        if(affectWaveOut)
        {
            _waveOutEvent?.Pause();
        }

            return Task.CompletedTask;
        }

        public Task ResumeAudio(bool affectWaveOut = false)
        {
            _isPaused = false;
            _waveInEvent?.StartRecording();
        if(affectWaveOut)
        {
            _waveOutEvent?.Play();
        }
            return Task.CompletedTask;
        }

Or am I missing something?

fred-peters commented 1 year ago

Hi finebytes, according to my understanding of the project, PauseAudio and ResumeAudio are implementation of the IAudioSource and not IAudioSink, that's why they should not deal with waveOutEvent., that's the purpose of the IAudioSink interface. If you need a generic (in/out) PauseAudio, this should be implemented at the VoipMediaSession level. This is unfortunate that the naming of the IAudioSource methods is generic (PauseAudio and ResumeAudio, it should be renamed to PauseAudioSource and ResumeAudioSource like it is correctly done of the IAudioSink interface which has PauseAudioSink and PauseAudioSource methods)

I don't know if your comment is related to the merge request I just issued and which affect this behaviour