From 9b9680819aa702a852bba95abe4b3d32b037872e Mon Sep 17 00:00:00 2001 From: James Laird Date: Mon, 8 Apr 2013 19:58:16 +1000 Subject: [PATCH] player: cleanups should get rid of some sign issues in debug messages on ARM --- player.c | 17 ++++++++--------- player.h | 8 +++++++- rtp.c | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/player.c b/player.c index 6ad53d31..d00a2ad2 100644 --- a/player.c +++ b/player.c @@ -188,7 +188,7 @@ static void free_buffer(void) { void player_put_packet(seq_t seqno, uint8_t *data, int len) { abuf_t *abuf = 0; - short buf_fill; + int16_t buf_fill; pthread_mutex_lock(&ab_mutex); if (!ab_synced) { @@ -209,7 +209,7 @@ void player_put_packet(seq_t seqno, uint8_t *data, int len) { } else { // too late. warn("late packet %04X (%04X:%04X)\n", seqno, ab_read, ab_write); } - buf_fill = ab_write - ab_read; + buf_fill = seq_diff(ab_read, ab_write); pthread_mutex_unlock(&ab_mutex); if (abuf) { @@ -338,15 +338,14 @@ static void bf_est_update(short fill) { // get the next frame, when available. return 0 if underrun/stream reset. static short *buffer_get_frame(void) { - short buf_fill; - seq_t read; + int16_t buf_fill; + seq_t read, next; abuf_t *abuf = 0; - unsigned short next; int i; pthread_mutex_lock(&ab_mutex); - buf_fill = ab_write - ab_read; + buf_fill = seq_diff(ab_read, ab_write); if (buf_fill < 1 || !ab_synced || ab_buffering) { // init or underrun. stop and wait if (ab_synced) warn("underrun.\n"); @@ -354,7 +353,7 @@ static short *buffer_get_frame(void) { ab_buffering = 1; pthread_cond_wait(&ab_buffer_ready, &ab_mutex); ab_read++; - buf_fill = ab_write - ab_read; + buf_fill = seq_diff(ab_read, ab_write); bf_est_reset(buf_fill); pthread_mutex_unlock(&ab_mutex); @@ -366,7 +365,7 @@ static short *buffer_get_frame(void) { } read = ab_read; ab_read++; - buf_fill = ab_write - ab_read; + buf_fill = seq_diff(ab_read, ab_write); bf_est_update(buf_fill); // check if t+16, t+32, t+64, t+128, ... (buffer_start_fill / 2) @@ -383,7 +382,7 @@ static short *buffer_get_frame(void) { abuf_t *curframe = audio_buffer + BUFIDX(read); if (!curframe->ready) { - warn("missing frame.\n"); + warn("missing frame %04X.\n", read); memset(curframe->data, 0, FRAME_BYTES(frame_size)); } curframe->ready = 0; diff --git a/player.h b/player.h index 9222df7a..33b28c70 100644 --- a/player.h +++ b/player.h @@ -8,7 +8,13 @@ typedef struct { int32_t fmtp[12]; } stream_cfg; -typedef unsigned short seq_t; +typedef uint16_t seq_t; + +// wrapped number between two seq_t. +static inline uint16_t seq_diff(seq_t a, seq_t b) { + int16_t diff = b - a; + return diff; +} int player_play(stream_cfg *cfg); void player_stop(void); diff --git a/rtp.c b/rtp.c index beea88e2..3481c4da 100644 --- a/rtp.c +++ b/rtp.c @@ -175,7 +175,7 @@ void rtp_request_resend(seq_t first, seq_t last) { if (!running) die("rtp_request_resend called without active stream!\n"); - warn("requesting resend on %d packets\n", last-first+1); + warn("requesting resend on %d packets\n", seq_diff(first,last) + 1); char req[8]; // *not* a standard RTCP NACK req[0] = 0x80; req[1] = 0x55|0x80; // Apple 'resend'