From bedc17be5c594d9821a08036564cb1db2d0e3723 Mon Sep 17 00:00:00 2001 From: "A.Brauckmann" Date: Thu, 7 Jan 2016 12:38:31 -0800 Subject: [PATCH] Fixing integer underflow in FileAudioDevice (webrtc issue 4554) Problem is described here: https://code.google.com/p/webrtc/issues/detail?id=4554 Review URL: https://codereview.webrtc.org/1295603002 Cr-Commit-Position: refs/heads/master@{#11174} --- AUTHORS | 1 + .../audio_device/dummy/file_audio_device.cc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index c120acc12e..6f11ee66d8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -32,6 +32,7 @@ Silviu Caragea Steve Reid Vicken Simonian Victor Costan +Alexander Brauckmann &yet LLC Agora IO diff --git a/webrtc/modules/audio_device/dummy/file_audio_device.cc b/webrtc/modules/audio_device/dummy/file_audio_device.cc index 3fff40b0f9..ea432af203 100644 --- a/webrtc/modules/audio_device/dummy/file_audio_device.cc +++ b/webrtc/modules/audio_device/dummy/file_audio_device.cc @@ -500,7 +500,12 @@ bool FileAudioDevice::PlayThreadProcess() } _playoutFramesLeft = 0; _critSect.Leave(); - SleepMs(10 - (_clock->CurrentNtpInMilliseconds() - currentTime)); + + uint64_t deltaTimeMillis = _clock->CurrentNtpInMilliseconds() - currentTime; + if(deltaTimeMillis < 10) { + SleepMs(10 - deltaTimeMillis); + } + return true; } @@ -530,7 +535,12 @@ bool FileAudioDevice::RecThreadProcess() } _critSect.Leave(); - SleepMs(10 - (_clock->CurrentNtpInMilliseconds() - currentTime)); + + uint64_t deltaTimeMillis = _clock->CurrentNtpInMilliseconds() - currentTime; + if(deltaTimeMillis < 10) { + SleepMs(10 - deltaTimeMillis); + } + return true; }