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

Fix noise crackling and clicks in unstable-2.7 #24

Open
wants to merge 15 commits into
base: unstable-2.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,36 @@ bld/
[Bb]in/
[Oo]bj/
DerivedData/
*.o

# Visual Studio 2015 cache/options directory
.vs/

xcuserdata/
autom4te.cache/

# autoconf build files
/Makefile
/Makefile.in
/aclocal.m4
/autom4te.cache/
/compile
/config.*
/configure
/depcomp
/install-sh
/libtool
/ltmain.sh
/m4/
/missing
/stamp-h?
.deps/
.dirstamp
.libs/
*.l[ao]
*~

# generated pkg-config file
/tgvoip.pc

# Qt Creator files
*.cflags
Expand All @@ -36,7 +60,5 @@ autom4te.cache/

# PVS Studio files
PVS-Studio.log
add_comments.log
compile_commands.json
pvs-report/
remove_comments.log
43 changes: 27 additions & 16 deletions JitterBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,30 @@ JitterBuffer::Status JitterBuffer::GetInternal(jitter_packet_t* pkt, std::uint32
if (advance)
Advance();

++m_lostCount;
if (offset == 0)
if (m_lastPutTimestamp != 0)
{
++m_lostPackets;
++m_lostSinceReset;
}
if (m_lostCount >= m_lossesToReset || (m_gotSinceReset > m_delay * 25 && m_lostSinceReset > m_gotSinceReset / 2))
{
LOGW("jitter: lost %d packets in a row, resetting", m_lostCount);
m_dontIncDelay = 16;
m_dontDecDelay += 128;
m_lostCount = 0;
ResetNonBlocking();
++m_lostCount;
if (offset == 0)
{
++m_lostPackets;
++m_lostSinceReset;
}
if (m_lostCount >= m_lossesToReset || (m_gotSinceReset > m_delay * 25 && m_lostSinceReset > m_gotSinceReset / 2))
{
LOGW("jitter: lost %d packets in a row, resetting", m_lostCount);
m_dontIncDelay = 16;
m_dontDecDelay += 128;
std::uint32_t currentDelay = GetCurrentDelayNonBlocking();
if (currentDelay < m_delay)
{
if ((m_delay - currentDelay) * m_step < m_nextTimestamp)
m_nextTimestamp -= (m_delay - currentDelay) * m_step;
else
m_nextTimestamp = 0;
}
m_lostCount = 0;
ResetNonBlocking();
}
}

if (!(advance && offset == 0))
Expand Down Expand Up @@ -285,17 +296,17 @@ void JitterBuffer::PutInternal(const jitter_packet_t& pkt, const std::uint8_t* d
return;
}

if (overwriteExisting)
auto it = m_slots.find(pkt.timestamp);
if (it != m_slots.end())
{
auto it = m_slots.find(pkt.timestamp);
if (it != m_slots.end())
if (overwriteExisting)
{
jitter_packet_t& slot = it->second;
slot.buffer.CopyFrom(data, 0, pkt.size);
slot.size = pkt.size;
slot.isEC = pkt.isEC;
return;
}
return;
}

++m_gotSinceReset;
Expand Down
13 changes: 12 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,18 @@ else
CFLAGS += -DTGVOIP_NO_DSP
endif

libtgvoip_la_LDFLAGS = -version-number @LIBTGVOIP_MAJOR_VERSION@:@LIBTGVOIP_MINOR_VERSION@:@LIBTGVOIP_PATCH_VERSION@
libtgvoip_la_CFLAGS = $(CRYPTO_CFLAGS) $(OPUS_CFLAGS)

if WITH_ALSA
libtgvoip_la_CFLAGS += $(ALSA_CFLAGS)
endif

if WITH_PULSE
libtgvoip_la_CFLAGS += $(PULSE_CFLAGS)
endif

libtgvoip_la_CXXFLAGS = $(libtgvoip_la_CFLAGS)
libtgvoip_la_LDFLAGS = -version-number @LIBTGVOIP_MAJOR_VERSION@:@LIBTGVOIP_MINOR_VERSION@:@LIBTGVOIP_PATCH_VERSION@ $(CRYPTO_LIBS) $(OPUS_LIBS)
libtgvoip_la_SOURCES = $(SRC) $(TGVOIP_HDRS)
tgvoipincludedir = $(includedir)/tgvoip
nobase_tgvoipinclude_HEADERS = $(TGVOIP_HDRS)
Expand Down
Loading