Skip to content

Commit 19fd6ec

Browse files
johngroAndroid Git Automerger
authored andcommitted
am 0693887: LibAAH_RTP: Fix a stuttering audio bug.
* commit '06938878d3fd9f66d87518f690f1770d1e7a33da': LibAAH_RTP: Fix a stuttering audio bug.
2 parents 2db21f1 + 0693887 commit 19fd6ec

13 files changed

+555
-243
lines changed

media/libaah_rtp/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ LOCAL_SRC_FILES := \
1717
aah_tx_group.cpp \
1818
aah_tx_packet.cpp \
1919
aah_tx_player.cpp \
20-
pipe_event.cpp
20+
pipe_event.cpp \
21+
utils.cpp
2122

2223
LOCAL_C_INCLUDES := \
2324
frameworks/base/include \

media/libaah_rtp/aah_rx_player.h

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "aah_decoder_pump.h"
3333
#include "pipe_event.h"
34+
#include "utils.h"
3435

3536
namespace android {
3637

@@ -173,8 +174,7 @@ class AAH_RXPlayer : public MediaPlayerInterface {
173174
bool waiting_for_fast_start_;
174175
bool fetched_first_packet_;
175176

176-
uint64_t rtp_activity_timeout_;
177-
bool rtp_activity_timeout_valid_;
177+
Timeout rtp_activity_timeout_;
178178

179179
DISALLOW_EVIL_CONSTRUCTORS(RXRingBuffer);
180180
};
@@ -194,9 +194,26 @@ class AAH_RXPlayer : public MediaPlayerInterface {
194194

195195
bool isAboutToUnderflow();
196196
uint32_t getSSRC() const { return ssrc_; }
197-
uint16_t getProgramID() const { return (ssrc_ >> 5) & 0x1F; }
197+
uint8_t getProgramID() const { return (ssrc_ >> 5) & 0x1F; }
198198
status_t getStatus() const { return status_; }
199199

200+
void clearInactivityTimeout() {
201+
inactivity_timeout_.setTimeout(-1);
202+
}
203+
204+
void resetInactivityTimeout() {
205+
inactivity_timeout_.setTimeout(kInactivityTimeoutMsec);
206+
}
207+
208+
bool shouldExpire() {
209+
// Substreams should always have a positive time until timeout. A
210+
// timeout value of 0 indicates that the timer has expired, while a
211+
// negative timeout (normally meaning no timeout) is used by some of
212+
// the core code to implement a mark and sweep pattern for cleaning
213+
// out no longer relevant substreams.
214+
return (inactivity_timeout_.msecTillTimeout() <= 0);
215+
}
216+
200217
protected:
201218
virtual ~Substream();
202219

@@ -228,8 +245,10 @@ class AAH_RXPlayer : public MediaPlayerInterface {
228245
uint32_t aux_data_expected_size_;
229246

230247
sp<AAH_DecoderPump> decoder_;
248+
Timeout inactivity_timeout_;
231249

232-
static int64_t kAboutToUnderflowThreshold;
250+
static const int64_t kAboutToUnderflowThreshold;
251+
static const int kInactivityTimeoutMsec;
233252

234253
DISALLOW_EVIL_CONSTRUCTORS(Substream);
235254
};
@@ -247,7 +266,8 @@ class AAH_RXPlayer : public MediaPlayerInterface {
247266
void processRingBuffer();
248267
void processCommandPacket(PacketBuffer* pb);
249268
bool processGaps();
250-
int computeNextGapRetransmitTimeout();
269+
void setGapStatus(GapStatus status);
270+
void cleanoutExpiredSubstreams();
251271
void fetchAudioFlinger();
252272

253273
PipeEvent wakeup_work_thread_evt_;
@@ -268,7 +288,9 @@ class AAH_RXPlayer : public MediaPlayerInterface {
268288

269289
SeqNoGap current_gap_;
270290
GapStatus current_gap_status_;
271-
uint64_t next_retrans_req_time_;
291+
Timeout next_retrans_req_timeout_;
292+
293+
Timeout ss_cleanout_timeout_;
272294

273295
RXRingBuffer ring_buffer_;
274296
SubstreamVec substreams_;
@@ -282,15 +304,14 @@ class AAH_RXPlayer : public MediaPlayerInterface {
282304
static const uint32_t kRetransRequestMagic;
283305
static const uint32_t kFastStartRequestMagic;
284306
static const uint32_t kRetransNAKMagic;
285-
static const uint32_t kGapRerequestTimeoutUSec;
286-
static const uint32_t kFastStartTimeoutUSec;
287-
static const uint32_t kRTPActivityTimeoutUSec;
307+
static const uint32_t kGapRerequestTimeoutMsec;
308+
static const uint32_t kFastStartTimeoutMsec;
309+
static const uint32_t kRTPActivityTimeoutMsec;
310+
static const uint32_t kSSCleanoutTimeoutMsec;
288311

289312
static const uint32_t INVOKE_GET_MASTER_VOLUME = 3;
290313
static const uint32_t INVOKE_SET_MASTER_VOLUME = 4;
291314

292-
static uint64_t monotonicUSecNow();
293-
294315
DISALLOW_EVIL_CONSTRUCTORS(AAH_RXPlayer);
295316
};
296317

0 commit comments

Comments
 (0)