aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-30 17:33:07 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-30 17:33:07 -0700
commita848893d85cd027d831ba0ecae9dacef0a5f0605 (patch)
tree0090036a5036ab3d7f8dce1cd35477536253e46d /src/outputBuffer.c
parentaa2fcfa7574ebdf3e348c051e496797841aa4f1d (diff)
downloadmpd-a848893d85cd027d831ba0ecae9dacef0a5f0605.tar.gz
mpd-a848893d85cd027d831ba0ecae9dacef0a5f0605.tar.xz
mpd-a848893d85cd027d831ba0ecae9dacef0a5f0605.zip
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.
Diffstat (limited to 'src/outputBuffer.c')
-rw-r--r--src/outputBuffer.c24
1 files changed, 12 insertions, 12 deletions
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__); */