aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_buffer.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-11-28 11:56:01 +0100
committerMax Kellermann <max@duempel.org>2011-11-28 11:56:01 +0100
commit4f093d5b979c3547c8dd8045dde5d91e8cc93461 (patch)
tree94b1c12cfce14c90f26852e948ba419a8a7ba7eb /src/pcm_buffer.c
parent37420c342bf9582a0de32d46f78716e913119400 (diff)
parente1b032cbad5db7698104a93c2235fb7da1f8b580 (diff)
downloadmpd-4f093d5b979c3547c8dd8045dde5d91e8cc93461.tar.gz
mpd-4f093d5b979c3547c8dd8045dde5d91e8cc93461.tar.xz
mpd-4f093d5b979c3547c8dd8045dde5d91e8cc93461.zip
Merge branch 'v0.16.x'
Conflicts: Makefile.am NEWS configure.ac src/encoder/flac_encoder.c src/log.c src/pcm_buffer.c
Diffstat (limited to '')
-rw-r--r--src/pcm_buffer.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/pcm_buffer.c b/src/pcm_buffer.c
index 12d7194a6..b277e768e 100644
--- a/src/pcm_buffer.c
+++ b/src/pcm_buffer.c
@@ -1,5 +1,9 @@
/*
+<<<<<<< HEAD
* Copyright (C) 2003-2011 The Music Player Daemon Project
+=======
+ * Copyright (C) 2003-2010 The Music Player Daemon Project
+>>>>>>> v0.16.x
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -19,17 +23,30 @@
#include "pcm_buffer.h"
+/**
+ * Align the specified size to the next 8k boundary.
+ */
+G_GNUC_CONST
+static size_t
+align_8k(size_t size)
+{
+ return ((size - 1) | 0x1fff) + 1;
+}
+
void *
pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
{
+ assert(buffer != NULL);
+
if (buffer->size < size) {
/* free the old buffer */
g_free(buffer->buffer);
- /* allocate a new buffer; align at 8 kB boundaries */
- buffer->size = ((size - 1) | 0x1fff) + 1;
+ buffer->size = align_8k(size);
buffer->buffer = g_malloc(buffer->size);
}
+ assert(buffer->size >= size);
+
return buffer->buffer;
}