summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbodamnam <bodamnam@google.com>2023-03-22 07:26:39 +0000
committerbodamnam <bodamnam@google.com>2023-03-22 07:26:39 +0000
commit498fad32cf67fdb3a772d0f0108c775a1a1cf33a (patch)
treeba1bd53412c28c52e9888cc110eb3371f3ed1f36
parente1491dcb83c13303b837adfe871b8dfa4f21b812 (diff)
downloadImsMedia-498fad32cf67fdb3a772d0f0108c775a1a1cf33a.tar.gz
Fix the SID playout delay issue
The AudioJitterBuffer is used to store audio frames from multiple threads. One thread stacks audio frames, while another thread retrieves them every 20 milliseconds. When the AudioJitterBuffer starts, it calculates the time delay of the stacked audio frames and discards the old ones, which causes the frames to be resynced to maintain a constant latency as configured in the jitter buffer size. When the resync is done, the jitter buffer decides the playing timestamp and increases it every time a frame is retrieved. The problem is that the AudioJitterBuffer does not increase the playing timestamp when the queue is empty. This causes the discard of audio frames when the audio frame changes from SID to normal frame because the SID interval is 160 milliseconds but audio frames are 20 milliseconds. To fix this, I added a checking condition to increase the playing timestamp for the next interval to correctly get the playable audio frame and prevent the incorrect audio frame discarding. Bug: 271808260 Test: Voice Call in live network checking the SID and normal sound switching period, atest ImsMediaNativeTests Change-Id: I1a08244d03d8cbfb941c68db7bd49e9577ca04e7
-rw-r--r--service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/AudioJitterBuffer.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/AudioJitterBuffer.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/AudioJitterBuffer.cpp
index 5b948204..64890329 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/AudioJitterBuffer.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/core/audio/AudioJitterBuffer.cpp
@@ -284,14 +284,20 @@ bool AudioJitterBuffer::Get(ImsMediaSubType* psubtype, uint8_t** ppData, uint32_
if (mDataQueue.GetCount() == 0)
{
- IMLOGD_PACKET0(IM_PACKET_LOG_JITTER, "[Get] wait - empty");
+ IMLOGD_PACKET0(IM_PACKET_LOG_JITTER, "[Get] fail - empty");
+
+ if (!mWaiting)
+ {
+ mCurrPlayingTS += FRAME_INTERVAL;
+ }
+
return false;
}
else if (mDataQueue.Get(&pEntry) && mWaiting)
{
uint32_t jitterDelay = currentTime - pEntry->arrivalTime;
- if (jitterDelay < (mCurrJitterBufferSize - 1) * FRAME_INTERVAL + ALLOWABLE_ERROR)
+ if (jitterDelay <= (mCurrJitterBufferSize - 1) * FRAME_INTERVAL)
{
if (psubtype)
*psubtype = MEDIASUBTYPE_UNDEFINED;
@@ -309,7 +315,6 @@ bool AudioJitterBuffer::Get(ImsMediaSubType* psubtype, uint8_t** ppData, uint32_
IMLOGD_PACKET4(IM_PACKET_LOG_JITTER,
"[Get] Wait - seq[%u], CurrJBSize[%u], delay[%u], QueueCount[%u]",
pEntry->nSeqNum, mCurrJitterBufferSize, jitterDelay, mDataQueue.GetCount());
- mCannotGetCount++;
return false;
}
else
@@ -321,6 +326,9 @@ bool AudioJitterBuffer::Get(ImsMediaSubType* psubtype, uint8_t** ppData, uint32_
}
else
{
+ IMLOGD_PACKET4(IM_PACKET_LOG_JITTER,
+ "[Get] Wait - seq[%u], CurrJBSize[%u], delay[%u], QueueCount[%u]",
+ pEntry->nSeqNum, mCurrJitterBufferSize, jitterDelay, mDataQueue.GetCount());
return false;
}
}
@@ -593,16 +601,26 @@ bool AudioJitterBuffer::Resync(uint32_t currentTime)
{
uint32_t timeDiff = currentTime - entry->arrivalTime;
- if (timeDiff > mCurrJitterBufferSize * FRAME_INTERVAL)
+ if (timeDiff > mCurrJitterBufferSize * FRAME_INTERVAL + ALLOWABLE_ERROR)
{
CollectRxRtpStatus(entry->nSeqNum, kRtpStatusDiscarded);
mDataQueue.Delete();
}
else
{
- // the first frame of voice term
- mCurrPlayingTS = entry->nTimestamp;
- return true;
+ if (!IsSID(entry->nBufferSize))
+ {
+ // the first voice frame
+ mCurrPlayingTS = entry->nTimestamp;
+ IMLOGD2("[Resync] currTs[%d], delay[%d]", mCurrPlayingTS, timeDiff);
+ return true;
+ }
+ else if (timeDiff > (mCurrJitterBufferSize - 1) * FRAME_INTERVAL)
+ {
+ mCurrPlayingTS = entry->nTimestamp;
+ IMLOGD2("[Resync] currTs[%d], delay[%d]", mCurrPlayingTS, timeDiff);
+ return true;
+ }
}
}