aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
commitea51f73285f4aca931c8c7f497838da573f89142 (patch)
tree555da5884786c82f98353daf8240756e69af59f8 /src
parent5df6ff8d22115f8588c321527bd4e33624306422 (diff)
downloadmpd-ea51f73285f4aca931c8c7f497838da573f89142.tar.gz
mpd-ea51f73285f4aca931c8c7f497838da573f89142.tar.xz
mpd-ea51f73285f4aca931c8c7f497838da573f89142.zip
tail_chunk() returns ob_chunk pointer
Code simplification: since we are not using in-band signalling with the chunk index anymore, we can just return a pointer to the tail chunk instead of the index.
Diffstat (limited to 'src')
-rw-r--r--src/outputBuffer.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index aee2f832b..fc19dbc5e 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -150,10 +150,10 @@ ob_chunk * ob_get_chunk(const unsigned i)
/**
* Return the tail chunk which has room for additional data.
*
- * @return the positive index of the new chunk; -1 if there is no
+ * @return the chunk which has room for more data; NULL if there is no
* room.
*/
-static int tailChunk(float data_time, mpd_uint16 bitRate)
+static ob_chunk *tail_chunk(float data_time, mpd_uint16 bitRate)
{
unsigned int next;
ob_chunk *chunk;
@@ -165,7 +165,7 @@ static int tailChunk(float data_time, mpd_uint16 bitRate)
next = successor(ob.end);
if (ob.begin == next)
/* no chunks available */
- return -1;
+ return NULL;
output_buffer_expand(next);
chunk = ob_get_chunk(next);
@@ -180,7 +180,7 @@ static int tailChunk(float data_time, mpd_uint16 bitRate)
chunk->times = data_time;
}
- return ob.end;
+ return chunk;
}
size_t ob_append(const void *data0, size_t datalen,
@@ -191,12 +191,10 @@ size_t ob_append(const void *data0, size_t datalen,
ob_chunk *chunk = NULL;
while (datalen) {
- int chunk_index = tailChunk(data_time, bitRate);
- if (chunk_index < 0)
+ chunk = tail_chunk(data_time, bitRate);
+ if (chunk == NULL)
return ret;
- chunk = ob_get_chunk(chunk_index);
-
dataToSend = sizeof(chunk->data) - chunk->chunkSize;
if (dataToSend > datalen)
dataToSend = datalen;