From 96f64a4f77ecce3c5b04e034bd19429643547825 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.net> Date: Mon, 19 Oct 2009 18:03:12 -0400 Subject: [PATCH] [2308] Fix latency at the beginning of a call, when playing DTMF and wehn starting tone --- sflphone-common/src/audio/audiolayer.cpp | 4 ++-- sflphone-common/src/audio/audiortp/AudioRtpSession.h | 4 +++- sflphone-common/src/managerimpl.cpp | 9 ++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sflphone-common/src/audio/audiolayer.cpp b/sflphone-common/src/audio/audiolayer.cpp index 9f1119ff69..8966eb6aba 100644 --- a/sflphone-common/src/audio/audiolayer.cpp +++ b/sflphone-common/src/audio/audiolayer.cpp @@ -24,13 +24,13 @@ void AudioLayer::flushMain (void) ost::MutexLock guard (_mutex); // should pass call id - _mainBuffer.flush(); + _mainBuffer.flushAllBuffers(); } void AudioLayer::flushUrgent (void) { ost::MutexLock guard (_mutex); - _urgentRingBuffer.flush(); + _urgentRingBuffer.flushAll(); } void AudioLayer::flushMic (void) diff --git a/sflphone-common/src/audio/audiortp/AudioRtpSession.h b/sflphone-common/src/audio/audiortp/AudioRtpSession.h index bed84b1c3d..3ac8916b3a 100644 --- a/sflphone-common/src/audio/audiortp/AudioRtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioRtpSession.h @@ -498,10 +498,12 @@ namespace sfl { } _ca->setRecordingSmplRate(_audiocodec->getClockRate()); - + _audiolayer->startStream(); static_cast<D*>(this)->startRunning(); + _audiolayer->flushUrgent(); + _debug ("Entering RTP mainloop for callid %s\n",_ca->getCallId().c_str()); while (!testCancel()) { diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 052b87fadf..006ef35f3e 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -372,6 +372,7 @@ ManagerImpl::answerCall (const CallID& call_id) } + if (!getAccountLink (account_id)->answer (call_id)) { // error when receiving... removeCallAccount (call_id); @@ -777,7 +778,7 @@ ManagerImpl::refuseCall (const CallID& id) AccountID accountid; bool returnValue; - stopTone (true); + stopTone (false); int nbCalls = getCallList().size(); @@ -1700,6 +1701,8 @@ ManagerImpl::playDtmf (char code, bool isTalking) // Put buffer to urgentRingBuffer // put the size in bytes... // so size * 1 channel (mono) * sizeof (bytes for the data) + audiolayer->flushUrgent(); + audiolayer->startStream(); audiolayer->putUrgent (buf, size * sizeof (SFLDataFormat)); } @@ -2030,6 +2033,8 @@ bool ManagerImpl::playATone (Tone::TONEID toneId) if (audiolayer) audiolayer->startStream(); + audiolayer->flushUrgent(); + if (_telephoneTone != 0) { _toneMutex.enterMutex(); _telephoneTone->setCurrentTone (toneId); @@ -2039,6 +2044,7 @@ bool ManagerImpl::playATone (Tone::TONEID toneId) nbSamples = audioloop->getSize(); SFLDataFormat buf[nbSamples]; + if (audiolayer) { audiolayer->putUrgent (buf, nbSamples); } else @@ -2218,6 +2224,7 @@ void ManagerImpl::notificationIncomingCall (void) SFLDataFormat buf[nbSampling]; tone.getNext (buf, tone.getSize()); /* Put the data in the urgent ring buffer */ + audiolayer->flushUrgent(); audiolayer->putUrgent (buf, sizeof (SFLDataFormat) *nbSampling); } } -- GitLab