From a848893d85cd027d831ba0ecae9dacef0a5f0605 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 30 Aug 2008 17:33:07 -0700 Subject: ringbuf: create a new struct rbvec instead of reusing struct iovec Using struct iovec means having to cast iov_base everywhere we want to do pointer arithmetic. Instead, just use rbvec which can be safely casted to iovec whenever we use the readv/writev functions. --- src/outputBuffer.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/outputBuffer.c') diff --git a/src/outputBuffer.c b/src/outputBuffer.c index a856c9a8c..27bb18b44 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -152,7 +152,7 @@ static enum action_status ob_finalize_action(void) /* marks all buffered chunks with sequence number matching `seq' as invalid */ static enum action_status ob_do_drop(void) { - struct iovec vec[2]; + struct rbvec vec[2]; long i; mpd_uint8 seq_drop; @@ -190,7 +190,7 @@ static enum action_status ob_do_pause(void) static void reader_reset_buffer(void) { - struct iovec vec[2]; + struct rbvec vec[2]; size_t nr; long i; @@ -330,15 +330,15 @@ static enum action_status ob_take_action(void) * like an infinite, rotating buffer. The first available chunk * is always indexed as `0', the second one as `1', and so on... */ -static struct ob_chunk *get_chunk(struct iovec vec[2], size_t i) +static struct ob_chunk *get_chunk(struct rbvec vec[2], size_t i) { - if (vec[0].iov_len > i) - return &ob.chunks[vec[0].iov_base + i - ob.index->buf]; - if (i && vec[1].iov_base) { - assert(vec[0].iov_len > 0); - i -= vec[0].iov_len; - if (vec[1].iov_len > i) - return &ob.chunks[vec[1].iov_base + i - ob.index->buf]; + if (vec[0].len > i) + return &ob.chunks[vec[0].base + i - ob.index->buf]; + if (i && vec[1].base) { + assert(vec[0].len > 0); + i -= vec[0].len; + if (vec[1].len > i) + return &ob.chunks[vec[1].base + i - ob.index->buf]; } return NULL; } @@ -426,7 +426,7 @@ static void send_next_tag(void) static void play_next_chunk(void) { - struct iovec vec[2]; + struct rbvec vec[2]; struct ob_chunk *a; size_t nr; static float last_time; @@ -551,7 +551,7 @@ void ob_seek_finish(void) */ void ob_flush(void) { - struct iovec vec[2]; + struct rbvec vec[2]; assert(pthread_equal(pthread_self(), dc.thread)); /* DEBUG(__FILE__":%s %d\n", __func__, __LINE__); */ -- cgit v1.2.3