diff options
author | Max Kellermann <max@duempel.org> | 2013-07-29 08:10:10 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-07-30 08:31:02 +0200 |
commit | c75cb67c4406648314ce2a15daf8b632374d7913 (patch) | |
tree | 5e27b73f2c90e878631bfac5b60070505b094717 /src/pcm/PcmBuffer.cxx | |
parent | cd1bb2bafa2653e5d4c7c9abf6f464bcdec693c5 (diff) | |
download | mpd-c75cb67c4406648314ce2a15daf8b632374d7913.tar.gz mpd-c75cb67c4406648314ce2a15daf8b632374d7913.tar.xz mpd-c75cb67c4406648314ce2a15daf8b632374d7913.zip |
pcm_buffer: convert to C++
Diffstat (limited to '')
-rw-r--r-- | src/pcm/PcmBuffer.cxx (renamed from src/pcm/pcm_buffer.c) | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/pcm/pcm_buffer.c b/src/pcm/PcmBuffer.cxx index 4b1eb875a..a70888080 100644 --- a/src/pcm/pcm_buffer.c +++ b/src/pcm/PcmBuffer.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ */ #include "config.h" -#include "pcm_buffer.h" +#include "PcmBuffer.hxx" #include "poison.h" /** @@ -32,27 +32,25 @@ align_8k(size_t size) } void * -pcm_buffer_get(struct pcm_buffer *buffer, size_t size) +PcmBuffer::Get(size_t new_size) { - assert(buffer != NULL); - - if (size == 0) + if (new_size == 0) /* never return NULL, because NULL would be assumed to be an error condition */ - size = 1; + new_size = 1; - if (buffer->size < size) { + if (size < new_size) { /* free the old buffer */ - g_free(buffer->buffer); + g_free(buffer); - buffer->size = align_8k(size); - buffer->buffer = g_malloc(buffer->size); + size = align_8k(new_size); + buffer = g_malloc(size); } else { /* discard old buffer contents */ - poison_undefined(buffer->buffer, buffer->size); + poison_undefined(buffer, size); } - assert(buffer->size >= size); + assert(size >= new_size); - return buffer->buffer; + return buffer; } |