From 036489f331196c723d88b3764fb927bb64ded340 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)> Date: Wed, 19 May 2010 16:37:57 -0400 Subject: [PATCH] [#3388] Fix segfault when closing SFLphone after refusing calls --- sflphone-common/src/audio/alsa/alsalayer.cpp | 23 +++--------- .../src/audio/pulseaudio/pulselayer.cpp | 35 ++++++------------- sflphone-common/src/sip/sipvoiplink.cpp | 4 ++- 3 files changed, 18 insertions(+), 44 deletions(-) diff --git a/sflphone-common/src/audio/alsa/alsalayer.cpp b/sflphone-common/src/audio/alsa/alsalayer.cpp index 5719c6aa23..98f191d50c 100644 --- a/sflphone-common/src/audio/alsa/alsalayer.cpp +++ b/sflphone-common/src/audio/alsa/alsalayer.cpp @@ -861,32 +861,19 @@ void AlsaLayer::audioCallback (void) } else { tone = _manager->getTelephoneTone(); - file_tone = _manager->getTelephoneFile(); toGet = framesPerBufferAlsa; maxBytes = toGet * sizeof (SFLDataFormat); if (tone != 0) { - out = (SFLDataFormat*) malloc (maxBytes * sizeof (SFLDataFormat)); + out = (SFLDataFormat *) malloc (maxBytes); tone->getNext (out, toGet, spkrVolume); write (out , maxBytes, _PlaybackHandle); free (out); out = 0; - /* - } else if (file_tone != 0) { - - out = (SFLDataFormat*) malloc (maxBytes * sizeof (SFLDataFormat)); - file_tone->getNext (out, toGet, spkrVolume); - write (out , maxBytes, _PlaybackHandle); - - free (out); - out = 0; - - } else { - */ } else { @@ -947,7 +934,7 @@ void AlsaLayer::audioCallback (void) } else { - if ( (tone == 0) && (file_tone == 0)) { + if (tone == 0) { SFLDataFormat* zeros = (SFLDataFormat*) malloc (framesPerBufferAlsa * sizeof (SFLDataFormat)); @@ -975,7 +962,7 @@ void AlsaLayer::audioCallback (void) if (file_tone != NULL) { - out = (SFLDataFormat*) malloc (maxBytes * sizeof (SFLDataFormat)); + out = (SFLDataFormat *) malloc (maxBytes); file_tone->getNext (out, toGet, spkrVolume); write (out, maxBytes, _RingtoneHandle); @@ -984,8 +971,8 @@ void AlsaLayer::audioCallback (void) } else { - out = (SFLDataFormat*) malloc ( maxBytes * sizeof (SFLDataFormat)); - memset(out, 0, maxBytes * sizeof (SFLDataFormat)); + out = (SFLDataFormat *) malloc ( maxBytes); + memset(out, 0, maxBytes); write(out, maxBytes, _RingtoneHandle); free(out); diff --git a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp index 820538b992..e6b3c905be 100644 --- a/sflphone-common/src/audio/pulseaudio/pulselayer.cpp +++ b/sflphone-common/src/audio/pulseaudio/pulselayer.cpp @@ -732,7 +732,6 @@ void PulseLayer::writeToSpeaker (void) } else { AudioLoop* tone = _manager->getTelephoneTone(); - AudioLoop* file_tone = _manager->getTelephoneFile(); // flush remaining samples in _urgentRingBuffer flushUrgent(); @@ -749,22 +748,6 @@ void PulseLayer::writeToSpeaker (void) pa_xfree (out); } - //} - - // else if (file_tone != 0) { - - /* - if (playback->getStreamState() == PA_STREAM_READY) { - - out = (SFLDataFormat*) pa_xmalloc (writeableSize); - int copied = file_tone->getNext (out, writeableSize / sizeof (SFLDataFormat), 100); - - pa_stream_write (playback->pulseStream(), out, copied * sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE); - - pa_xfree (out); - - } - */ } else { @@ -831,7 +814,7 @@ void PulseLayer::writeToSpeaker (void) } else { - if ( (tone == 0) && (file_tone == 0)) { + if (tone == 0) { SFLDataFormat* zeros = (SFLDataFormat*) pa_xmalloc (writeableSize); @@ -916,27 +899,29 @@ void PulseLayer::ringtoneToSpeaker(void) int writableSize = pa_stream_writable_size(ringtone->pulseStream()); - // _debug("writable size: %d", writableSize); + _debug("writable size: %d", writableSize); if (file_tone) { if(ringtone->getStreamState() == PA_STREAM_READY) { - out = (SFLDataFormat*)pa_xmalloc(writableSize); + out = (SFLDataFormat *)pa_xmalloc(writableSize); int copied = file_tone->getNext(out, writableSize/sizeof(SFLDataFormat), 100); pa_stream_write(ringtone->pulseStream(), out, copied*sizeof(SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE); pa_xfree(out); - } } else { - out = (SFLDataFormat*)pa_xmalloc(writableSize); - memset(out, 0, writableSize); - pa_stream_write(ringtone->pulseStream(), out, writableSize, NULL, 0, PA_SEEK_RELATIVE); + if(ringtone->getStreamState() == PA_STREAM_READY) { + + out = (SFLDataFormat*)pa_xmalloc(writableSize); + memset(out, 0, writableSize); + pa_stream_write(ringtone->pulseStream(), out, writableSize, NULL, 0, PA_SEEK_RELATIVE); - pa_xfree(out); + pa_xfree(out); + } } diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 3a3df884be..a5642a3b22 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -269,6 +269,7 @@ SIPVoIPLink::~SIPVoIPLink() _debug("UserAgent: SIPVoIPLink destructor called"); terminate(); + } SIPVoIPLink* SIPVoIPLink::instance (const AccountID& id) @@ -333,7 +334,6 @@ SIPVoIPLink::terminate() initDone (false); - _debug("Terminating"); } void @@ -1248,6 +1248,8 @@ SIPVoIPLink::refuse (const CallID& id) call->getInvSession()->mod_data[getModId() ] = NULL; + removeCall(id); + terminateOneCall (id); _debug("UserAgent: Refuse call completed"); -- GitLab