-
Notifications
You must be signed in to change notification settings - Fork 28
Null Reference Exception in WindowsAudioEndpoint #21
Description
Hello all, I'm fairly new to the world of SIP and I'm running into a bit of a bind with this library. My goal is fairly straightforward, I want to create a little .NET service that sends audio to SIP endpoints. I'm trying to use a WindowsAudioEndpoint declared like it is in the SIPExamples project Play Sounds.
var windowsAudio = new WindowsAudioEndPoint(new AudioEncoder());
windowsAudio.RestrictFormats(format => format.Codec == AudioCodecsEnum.G722);
var voipMediaSession = new VoIPMediaSession(windowsAudio.ToMediaEndPoints());
This is a result of trying to improve the audio quality produced by a VoIPMediaSession declared like this:
VoIPMediaSession voipMediaSession = new VoIPMediaSession(null, formats => formats.Codec == AudioCodecsEnum.G722);
The audio coming out of my softphone and speakers is much more consistent and clear with the former declaration rather than the latter. The latter is basically unlistenable for some reason?
Now the problem is, and this is a problem even running the stock PlaySounds example against my endpoints, that an exception is thrown while the call task is awaited.
The debugger takes me to line 141 of WindowsAudioEndPoint.cs:
if (!_disableSource && _waveSourceFormat.SampleRate != _audioFormatManager.SelectedFormat.ClockRate)
where it seems like _waveSourceFormat is null.
The naïve fix I'm using is to add a null conditional operator to said _waveSourceFormat on line 141 and on line 143.
Any help or advice would be much appreciated, thanks!