Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Reference Exception in WindowsAudioEndpoint #21

Open
NeatoBandito777 opened this issue Jun 25, 2024 · 0 comments
Open

Null Reference Exception in WindowsAudioEndpoint #21

NeatoBandito777 opened this issue Jun 25, 2024 · 0 comments

Comments

@NeatoBandito777
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant