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_xfade.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/outputBuffer_xfade.h') diff --git a/src/outputBuffer_xfade.h b/src/outputBuffer_xfade.h index 336a7adc2..50fb062ce 100644 --- a/src/outputBuffer_xfade.h +++ b/src/outputBuffer_xfade.h @@ -5,8 +5,8 @@ #include "audio.h" #include "pcm_utils.h" -static struct ob_chunk *get_chunk(struct iovec vec[2], size_t i); -static size_t calculate_xfade_chunks(struct iovec vec[2]) +static struct ob_chunk *get_chunk(struct rbvec vec[2], size_t i); +static size_t calculate_xfade_chunks(struct rbvec vec[2]) { float xfade_time = ob.xfade_time; /* prevent race conditions */ size_t chunks; @@ -37,7 +37,7 @@ static size_t calculate_xfade_chunks(struct iovec vec[2]) if (chunks > (ob.index->size - ob.bpp_cur)) chunks = ob.index->size - ob.bpp_cur; DEBUG("calculated xfade chunks: %d\n", chunks); - nr = vec[0].iov_len + vec[1].iov_len; + nr = vec[0].len + vec[1].len; if (chunks <= nr) { c = get_chunk(vec, chunks); @@ -64,7 +64,7 @@ static size_t calculate_xfade_chunks(struct iovec vec[2]) return chunks; } -static size_t xfade_chunks_needed(struct iovec vec[2]) +static size_t xfade_chunks_needed(struct rbvec vec[2]) { assert(pthread_equal(ob.thread, pthread_self())); -- cgit v1.2.3 From 43fc7747130702b7a2a02547f90bbcbddf42d32d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:09 +0200 Subject: added inline function audio_format_time_to_size() Make the code more readable by hiding big formulas in an inline function with a nice name. --- src/outputBuffer_xfade.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/outputBuffer_xfade.h') diff --git a/src/outputBuffer_xfade.h b/src/outputBuffer_xfade.h index 50fb062ce..70e490c65 100644 --- a/src/outputBuffer_xfade.h +++ b/src/outputBuffer_xfade.h @@ -29,7 +29,7 @@ static size_t calculate_xfade_chunks(struct rbvec vec[2]) assert(af->channels > 0); assert(af->sampleRate > 0); - chunks = af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE; + chunks = audio_format_time_to_size(af) / CHUNK_SIZE; chunks = chunks * (xfade_time + 0.5); assert(chunks); -- cgit v1.2.3