sipsorcery-org / sipsorcery

A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
https://sipsorcery-org.github.io/sipsorcery
Other
1.47k stars 442 forks source link

SDL2 CRASHES WHEN CALL #1002

Closed yeatttttt closed 1 year ago

yeatttttt commented 1 year ago

SDL2 CRASHES WHEN CALL RESOLVE THIS PROBLEM

sipsorcery commented 1 year ago

If you'd like help you'll need to look up how to log issues in an acceptable manner.

yeatttttt commented 1 year ago

Again, you'll need to find out how to log issues before anyone even considers helping.

ok, excuse me there is some different logs from windbg and Windows event log Let me remind you that the application works in debug, but upon release it crashes on the call Code:

public async Task<bool> Call(string destination)
        {
            try
            {
                SIPURI? callURI = null;
                string? sipUsername = null;
                string? sipPassword = null;
                string? fromHeader = null;
                callURI = SIPURI.ParseSIPURIRelaxed(destination + "@" + _settings.Host);
                sipUsername = _settings.User;
                sipPassword = _settings.Password;
                fromHeader =
                    (new SIPFromHeader(_settings.FromName, new SIPURI(_settings.User, _settings.Host, null), null))
                    .ToString();

                var dstEndpoint = SIPDns.ResolveAsync(callURI, false, _cts.Token);

                if (dstEndpoint == null)
                {
                    return false;
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine($"DNS lookup result for {callURI}: {dstEndpoint}.");
                    SIPCallDescriptor callDescriptor = new SIPCallDescriptor(sipUsername, sipPassword,
                        callURI.ToString(), fromHeader, null, null, null, null, SIPCallDirection.Out,
                        SDP_MIME_CONTENTTYPE, null, null);

                    _sipUserAgent.RemotePutOnHold += OnRemotePutOnHold;
                    _sipUserAgent.RemoteTookOffHold += OnRemoteTookOffHold;
                    _sipUserAgent.ClientCallAnswered += ClientCallAnswered;

                    CreateMediaSessionRTP(AudioOutDeviceIndex, AudioInDeviceIndex);
                    if (_mediaSession.Media.AudioSource != null)
                        _mediaSession.Media.AudioSource.StartAudio();
                    if (_mediaSession.Media.AudioSink != null)
                        _mediaSession.Media.AudioSink.StartAudioSink();
                    var res = await _sipUserAgent.Call(callDescriptor, _mediaSession);
                    return res;
                }
            }
            catch (SEHException ex)
            {
                await MessageBoxManager.GetMessageBoxStandard("", ex.Message).ShowAsync();
                return false;
            }
            catch (SocketException ex)
            {
                Console.WriteLine(ex);
                return false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return false;
            }
        }private async void CreateMediaSessionRTP(int audioOutDeviceIndex = 0, int audioInDeviceIndex = 0)
        {
            try
            {
                SDL2Helper.InitSDL();
                var din = SDL2Helper.GetAudioPlaybackDevice(0);
                var micro = SDL2Helper.GetAudioRecordingDevice(0);
                var windowsAudioEndPoint =
                    new SIPSorceryMedia.SDL2.SDL2AudioEndPoint(din, new AudioEncoder());
                var windowsAudioStartPoint =
                    new SIPSorceryMedia.SDL2.SDL2AudioSource(micro, new AudioEncoder(), 160);
                var ses = new MediaEndPoints();
                ses.AudioSink = windowsAudioEndPoint;
                ses.AudioSource = windowsAudioStartPoint;
                var voipMediaSession = new VoIPMediaSession(ses, null);
                voipMediaSession.AcceptRtpFromAny = true;
                _mediaSession = voipMediaSession;
            }
            catch (SEHException ex)
            {
                await MessageBoxManager.GetMessageBoxStandard("", ex.Message).ShowAsync();
            }
            catch (SocketException ex)
            {
                await MessageBoxManager.GetMessageBoxStandard("", ex.Message).ShowAsync();
            }
            catch (Exception ex)
            {
                await MessageBoxManager.GetMessageBoxStandard("", ex.Message).ShowAsync();
            }
        }
    **WinDbg:**
    ```
    (7c04.8c08): Access violation - code c0000005 (first chance)

First chance exceptions are reported before any exception handling. This exception may be expected and handled. Unable to read dynamic function table entries Unable to read dynamic function table entries 00007ff66d38b212 0fb74f44 movzx ecx,word ptr [rdi+44h] ds:0000000000000044=????

or

(1d78.9dcc): Invalid handle - code c0000008 (first chance) First chance exceptions are reported before any exception handling. This exception may be expected and handled. ntdll!KiRaiseUserExceptionDispatcher+0x3a: 00007ff868690daa 8b8424c0000000 mov eax,dword ptr [rsp+0C0h] ss:000000139dd1db90=c0000008


**Windows event log:**

Имя сбойного приложения: AvaloniaLlacot.exe, версия: 1.0.0.0, метка времени: 0x6492041a Имя сбойного модуля: coreclr.dll, версия: 7.0.923.32018, метка времени: 0x6491fc88 Код исключения: 0xc0000005 Смещение ошибки: 0x00000000001ca35e Идентификатор сбойного процесса: 0x8f6c Время запуска сбойного приложения: 0x01d9f08b846a2444 Путь сбойного приложения: C:\Users\user\Desktop\avaloniallacot\AvaloniaLlacot\bin\Debug\net7.0\AvaloniaLlacot.exe Путь сбойного модуля: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.9\coreclr.dll Идентификатор отчета: 5b46f260-2255-4553-b3ea-70f7fb78f403 Полное имя сбойного пакета: Код приложения, связанного со сбойным пакетом:

or

Имя сбойного приложения: AvaloniaLlacot.exe, версия: 1.0.0.0, метка времени: 0x6492041a Имя сбойного модуля: SDL2.DLL, версия: 2.28.3.0, метка времени: 0x64f22d5a Код исключения: 0xc0000005 Смещение ошибки: 0x000000000009c3b3 Идентификатор сбойного процесса: 0x8724 Время запуска сбойного приложения: 0x01d9f08a7631bf0d Путь сбойного приложения: C:\Users\user\Desktop\avaloniallacot\AvaloniaLlacot\bin\Debug\net7.0\AvaloniaLlacot.exe Путь сбойного модуля: C:\Users\user\Desktop\avaloniallacot\AvaloniaLlacot\bin\Debug\net7.0\SDL2.DLL Идентификатор отчета: c8896d98-3891-4845-bdb5-c43af88539cc Полное имя сбойного пакета: Код приложения, связанного со сбойным пакетом:


Again, there is no problem in DEBUG, but when i run it on release ver. it's always crash on .Call();