aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm_buffer.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-11-27 20:04:56 +0100
committerMax Kellermann <max@duempel.org>2011-11-27 20:17:14 +0100
commita1e824ada0a08c0065a8a85a2e2aa979f6e97121 (patch)
tree2bc02f16addeb3d38fc0b192fe8724c8dab5693d /src/pcm_buffer.c
parentf5f1bfbef1e4f777a5928da901d0ec4cb063b3f1 (diff)
downloadmpd-a1e824ada0a08c0065a8a85a2e2aa979f6e97121.tar.gz
mpd-a1e824ada0a08c0065a8a85a2e2aa979f6e97121.tar.xz
mpd-a1e824ada0a08c0065a8a85a2e2aa979f6e97121.zip
pcm_buffer: move formula to new function align_8k()
Diffstat (limited to 'src/pcm_buffer.c')
-rw-r--r--src/pcm_buffer.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pcm_buffer.c b/src/pcm_buffer.c
index 126a4e036..75b76a5d3 100644
--- a/src/pcm_buffer.c
+++ b/src/pcm_buffer.c
@@ -19,6 +19,16 @@
#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)
{
@@ -26,8 +36,7 @@ pcm_buffer_get(struct pcm_buffer *buffer, size_t 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);
}